Advanced Searching
  • So I am trying to make a search that first searches through collection based on it's tags..then does a general query search on the system to include any other items that might have that query term as a part of it.

    Here is my code:


    <v:php>
    $search_results = array();
    </v:php>
    <v:collection path="/art[tags/name='<v=ucwords($tag)>']" unique="name">
    <v:php>
    array_push($search_results, $context['id']);
    $my_image = vae_sizedimage($context['image'], 'Thumb160');
    $path = vae_data_url() . $my_image;
    return '<img src="' . $path . '" />';
    </v:php>
    </v:collection>

    <v:collection path="/art" filter_input="tag" unique="name">
    <v:if path="count($search_results)>0">
    <v:if path="CHECKID(<v->)" is="true">
    <v:php>
    $my_image = vae_sizedimage($context['image'], 'Thumb160');
    $path = vae_data_url() . $my_image;
    return '<img src="' . $path . '" />';
    </v:php>
    </v:if>
    <v:else>
    <v:php>
    $my_image = vae_sizedimage($context['image'], 'Thumb160');
    $path = vae_data_url() . $my_image;
    return '<img src="' . $path . '" />';
    </v:php>
    </v:else>
    </v:if>
    </v:collection>

    in my __vae.php
    function CHECKID(myID)
    {
    $showMe = "true";
    foreach($search_results as $result)
    {
    if(myID == $result) $showMe = "false";
    }
    return $showMe;
    }



    It seems like the count check is working but it doesn't look like my CHECKID() function call I am making in the v:if line is...

    Any help on how to solve this and / or do another way would be greatly appreciated.

    Thanks,
    Brandon

  • 5 Answers sorted by
  • You probably need a global $myID, $search_results; in the CHECKID() function.

    But since you're already in PHP, I'd just do that whole inner block in PHP:


    if (count($search_results)) > 0) {
    if (CHECKID($id)) {
    $my_image = vae_sizedimage($context['image'], 'Thumb160');
    $path = vae_data_url() . $my_image;
    return '<img src="' . $path . '" />';
    } else {
    $my_image = vae_sizedimage($context['image'], 'Thumb160');
    $path = vae_data_url() . $my_image;
    return '<img src="' . $path . '" />';
    }
    }

  • hmmm is there a better way to do it maybe with vaeml this doesn't seem to be working either

  • Did you add the global line to the function?

  • i ended up being able to do with vaeml / vaeql

    this way if there is items listed by tags it will show those..if not it falls back on to the query search. which works for me :)

    thanks as always kevin!
    b



    <v:if path="/art[tags/name='<v=ucwords($tag)>']">
    <v:else>
    <v:collection path="/art" filter_input="tag" unique="name">
    </v:collection>
    </v:else>
    </v:if>

  • Nice!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership

In this Discussion