Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
Wondering if i can set up the following, I have a blog post, Below it i'd like to show 4 related blog posts which i've picked - I've set this up using the related pages tag and that part works perfectly. But now as a 2nd option, if a blog post does not contain 4 pre-selected related paged, i'd like it to just show 4 related blog posts from within the same folder. Which i've also set up using the pages tag, The part I'm struggling on is intertwining the 2 so that if my blog post has 4 related pages, show those related pages, else, if it doesn't, show 4 blog posts from the same folder as the current blog.

Would anyone have any idea on how i would go about this?

Many Thanks for the help.
Hi,

You can get a count of related pages first like this (changing the name of the region of course) -
Code: Select all
<cms:set count_related_posts="<cms:related_pages 'name_of_related_region_field' count_only='1' />" />

Now based of that count you can display the normal pages from the folders e.g.
Code: Select all
<cms:if count_related_posts='0' >
   <cms:pages folder=..
   ..
</cms:if>

If required you can also use the count to calculate the number of pages to show e.g. if related pages were only 3, you can show 1 normal page.

Hope this helps.
Do let us know if something is unclear.

Thanks.
Ah sweet, thanks KK, that seems to work nicely.
3 posts Page 1 of 1
cron