Jump to content

[SOLVED] Selector to retrieve tags only if has more than 1 item tagged.


Jhin
 Share

Recommended Posts

Hello,

I have in the template blog_posts the field tag_country as InputfieldTextTags field, linked to the pages with template "countries". I know I can safely show how many linked blog_posts to countries i have with:

<?php 
$desired_country = 1;
$blog = $pages->find("template=blog_posts, tag_countries=$desired_country"); 
foreach ($blog as $blogItem) {
# loop
}
?>

But how I can I get only the countries pages that has at least one item tagged? I tries something like this, but I'm feeling I'm missing a huge concept with nested subselectors.

<?php 
$countries = $pages->find("template=countries, [template=blog_posts, tag_country=id].count>=1, include=all"); 
foreach ($countries as $country) {
# loop
?>

I hope you can help me,

Thank you!

 

-----------------

I found a solution using the owner selector:

 $countries = $pages->find("template=country_item, parent=$continent, include=all, tag_country.owner.template=blog_posts");

 

 

Link to comment
Share on other sites

  • Jhin changed the title to [SOLVED] Selector to retrieve tags only if has more than 1 item tagged.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...