Forum Discussion

ryancjmp's avatar
2 years ago

Pass parameter to custom content component in community

For custom components that I build I can pass a parameter to it like so:

<@component id="custom.component" param="someParam" />

Then I can access that parameter within the component using:

<#assign param = env.context.component.getParamter('param') />

I would like to do this for a custom content component as well, but it doesn't seem to work.  Is there a way to pass data to the custom content components?

  • This should work whether it's an OOTB component or a custom component. 

     

    If you're looking for something passed via component, i.e., 

    In a quilt: 
    
    <component id="myComponent" msg="I like tacos" tacoType="chorizo with everything" />

     

    In the component receiving the parameters: 
    
    <#assign value1 = env.context.component.getParameter("msg")!"" />
    <#assign value2 = env.context.component.getParameter("tacoType")!"" />

     

    https://developer.khoros.com/khoroscommunitydevdocs/reference/contextcomponentgetparameterparameter_name

  • I think the answer is yes, but I still don't have an engineer cap, so I pretend to know what I am saying (Our engineer is on PTO else I would go get a smarter answer).

    In our Custom Content for our article tiles component we built, we have this (It has like 100+ parameters, we go crazy)

     

    <@component id="Custom.Article-Tiles-Final" carousel768="items:1" featured="true" showText="true" carousel="false" showDate="true" showMoreButton="false" sortBy="id DESC" displayNodes="Blog" end="true" carouselOptions="loop:true,nav:true,margin:0,items:1" displayArticles="1244758" showComments="false" showSubject="true" includeStyles="true" showArticleTeaser="true" showUser="false" start="true"  coverPhoto="/html/assets/demo-image-6.jpg" characterLimit="231" carousel992="items:1" carousel1400="items:1" displayAmount="1" showLabels="false" carousel1800="items:1" grid="1" showViews="false" showUpvotes="false" uniqueId="t432t4gre"/>

     

    In the component in Studio, he has this at the top of it

     

    <#--  component settings  -->
    <#assign displayAmount = env.context.component.getParameter("displayAmount")!"4">
    <#assign sortBy = env.context.component.getParameter("sortBy")!"post_time DESC">
    <#assign displayNodes = env.context.component.getParameter("displayNodes")>
    <#assign displayArticles = env.context.component.getParameter("displayArticles")!"">
    <#assign characterLimit = env.context.component.getParameter("characterLimit")!"50">
    <#assign featured = env.context.component.getParameter("featured")!"false">
    <#assign dateStart = env.context.component.getParameter("dateStart")!"">
    <#assign dateEnd = env.context.component.getParameter("dateEnd")!"">
    <#assign where = env.context.component.getParameter("where")!"">
    <#assign onlyLabel = env.context.component.getParameter("onlyLabel")!"">
    
    
    <#--  bottomText, bottomLink, dateStart, dateEnd, tabs, where  -->

     

    That help at all? Anything more specific I could go look for in the code to help with?