Macrura Posted March 17, 2013 Posted March 17, 2013 Hi all, i think i need some help with this: I have a field called Tags, which is a pageAutocomplete field, and allows the user to enter tags for a page; Then on the template i have an isotope display which has a filter, using the tags; Right now i'm just cycling through the tags (selector for template=tag) to create the list of filter links; but is there a way to check that a given tag is actually in use, by a page, since right now if someone enters a tag and then deletes it, that tag is still a tag page, but if you click on that filter, no items are displayed... TIA
Wanze Posted March 18, 2013 Posted March 18, 2013 Maybe something like this could work: $tags = $pages->find('template=tag'); foreach ($tags as $tag) { $c = $pages->count("tags={$tag}"); if ($c == 0) //... this tag was not assigned to pages, so don't output it with your filter } 2
Macrura Posted March 18, 2013 Author Posted March 18, 2013 Hi Wanze - many thanks - great and simple solution, nice thinking! here is how i finally implemented: <?php $tags = $pages->find("template=tag"); foreach($tags as $tag) { $c = $pages->count("template=audio, tags={$tag}"); if ($c == 0) continue; ?> //filter <li> markup here <?php } ?> 2
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now