Do not remember me!
/ / / How to display xfield image (poster) in quick search?

How to display xfield image (poster) in quick search?

Hello, I run DLE website for movies/films and I use xfield to add movie posters, is there any way I can show xfield image in quick search drop down list? Added by: in PHP Questions on
Yes you can easily add xfield image in quick search, simply open /engine/ajax/search.php and find:
$db->query("SELECT id, short_story, title, date, alt_name, category FROM " . PREFIX . "_post WHERE " . PREFIX . "_post.approve=1".$this_date." AND (short_story LIKE '%{$query}%' OR full_story LIKE '%{$query}%' OR xfields LIKE '%{$query}%' OR title LIKE '%{$query}%') ORDER by date DESC LIMIT 5");
Replace with:
$db->query("SELECT id, short_story, title, date, xfields, alt_name, category FROM " . PREFIX . "_post WHERE " . PREFIX . "_post.approve=1".$this_date." AND (short_story LIKE '%{$query}%' OR full_story LIKE '%{$query}%' OR xfields LIKE '%{$query}%' OR title LIKE '%{$query}%') ORDER by date DESC LIMIT 5");
Find:
$description = preg_replace( "'\[attachment=(.*?)\]'si", "", $description );
Add below:
$xfieldsdata = xfieldsdataload( $row['xfields'] );

Now you can add image tag in quick search by find the line:
$buffer .= "<span>".$description."</span></a>";
Replace with:
$buffer .= "<span><img src=\"".$xfieldsdata['Name of your additional fields']."\" class=\"poster\" style=\"float:left;margin:5px;width:"50px;height:50px\" />".$description."</span></a>";
You must replace "Name of your additional fields" with your actual xfield name and adjust the size of your choice...

This hack has been tested with DLE 9.8 and newer. Answered by: dlefaq



+5

Comments 1

  1. dlefaq
    +1
    dlefaq Currently Offline → 13 February 2015 00:41

    // This comment contains correct answer for this question
    == Removed and added to topic answer above ==
    // This comment contains correct answer for this question
     2 |  102

Information

Would you like to leave your comment? Please Login to your account to leave comments. Don't have an account? You can create a free account now.