Forum Discussion

mfeltscher's avatar
10 years ago

Using system components in custom components (FreeMarker)

Hi

 

I'm looking for a way to integrate a system component into a FreeMarker template.

I want to render a blog post into my template by using the system template Lithium is using (no REST call fetching the data), as well as its comments. Basically, I'm looking for something like this:

<#-- Rendering blog post with ID "blog-post-id" -->
<@component id="blog_post" param=<blog-post-id> />

<#-- Rendering blog post comments for blog post with ID "blog-post-id" -->
<@component id="blog_post_comments" param=<blog-post-id> />

I wasn't able to find a system template for these, so I made up the template names ("blog_post" and "blog_post_comments").

 

Thanks for your help

 

Moreno

  • mfeltscher - What exactly you want to know, the template names?

     

    This is for the blog article

     

    <component id="article"/>

     

    this is for comment:

     

        <component id="comments"/>

     

    But it will not render the content in a page which is out of context.

    • mfeltscher's avatar
      mfeltscher
      Expert

      VarunGrazitti Thank you for your fast reply.

       

      First of all I wanted to ask, how I can find all available template names.

       

      The thing is, that we want to use this outside the context you described (for example inside a custom REST endpoint). Is this somehow possible?

      • VarunGrazitti's avatar
        VarunGrazitti
        Boss

        To know the names of the components, you'd need to switch to the XML view in studio page tab. It'll show you the names of all the components on that page.

        As long as you use that custom REST endpoint in the context of the page, rather on the same page where the default component is being used, you should be fine. E.g. if you use a blog page component on home page, you'll get an exception.