Forum Discussion

Suchith's avatar
6 years ago

Displaying Custom Message in a Specific Category.

Hi.

I have a requirement, I want to display a message on a specific category. 

For instance: I have 20 Category in my community, but I have to display message only in one of the category.

Approach:

1) Create a custom component which has Code Logic :
    a) Trigger this component if current visited page is a category.
    b) Get category id.
    c) if category id == "mycategoryid"
    d) Display the content, else ignore

2)Add this component to Category Page.

Please let me know how can I implement  1.a and 1.b steps or a better way to implement this requirement.

Thanks

 

  • Suchith,

    for 1a. You can drectly include custom component to category page or you can add condition like below in your component.

    <#if page.name == "CategoryPage">

    for 1.b to get category id use below code:

    ${coreNode.id}
  • Suchith,

    for 1a. You can drectly include custom component to category page or you can add condition like below in your component.

    <#if page.name == "CategoryPage">

    for 1.b to get category id use below code:

    ${coreNode.id}
  • Depending on how "complex" your message is, it would likely be much easier to either use the "Announcement" and just fill it out on that specific node (although, this will will inherit down to child nodes if there are any) or use the built in "Custom Content" fields which can be included like a custom component within a quilt, e.g.

    <component id="common.widget.custom-content" name="<custom-content-id>" panel="false" />
    if there is not already a node specific custom quilt, you then would just create that custom quilt for the node where you want to display the custom content, add (properly configured) the above code and override the default quilt.