We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20437
    • 16 Posts
    Apologies in advance for what may be a really stupid question, but I’ve searched the forums up and down for a way to access a specific post in the list that NewsListing returns.

    By that I mean this:

    When you use NewsListing you get back a list of posts/articles depending on the parameters you enter in the "search". Say you request the eight last posts in the folder ’News’. How do you access a specific post in that list, say post #9?

    What I want to do is to add a bit of randomness to the display of posts:

    +--+--+--+--+
    | 1 | 2 | 3 | 4 |
    +--+--+--+--+
    | 5 | 6 | 7 | 8 |
    +--+--+--+--+

    Each number in the table represents a space for a post. In reality ( with my randomness) I’d like to place posts in each holder. Say like this:

    +--+--+--+--+
    | P7 | P3 | P5 |P1|
    +--+--+--+--+
    | P6 | P2 | P4| P8 |
    +--+--+--+--+

    For that I would need to know how to access a specific post, and put placeholders in a chunk according to my randomness routine. Say I want the routine to write the 3rd place in the top line.

    <div id="P5">
    <p>[+Longtitle(5)+]</a> (i.e. the long title for post numer 5 in the returned list)
    <p>[+summary(5)+]</p> (i.e. the summary for post number 5 in the returned list)
    </div>

    Thanks in advance!
      • 18397
      • 3,250 Posts
      The way NewsListing currently works, this would not be possible as it uses a repeating template.

      The way you describe it is possible but would require quite a bit of coding.

      I could do something similar with much fewer lines of code. Tell me what you think of this: You could have [+item#+] placeholders for each post and could put them wherever you want. These would use the &tpl for code formatting.

        • 20437
        • 16 Posts
        Thanks for the reply. smiley

        I won’t even try to advice you how to code it. I think that an [+item+]-placeholder would be just fine, if that meant that I could - in the tpl-template - get access to the data in the item. The reason for my question is that there will be about twenty-thirty headline-articles per day, and to ensure an even display of these articles without clogging the main page there would have to be some sort of random display for the articles.