Forum Discussion

Puljac's avatar
Puljac
Maven
12 years ago

Member recent posts

Hi to all, 

 

I have questions from community members "I can't find my posts that i posted, where to see if somebody replyed to my query".

 

Instead of searching through categories and posts, basically they can go to their profile page and see widget for their recent posts, that widget is ".lia-component-forums-widget-recent-messages"

 

If they click on View all in that widget they go to /t5/forums/recentpostspage/post-type/message/user-id/4

 

So, I want to make ONE LINK for members on Homepage named "Your recent posts" and linked to that page /t5/forums/recentpostspage/post-type/message/user-id/

 

But how can i make that link for all users, cause member ID on end is dinamically and it depends on user ID which is loged in community?

 

Any suggestions....?

 

thanks a lot.

 

  • Puljac- we created a custom component for one of our communities that shows the user their five most recent posts. Here's a code snippet that shows how you can do this:

     

    <#if user.id != -1>
    <div class="RecentPosts">
    ...
        <#assign recentPosts = rest("/users/id/${user.id}/posts?page_size=5&restapi.response_style=view").node_message_context.message />
        <ul>
        <#list  recentPosts as recentPost>
            <li><a href="${recentPost.@view_href}">${recentPost.subject}</a></li>
        </#list>
        </ul>
    ...
    </div>
    </#if>

     

3 Replies

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

    Hi Puljac,

     

    I think you can achieve this using the Lithium Context objects, specifically the User one

     

    You can use ${user.anonymous} to determine if the viewer is actually logged in or not, and then ${user.id} to retrieve the unique user ID that you need. You can include this logic in a Studio Custom Component, and then add to the relevant area of your community.

     

    Hope this helps!

  • Puljac- we created a custom component for one of our communities that shows the user their five most recent posts. Here's a code snippet that shows how you can do this:

     

    <#if user.id != -1>
    <div class="RecentPosts">
    ...
        <#assign recentPosts = rest("/users/id/${user.id}/posts?page_size=5&restapi.response_style=view").node_message_context.message />
        <ul>
        <#list  recentPosts as recentPost>
            <li><a href="${recentPost.@view_href}">${recentPost.subject}</a></li>
        </#list>
        </ul>
    ...
    </div>
    </#if>

     

  • Puljac's avatar
    Puljac
    Maven
    12 years ago

    Thanks guys,

     

    I add "View All" link so user can view all of their posts

     

    <#if user.id != -1>
    <div class="RecentPosts">
        <#assign recentPosts = rest("/users/id/${user.id}/posts?page_size=5&restapi.response_style=view").node_message_context.message />
        <ul>
        <#list  recentPosts as recentPost>
            <li><a href="${recentPost.@view_href}">${recentPost.subject}</a></li>
        </#list>
        </ul>
    <a id="link_16" class="lia-link-navigation view-all-link" href="/t5/forums/recentpostspage/post-type/message/user-id/${user.id}">
        VIEW ALL
    </a>
    </div>
    </#if>