Forum Discussion

keithkelly's avatar
2 years ago

Rebuilding "Categories/Boards" List - any custom components or starter code?

I understand the "Community Board List" component can't be modified, yet there are a couple customizations I'd like to make.  So, I'd like to build my own component or contribute to a component that's already in the works. 

Looking for a bit of quick-start code or open-source component that at a minimum, lists:

  • Category
    • Board
    • Board
    • Board

 

  • Category
    • Board
    • Board
    • Board
  • etc

 

Things I'd like to do (compared to OOTB Community Board List)

  1. Parameterize the context
  2. Minify the date format
  3. Add "Topics" field (instead of "Posts")

 

I'm only looking for the FreeMarker code (not CSS) - If anyone has a simple component or code they can contribute for a starting point, I'm happy to share the changes I make. 

  • keithkelly 
    You can do it easily. You can follow below steps

    1. Get all boards 

     

    <#assign boardList=liql("select id,messages.count(*),view_href,title,conversation_style,description from boards where parent_category.id='${coreNode.id}' order by position asc").data.items />​

     

    • List down those boards 

     

    <#list boardList as board>
    <@boardsListGenrator board=board />
    </#list>​

     

    • If do not want to use the macro, directly right your code inside list show the required data for boards 

     

    <#list boardList as board>
    <p>${board.title}</p>
    </#list>​

     

    • If you want to show the Topics count instead of post, use this query

     

    SELECT count(*) from messages where board.id='BOARD_ID' and depth=0​

     

    • By defualt you can get the minified date using "user_friendly" selectror. If does not exist, use below code

     

    ${post_time?string["yyyy-MM-dd"]}

     

  • Wow, very helpful.  The boardListGenerator isn't working for me - do I need to acquire that from somewhere and paste it in as a macro?

    • VikasB's avatar
      VikasB
      Boss

      keithkelly 
      You can do it without macro also as I mentioned earlier that

      • If do not want to use the macro, directly right your code inside list show the required data for boards 

      Just to follow the best practices, you can create a macro to generate the boards list. I have sent you a code snippet in PM.