Forum Discussion

Warren_Brill's avatar
6 years ago

List of all blog articles across the Community, but excepting one or more categories

I'd like to create a custom page that lists all blog articles across the site, but excepts one or more categories. Display parameters (e.g., ORDER BY) are less important than excepting the archives.

Has anyone done this? It would be a boost for SEO, as well as a list per se.

  • luk's avatar
    luk
    6 years ago

    Warren_Brill 

    when I put the JS into a component and save it, it executes from inside Studio, and I had to blow away the component entirely, lest it hang up Studio

    this you can easily avoid by wrapping your JS into an #if block, like so:

     

    <#if !page.name?matches('BizAppsPage')>
        <#-- add your JS, but not in the backend -->
        <@liaAddScript>
    
        </@liaAddScript>
    
        <#-- or simply -->
        <script>
            // here goes your JS
        </script>
    </#if>

     

     

    Regarding the API call I can't really help right now, Lithium/Khoros just locked everybody out of the Dev-Docs Portal (they did a redesign there...), e.g. looks like this when trying to access the API v2 message collection...

     

    SuzieH DougS  please fix this =)!

  • Tarun's avatar
    Tarun
    6 years ago

    Warren_Brill 

    You can try to update your code with the following

    <#assign articleList = rest("2.0","/search?q=" + "Select * from messages where board.id='AroundtheStorageBlock'"?url) />
    <#if (articleList.data.size?number > 0) >
    <#list articleList.data.items as article>
    <#-- your code for list comes here and you can acess detail about each article eg-->
    <p><a href="${article.view_href}">${article.subject}</a></p>
    </#list>
    <#else>
    <p>No articles in the given board ID</p>
    </#if>

    The anchor would create the link to the article's details. 

    Hope that's the solution required.

    Regards

    Tarun Kumar 

  • Hi Warren_Brill,

    what you need in this case is an API request looking like this:

    SELECT * FROM messages WHERE board.id NOT IN ('xxxx', 'yyyy')

    Of course with some additional filters for blog post type etc.

    Unfortunately, APIv2 doesn't have a NOT_IN operator. 😞 I already created an idea for this in the past.

    Up to the point where API gets such an operator, you can implement things using a white-list of boards/categories you want to query. Therefore create a Freemarker list with IDs you want to query:

    <#assign boards = ["id_1", "id_2"] />

    Then use this list as parameter in the query:

     

    SELECT * FROM messages WHERE board.id IN ('${boards}')

     

    Best regards,

    Christian

     

    • Thanks Christian,
      I'm working with this as a base. Question:
      For

      <#assign boards = ["id_1", "id_2"] />

       are "id_1" and "id_2" actual node IDs (numeric, as found in LSI) or the alphanumeric IDs used in Community Structure?

      This would make ORDER BY feasible.

      • cike's avatar
        cike
        Champion

        Warren_Brill  - use the node IDs from your community structure. These are the technical names for your nodes.