Hi: I am trying to figure out how to ‘dynamically insert’ (if that is the right term!) a category name into the pagination code below:
Currently I am hard coding ‘home’ so that all pages with this category go from previous to next - and all works well - and other listed pages are not included in the pagination.
However I was wondering if there was a way to replace ‘home’ with the current category of the listed pages so I wouldn’t have to create separate templates, etc.
Sorry, let me explain a bit! An artwork portfolio site where I have categories created which can be checked off in the panel - that allow certain artworks to show up. So let’s say five artworks have the ‘home’ checkbox checked, and another five have ‘private view’ checked.
The following code grabs all the pages in the ‘home’ category.
<?php foreach ($privatePages = $pages->children()->filterby('categories', 'home', ',') as $artwork): ?>
And this is fine to have the category inserted manually.
This is the blueprint:
categories:
label: Visibility Section
type: checkboxes
default: archive
options:
home: home
privateview: private view
preview: preview
studies: studies
review: review
exhibition: exhibition
archive: archive
So on the front end - when someone clicks on the artwork link to the ‘detail page’, I want the ‘NEXT | PREVIOUS’ links (on the detail pages) to only show the pages listed within a certain category. I have it working if I hard code the category ‘home’ (for example) in this template code:
OK, i put a comma after param - didn’t get an error
However, I only got the ‘NEXT’ LINK to appear on the page - and then no links at all after clicking on next.
Very close though!