Forum Discussion

lorna's avatar
lorna
Maven
12 years ago

Using @component within an endpoint

We want a component (that is visible only to our admins) and shows the most active threads in that node. That part is fine. The next requirement is to be able to change the time range ...

 

So I have a component that by default displays 24h and has a dropdown selection to pick 1y, 1M or 1w. I'm using an endpoint for that with the node & time as url parameters.

 

It works ... except I made it easy and used <@component> to build it (see below). The links for the results is then wrong:

 

/*mycommunity*/forums/forumtopicpage/board-id/*boardid*/message-id/2

 

instead of

 

/t5/*boardname*/*subject*/m-p/421

 

 

Can I use @component within an endpoint? If so, how?

 

 

<#assign time_range = http.request.parameters.name.get("time_range","")?string />
<#assign category = http.request.parameters.name.get("category","")?string />
<#assign result_list_size = 5 />
<#assign rest_query = "/categories/id/"+category+"/search/messages?q=is_root:true&sort_by=-replies&rangeTime="+time_range+"&restapi.response_style=view&restapi.format_detail=full_list_element&include_forums=true&size=" + result_list_size />
<div id="new-activity"><@component id="forums.widget.message-list-panel" title="Most Active Threads" messages="rest_v1:"+rest_query style="slim" numMessages="conv:"+result_list_size /></div>

 Thank you!

1 Reply

  • PaoloT's avatar
    PaoloT
    Lithium Alumni (Retired)
    12 years ago

    Hi lorna,

     

    I think you can use the <@component> directive in an endpoint in general.

     

    However in your specific case it seems that you are attempting to reuse a lithium standard Forum component, which is meant to be used within the community quilts. Therefore it may not work as intended as I don't think it was designed for inclusion into an Endpoint (which is not part of the community structure). Maybe in this case the best approach would be to use a custom component.

     

    Hope this helps,