Search in sources :

Example 11 with PageTemplate

use of com.enonic.xp.page.PageTemplate in project xp by enonic.

the class CreatePageTemplateCommand method execute.

public PageTemplate execute() {
    final PropertyTree data = new PropertyTree();
    new PageTemplateFormDataBuilder().supports(supports).appendData(data.getRoot());
    final Content content = contentService.create(CreateContentParams.create().name(name).displayName(displayName).owner(PrincipalKey.ofAnonymous()).contentData(data).type(ContentTypeName.pageTemplate()).inheritPermissions(true).parent(ContentPath.from(site, ContentServiceImpl.TEMPLATES_FOLDER_NAME)).build());
    return (PageTemplate) pageService.create(new CreatePageParams().content(content.getId()).controller(controller).config(pageConfig).regions(pageRegions));
}
Also used : CreatePageParams(com.enonic.xp.page.CreatePageParams) PageTemplate(com.enonic.xp.page.PageTemplate) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree)

Example 12 with PageTemplate

use of com.enonic.xp.page.PageTemplate in project xp by enonic.

the class ComponentInstructionTest method testInstructionRenderFragment.

@Test
public void testInstructionRenderFragment() throws Exception {
    RendererDelegate rendererDelegate = newRendererFactory("<b>part content</b>");
    ComponentService componentService = Mockito.mock(ComponentService.class);
    Component component = createPartComponent();
    doReturn(component).when(componentService).getByKey(isA(DescriptorKey.class));
    ComponentInstruction instruction = new ComponentInstruction();
    instruction.setRendererDelegate(rendererDelegate);
    instruction.setComponentService(componentService);
    PortalRequest portalRequest = new PortalRequest();
    Content content = createFragmentPage("content-id", "content-name");
    portalRequest.setContent(content);
    Site site = createSite("site-id", "site-name", "myapplication:content-type");
    portalRequest.setSite(site);
    PageTemplate pageTemplate = createPageTemplate();
    portalRequest.setPageTemplate(pageTemplate);
    String outputHtml = instruction.evaluate(portalRequest, "COMPONENT fragment").getAsString();
    assertEquals("<b>part content</b>", outputHtml);
}
Also used : Site(com.enonic.xp.site.Site) PageTemplate(com.enonic.xp.page.PageTemplate) Content(com.enonic.xp.content.Content) DescriptorKey(com.enonic.xp.page.DescriptorKey) ComponentService(com.enonic.xp.region.ComponentService) Component(com.enonic.xp.region.Component) PartComponent(com.enonic.xp.region.PartComponent) RendererDelegate(com.enonic.xp.portal.impl.rendering.RendererDelegate) PortalRequest(com.enonic.xp.portal.PortalRequest) Test(org.junit.jupiter.api.Test)

Aggregations

PageTemplate (com.enonic.xp.page.PageTemplate)12 Content (com.enonic.xp.content.Content)9 Site (com.enonic.xp.site.Site)8 Test (org.junit.jupiter.api.Test)8 Page (com.enonic.xp.page.Page)7 DescriptorKey (com.enonic.xp.page.DescriptorKey)3 PropertyTree (com.enonic.xp.data.PropertyTree)2 PortalRequest (com.enonic.xp.portal.PortalRequest)2 RendererDelegate (com.enonic.xp.portal.impl.rendering.RendererDelegate)2 Component (com.enonic.xp.region.Component)2 ComponentService (com.enonic.xp.region.ComponentService)2 PartComponent (com.enonic.xp.region.PartComponent)2 ContentNotFoundException (com.enonic.xp.content.ContentNotFoundException)1 ContentPath (com.enonic.xp.content.ContentPath)1 FindContentByParentParams (com.enonic.xp.content.FindContentByParentParams)1 FindContentByParentResult (com.enonic.xp.content.FindContentByParentResult)1 CreatePageParams (com.enonic.xp.page.CreatePageParams)1 PageRegions (com.enonic.xp.page.PageRegions)1 PageTemplates (com.enonic.xp.page.PageTemplates)1 ValueFilter (com.enonic.xp.query.filter.ValueFilter)1