Forum Discussion

iftomkins's avatar
11 years ago

How to find out the page name for conditional statements?

I'm trying to find the page name of a custom page template, which was created for us by a Lithium contact at some point. You can see in the screenshot the full name of the page (http://screencast.com/t/WlWlbkLpbinq), which is "CategoryPage.Product.quilt.xml". That is actually the full name.

 

This is what we're trying to achieve, but it does not work.

 

         <#if page.name?lower_case == "categorypageproductquiltxml" >

            $(".BoardBrowserListTaplet .CategoryListDisplay").eq(0).before('<a name="support"></a>');

$(".BoardBrowserListTaplet .CategoryListDisplay").eq(1).before('<a name="dashboard"></a>');

$(".BoardBrowserListTaplet .CategoryListDisplay").eq(2).before('<a name="feedback"></a>');

         </#if>

 

 I'd assume it would follow the same naming convention, so I've tried the following to no avail.

 

CategoryPageProductquiltxml

CategoryPageProduct

 

Thanks!

Alan

 

5 Replies

  • YuriK's avatar
    YuriK
    Khoros Expert
    11 years ago

    Hey Alan,

     

    I believe everything after the period is ignored for the page name, so the page name will be "CategoryPage" here.

     

    One good way to check what the name of a page is is as follows:

     

    1. Create a component that just outputs ${page.name}
    2. Put the component on the page that you want to see the name of
    3. Go to the page that you want to see the name of

    Hope this helps,

     

    Yuri

  • Hi,

     

    This is interesting problem and could be a common one for many people. Here is solution which I am thinking of. We can use the funtionlaity of Passing the Parameter to the custom component, which means you pass a paramater to your custom component which specifies the unique name of your page as you wish then get that in the custom component for the comparison.

     

    Please refer the below article on how to pass the parameter to the custom component and retreive it. 

     

    http://lithosphere.lithium.com/t5/developers-knowledge-base/Passing-Parameters-to-a-Custom-Component/ta-p/88704

     

    Thanks,
    Premkumar

     

     

  • For what it's worth, the body tag (in the HTML) has a class which indicates the page type. For example, this page has the following body tag:

    <body class="lia-board ForumTopicPage lia-body" id="lia-body">

    In this case, the page type is 'ForumTopicPage'.

     

    You can use this in a few ways:

    1. You can use it to work out what a given page type is on the community.
    2. You can create CSS rules that are specific to the page type (just have body.ForumTopicPage in the selector).
    3. You can use it in the jQuery select, e.g.
      $('.ForumTopicPage .BoardBrowserListTaplet .CategoryListDisplay')

    Depending on what you're trying to do, this can sometimes negate the need for custom logic.

  • iftomkins's avatar
    iftomkins
    Maven
    11 years ago
    Hi Yurik,

    Yes, you're right, it only outputs CategoryPage for the page name (${page.name} is good to know).

    This is a challenge for us because we have 2 pages which are both CategoryPage. How do we tell them apart with freemarker conditionals?

    Can you do page.template-name? Because they use different templates.

    Another thought is node.id, but I only saw an option for coreNode.id.

    - Alan
  • AdamN's avatar
    AdamN
    Khoros Oracle
    11 years ago

    If you need to know the name of a custom page that's being used for a particular node, you should be able to pull that information from the node settings. There are a series of settings in the "quilt" settings group that specify the name of the custom page being used. For a category page, the name of this setting is "quilt.categorypage". So then it's just a matter of retreiving the value via the REST API.

     

    For example, let's say I have a category with id CategoryABC and for that category I've gone into the Category Admin and set Content > Custom Pages > Category Page to "CategoryPage.XYZ". If I make this REST API call:

    /restapi/vc/categories/id/CategoryABC/settings/name/quilt.categorypage

    Then I will get back a value of:

    CategoryPage.XYZ

     

     

    The process is similar for other page types (i.e. The Forum Page setting is "quilt.forumpage"). Just keep in mind that what you're essentially doing is retreiving the value that has been set for the node in the Community Admin.