Jump to content

searching for image tags


Marty Walker
 Share

Recommended Posts

Hi all,

I'm using the standard search template and I want to have my search results pickup some image tags. I've added the tags option to my images field (portfolio_images). The tags output fine elsewhere but I'm wondering if I'm missing something or if it's even possible at all.

<?php

$matches = $pages->find("template=portfolio, title|first_name|last_name|body%=$q|portfolio_images.tags*=$q, limit=150"); 

Link to comment
Share on other sites

Hi Marty,

I'm not sure, but shouldn't it be with a comma, before your image field?

$matches = $pages->find("template=portfolio, title|first_name|last_name|body%=$q|portfolio_images.tags*=$q, limit=150");
$matches = $pages->find("template=portfolio, title|first_name|last_name|body%=$q,portfolio_images.tags*=$q, limit=150");
                                                                              > ! <

(Not tested)

  • Like 1
Link to comment
Share on other sites

i would have tried this first

$matches = $pages->find("template=portfolio, title|first_name|last_name|body|portfolio_images.tags*=$q, limit=150");

but if that didn't work then maybe or groups:

$matches = $pages->find("template=portfolio, (title|first_name|last_name|body%=$q), (portfolio_images.tags*=$q), limit=150");
  • Like 1
Link to comment
Share on other sites

I just tested Macrura's group approach and it works for me on an ImageExtra field.

It's modified slightly to match the fields/templates I have in my current sandbox install. I can't imagine why CroppableImage would affect this. 

$q = 'testtag';
$matches = $pages->find("template=home, (title|first_name|body%=$q), (images.tags*=$q), limit=150");
foreach($matches as $p) {
    echo $p->title;
}

What happens if you strip it down to the basics, like this:

$q = 'testtag';
$matches = $pages->find("images.tags~=$q, limit=150");
foreach($matches as $p) {
    echo $p->title;
}

Also, try putting this as is in a template file to make sure nothing is going wrong in getting $q to the selector. Of course you could also just echo the value of $q in your search template as well, but you see where I am headed :)

  • Like 1
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

  • Recently Browsing   0 members

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