Jump to content

getting tags in use


Macrura
 Share

Recommended Posts

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

Link to comment
Share on other sites

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
}
  • Like 2
Link to comment
Share on other sites

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 } ?>
 
  • Like 2
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...