Limit number of items to display in a format

rgraves2's Avatar

rgraves2

30 Jun, 2015 12:44 PM

I have an index block that grabs a list of items and a format that displays them on the homepage. I was originally limiting the number to display in the index block. The problem is in my format I had to check a data definition field to see if that item should be displayed or not. This works, however I need to consistently have 4 items display so this would result in too few appearing.

What I'm wanting to do is set the index block's max rendered assets to a higher number and then use an XSLT counter to ensure only 4 appear. Can you tell me how to accomplish this?

  1. 1 Posted by Ryan Griffith on 30 Jun, 2015 02:49 PM

    Ryan Griffith's Avatar

    Hi,

    To accomplish this, I would have an <xsl:apply-templates> call that filters the items based on the field (and optionally sort the items). This would apply your "item" template to output each of the items. Within the "item" template, you would check to see if the item's position() is less than 5 (or less than equal to 4).

    Consider the following example for starters:

    <xsl:template match="/system-index-block">
      <xsl:apply-templates select="//system-page[system-data-structure/to-display = 'Yes']"/>
    </xsl:template>
    
    <xsl:template match="system-page">
      <xsl:if test="position() &lt; 5">
        <!-- Output page -->
      </xsl:if>
    </xsl:template>
    

    Please let me know if you have any questions.

    Thanks!

  2. 2 Posted by rgraves2 on 30 Jun, 2015 03:47 PM

    rgraves2's Avatar

    Thanks. This seems to have worked. I'll let you know if I have any other questions.

  3. 3 Posted by Ryan Griffith on 30 Jun, 2015 04:07 PM

    Ryan Griffith's Avatar

    Not a problem at all, I am glad to hear that the proposed solution did the trick.

    I'm going to go ahead and close this discussion for now, but please feel free to comment or reply to re-open if you have any additional questions.

    Have a great day!

  4. Ryan Griffith closed this discussion on 30 Jun, 2015 04:07 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

 

26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM