Not signed in (Sign In)

Vanilla 1.1.10 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorthebluebus
    • CommentTimeMay 22nd 2008
     
    is it possible to have plogger search more than one word and only display results that have both of those words, not just either one?

    i.e. blue+car | would display photos with BOTH words in the description or caption
    • CommentAuthorchewbears
    • CommentTimeMay 22nd 2008
     
    blue and car

    Someone will correct me if I am wrong but I believe it does handle and/or statements.
    • CommentAuthorthebluebus
    • CommentTimeMay 22nd 2008
     
    how do you use it? like you typed? doesnt work for me
    •  
      CommentAuthorkimparsell
    • CommentTimeMay 22nd 2008
     
    I'm guessing he means that you would type the search terms like this:

    blue AND car
    blue OR car

    Not sure if those work or not, but you might try it.
    • CommentAuthorthebluebus
    • CommentTimeMay 22nd 2008
     
    doesnt work
    • CommentAuthorthebluebus
    • CommentTimeMay 28th 2008
     
    anyone else :)
    •  
      CommentAuthorsidtheduck
    • CommentTimeMay 28th 2008 edited
     
    thebluebus,

    Do you only want it to search the caption and description or within the comment and / or filename like the current search looks?

    If you want it to search all, I did a quick fix that works (but isn't all that neat and clean). To do it, find the following code under function plogger_init_search($arr) in 'plog-functions.php':foreach ($terms as $term) {
    $query .= "
    `path` LIKE '%".mysql_escape_string($term)."%' OR
    `description` LIKE '%".mysql_escape_string($term)."%' OR
    `comment` LIKE '%".mysql_escape_string($term)."%' OR
    `caption` LIKE '%".mysql_escape_string($term)."%' OR ";
    }
    and edit it to read:foreach ($terms as $term) {
    $multi_term = explode("+",$term);
    if (count($multi_term)>1) {
    array_map('mysql_real_escape_string',$multi_term);
    $path_combine = implode("%' AND `path` LIKE '%",$multi_term);
    $desc_combine = implode("%' AND `description` LIKE '%",$multi_term);
    $comm_combine = implode("%' AND `comment` LIKE '%",$multi_term);
    $capt_combine = implode("%' AND `caption` LIKE '%",$multi_term);
    $query .= "
    `path` LIKE '%$path_combine%' OR
    `description` LIKE '%$desc_combine%' OR
    `comment` LIKE '%$comm_combine%' OR
    `caption` LIKE '%$capt_combine%' OR ";
    } else {
    $query .= "
    `path` LIKE '%".mysql_real_escape_string($term)."%' OR
    `description` LIKE '%".mysql_real_escape_string($term)."%' OR
    `comment` LIKE '%".mysql_real_escape_string($term)."%' OR
    `caption` LIKE '%".mysql_real_escape_string($term)."%' OR ";
    }
    }


    Then you just search for items with '+' in between the search terms you want to use (like blue+bus will search for 'blue' and 'bus' or car blue+bus will search for either 'car' or 'blue' and 'bus').

    If you only want it to search for description and caption, the code should look like:foreach ($terms as $term) {
    $multi_term = explode("+",$term);
    if (count($multi_term)>1) {
    array_map('mysql_real_escape_string',$multi_term);
    $desc_combine = implode("%' AND `description` LIKE '%",$multi_term);
    $capt_combine = implode("%' AND `caption` LIKE '%",$multi_term);
    $query .= "
    `description` LIKE '%$desc_combine%' OR
    `caption` LIKE '%$capt_combine%' OR ";
    } else {
    $query .= "
    `path` LIKE '%".mysql_real_escape_string($term)."%' OR
    `description` LIKE '%".mysql_real_escape_string($term)."%' OR
    `comment` LIKE '%".mysql_real_escape_string($term)."%' OR
    `caption` LIKE '%".mysql_real_escape_string($term)."%' OR ";
    }
    }


    That should do it!
    •  
      CommentAuthorsidtheduck
    • CommentTimeMay 28th 2008
     
    Sorry for the double post, but here's a slightly cleaner way to do it:foreach ($terms as $term) {
    $term = mysql_real_escape_string($term);
    $multi_term = explode("+",$term);
    if (count($multi_term)>1) {
    $path = implode("%' AND `path` LIKE '%",$multi_term);
    $description = implode("%' AND `description` LIKE '%",$multi_term);
    $comment = implode("%' AND `comment` LIKE '%",$multi_term);
    $caption = implode("%' AND `caption` LIKE '%",$multi_term);
    } else {
    $path = $description = $comment = $caption = $term;
    }
    $query .= "
    `path` LIKE '%$path%' OR
    `description` LIKE '%$description%' OR
    `comment` LIKE '%$comment%' OR
    `caption` LIKE '%$caption%' OR ";
    }
    • CommentAuthorthebluebus
    • CommentTimeMay 29th 2008
     
    thanks a lot.
    my site currently only search captions and descriptions using this mod

    http://plogger.org/forum/discussion/1788/search-not-to-use-filename/#Item_3

    i'll give yours a shot later! :)
    •  
      CommentAuthorsidtheduck
    • CommentTimeMay 29th 2008
     
    Posted By: thebluebusthanks a lot.
    my site currently only search captions and descriptions using this mod

    http://plogger.org/forum/discussion/1788/search-not-to-use-filename/#Item_3

    i'll give yours a shot later! :)
    Just follow the same direction as mike gave you in that discussion and remove the lines that you don't want it to search. I've tested mine on my site and it seems to work great. Hopefully it works as well on yours! :)
    • CommentAuthorthebluebus
    • CommentTimeMay 29th 2008
     
    thanks! worked perfectly, i just removed the filename searching :)

    $query .= " WHERE ( ";
    foreach ($terms as $term) {
    $term = mysql_real_escape_string($term);
    $multi_term = explode("+",$term);
    if (count($multi_term)>1) {
    $description = implode("%' AND `description` LIKE '%",$multi_term);
    $comment = implode("%' AND `comment` LIKE '%",$multi_term);
    $caption = implode("%' AND `caption` LIKE '%",$multi_term);
    } else {
    $path = $description = $comment = $caption = $term;
    }
    $query .= "
    `description` LIKE '%$description%' OR
    `comment` LIKE '%$comment%' OR
    `caption` LIKE '%$caption%' OR ";
    }
    • CommentAuthorchewbears
    • CommentTimeDec 9th 2008
     
    Just wanted to add a update to this code as it will fail to work if you are working with multipages that have been generated by your search as well as your slideshow.

    In function plogger_slideshow_link() {

    REPLACE:

    if ($GLOBALS['plogger_level'] == "search") {
    $ss_url = $config['baseurl'] . '?level=search&searchterms=' .$_GET['searchterms']);
    $ss_url .= "&mode=slideshow";
    $ss_tag = "<a href=\"$ss_url\">" . plog_tr('View as Slideshow') . "</a>";

    WITH :

    if ($GLOBALS['plogger_level'] == "search") {
    $ss_url = $config['baseurl'] . '?level=search&amp;searchterms=' . str_replace('+','%2B',$_GET['searchterms']);
    $ss_url .= "&amp;mode=slideshow";
    $ss_tag = "<a href=\"$ss_url\">" . plog_tr('View as Slideshow') . "</a>";

    that will properly build your slideshow based on your searchterms

    and in
    function plogger_pagination_control() {
    global $config;

    REPLACE:

    if ($GLOBALS['plogger_level'] == "search") {
    $EXIFterms = urlencode($_GET["searchterms"]);
    $p_url = $config['baseurl']."?level=search&amp;searchterms=".$_GET['searchterms'])."&amp;id=".$GLOBALS["plogger_id"];
    }

    WITH:

    if ($GLOBALS['plogger_level'] == "search") {
    $EXIFterms = urlencode($_GET["searchterms"]);
    $p_url = $config['baseurl']."?level=search&amp;searchterms=".str_replace('+','%2B',$_GET['searchterms'])."&amp;id=".$GLOBALS["plogger_id"];
    }

    Now when you click the generated pages they will hold true for your AND (+) statement