I’m currently developing an agency portfolio website where, on the projects pages, I’m displaying a random picked project at the end of the page. The idea is to have the user to be redirected to a random project in order to discover more about what the agency is doing.
The problem is that, sometimes, the displayed project is the same that we’re currently looking at …
Is there a way to “exclude self” so the random picked project is always another one than the current one?
Here’s the code I’m using for now:
{% set random = random(page.find('/projects').children().published()) %}
Yes, from what I understand from the documentation, it shouldn’t displays the current page …
@self.siblings - All the sibling pages
This collection will collect all the published Pages at the same level of the current page, excluding the current page:
random() cannot get a page and add it to collection. Could you debug siblings and see if current page is really there in the list? Is it possible you have a duplicate page which seems like the same page, but actually isn’t?
@Valord, It is often not appreciated if a post is cross-posted on another forum. It ultimately means the effort invested by people on one forum is wasted…
It would therefor be polite to pro-actively mention the post has been cross-posted.