- Posts: 26
COMMUNITY FORUM
Images in search results
- Mark Foster
-
Topic Author
- Offline
- Junior Member
Is there any way or hack that I can implement so that images can be shown in search results
It's critical for a properties site that I am making
Please help!
Kind regards
Mark
Please Log in or Create an account to join the conversation.
- BBC
-
- Offline
- Platinum Member
- Posts: 663
How many columns do you want ? Intro, just Title ? Something else ?
Please Log in or Create an account to join the conversation.
- Mark Foster
-
Topic Author
- Offline
- Junior Member
- Posts: 26
Sorry I should said, I'm using the extra fields search from Joomlart as I need to to be able to offer drop down choices as well otherwise I would have used the k2 tools one
Site is here
www.farmhousesaleslemarcheitaly.co.uk/
If you set province in the search to Fermo, then 2 results are returned, I need to be able to display the images next to them.
Mamy thanks
Mark
Please Log in or Create an account to join the conversation.
- BBC
-
- Offline
- Platinum Member
- Posts: 663
There are some image frames.
Please Log in or Create an account to join the conversation.
- Mark Foster
-
Topic Author
- Offline
- Junior Member
- Posts: 26
Which modded the default_results.php file in com_search and added this
<img src="<?php echo $result->image; ?>" alt="<?php echo $result->title; ?>" title="<?php echo $result->title;?>" width="100px" height="100px"/>
the result class is empty though and isn't returning an image though
I guess this is all means getting further into how K2 and the standard Joomla search work together
Thanks
Mark
BBC said:
Do you testing something ?
There are some image frames.
Please Log in or Create an account to join the conversation.
- BBC
-
- Offline
- Platinum Member
- Posts: 663
Fast, not as you want it, in Joomla com_search.
But, i cannot get images to show in search listing.
Please Log in or Create an account to join the conversation.
- jjozsika
-
- Offline
- New Member
- Posts: 6
You have the search mod which is searching in the table.
Located: plugins/search/jak2_filter.php
It has the SQL query with binary search, you have to add the id field to the selected list:
In the 231. line oyou have to add the id field name:
$query = " SELECT i.id, i.title, i.metadesc,
Now, you can go and edit the result lister tamplate:
/templates/gk_mystore/html/com_search/search/default_results.php
After the result cycle,
<?php foreach ($this->results as $result) : ?>
You can add the image generation based pn the id and md5() hash:
<?php $row = './media/k2/items/cache/'.md5("Image".$result->id).'_S.jpg'; if(file_exists($row)) echo "<img src=\"$row\">";?>
And woala, the images right there!
regards, jjozsi
Please Log in or Create an account to join the conversation.
- Mark Foster
-
Topic Author
- Offline
- Junior Member
- Posts: 26
Thanks
Mark
Please Log in or Create an account to join the conversation.
- jjozsika
-
- Offline
- New Member
- Posts: 6
Mark Foster said:
Will try that now and let you know!
Thanks
Mark
Please Log in or Create an account to join the conversation.
- Mark Foster
-
Topic Author
- Offline
- Junior Member
- Posts: 26
Works great, been waiting weeks to find a solution to that :)
Thank you so much
Please Log in or Create an account to join the conversation.
- jjozsika
-
- Offline
- New Member
- Posts: 6
Mark Foster said:
You are a star :)
Works great, been waiting weeks to find a solution to that :)
Thank you so much
Please Log in or Create an account to join the conversation.
- Emily Pearce
-
- Offline
- Junior Member
- Posts: 24
I would also like to include an items extra fields in the Joomla search results.
Any idea how i might do this?
Many thanks, Emily
Please Log in or Create an account to join the conversation.
- jjozsika
-
- Offline
- New Member
- Posts: 6
Please Log in or Create an account to join the conversation.
- Liam McGarry
-
- Offline
- New Member
- Posts: 3
I've signed up to say a massive thank you to jjozsika who solved the exact same problem that I had!
For anyone who may be stuggling to find the default_results.php file, it can be found in different locations, mine was:
components/com_search/views/search/tmpl
Also, whilst on the topic of searching, does anyone know how to modify the search results screen?
I.e Remove:
Search Keyword: SearchAll words Any words Exact PhraseSearch Only:Activities Other group
I too am using K2 search filter
Please Log in or Create an account to join the conversation.
- Francisco Ferreira
-
- Offline
- Junior Member
- Posts: 28
Many thanks jjozika.
We now know how to put images on search results. Nonetheless It would be the ultimate help if you or someone could explain us newbies how to do the same with other extra fields, i.e. I understand we just need to put the field name like: $query = " SELECT i.id, i.title, i.metadesc,
... but I'm not so clear about what to put on the default_results.php ?
Can you help us please?
Many thanks in advance...
Francis
ps: Why would JA guys make the dificult part only to en up before developing the easyer part, i.e. costumizable results display...
Please Log in or Create an account to join the conversation.
- Brenda
-
- Offline
- New Member
- Posts: 13
Please Log in or Create an account to join the conversation.
- Brenda
-
- Offline
- New Member
- Posts: 13
In this file: /plugins/search/k2.php
add the id to the SELECT query (It has the SQL query with binary search, you have to add the id field to the selected list:
add the id field name):
$query = " SELECT i.id, i.title, i.metadesc,
In this file: /components/com_search/views/search/tmpl/default_results.php
AFTER THIS SECTION(or where you want to position the image) :
if ( $result->section ) : ?><br /><span class="small<?php echo $this->escape($this->params->get('pageclass_sfx')); ?>">(<?php echo $this->escape($result->section); ?>)</span><?php endif; ?><?php endif; ?></div>
ADD THIS:
<?php $row = './media/k2/items/cache/'.md5("Image".$result->id).'_S.jpg'; if(file_exists($row)) echo "<img src=\"$row\">"; ?>
Please Log in or Create an account to join the conversation.
- Jock
-
- Offline
- Premium Member
- Posts: 90
This is kind of related but not entirely the same ... does anyone know how you return $result->text; for extra fields? Basically I want my search results to have the snippet of text with the highlighted keywords for content that is in extra fields. Currently it is returning the matching item but not with the snippet.
Anyone know how to fix this?
Please Log in or Create an account to join the conversation.
- Sotiris
-
- Offline
- New Member
- Posts: 6
Anyone know how i can do it?
Please Log in or Create an account to join the conversation.
- Jock
-
- Offline
- Premium Member
- Posts: 90
Please Log in or Create an account to join the conversation.