Searchresults in list view

Creating and modifying plugins.
Post Reply
onli
Regular
Posts: 2732
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Searchresults in list view

Post by onli »

The listsearch-plugin provides an alternative way of displaying the searchresults. Instead of listing all the entries in full length, a list with excerpts is shown.
Image
The output can be modified via smarty.

Garvin: Something like this don't exist yet? If that's true, shall I add this to spartacus?

Download: http://www.onli-blogging.de/uploads/ser ... 1.1.tar.gz
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Searchresults in list view

Post by yellowled »

onli wrote:Something like this don't exist yet? If that's true, shall I add this to spartacus?
I really like this, since it sets the search results page apart from the usual lists of entries, making it very clear to users that it actually is a search results page.

Just to, you know, root for it a little :)

YL
amazon Wishlist - Serendipity-Podcast (German only, sorry)
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Searchresults in list view

Post by Don Chambers »

I have not looked at this plugin in detail.... But I think I would rather see a truncation option in the quicksearch plugin itself, rather than a separate plugin. Does that make any sense, or is it just not a good idea due to code?
=Don=
onli
Regular
Posts: 2732
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Searchresults in list view

Post by onli »

Thanks Yellowled :)

@Don: The quicksearch-Plugin is only a sidebar-plugin, starting a search, and this search (part of the core) emits the entries as a whole. Changes to that would require a modification of core-functionality, of genpage.inc.php, and truncation of the entries via a function that also would need to be integrated into the core (at least that's the way as far as I can see). I didn't want to try that out without knowing that it would be added to the core.
Instead of that, the listsearch-sidebar-plugin points to an event-plugin, rendering the searchresults explicitly via smarty. I think that has its benefits.

But if Garvin thinks something like that should an can be added to the quicksearch-plugin: I would appreciate that (and also try to implement it).
garvinhicking
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Searchresults in list view

Post by garvinhicking »

Hi!

Hm, tough decission. On the one hand, how to display search results to me is more a thing of templating, so that you would put a {if $view == 'search'}...{/if} into entries.tpl, or offer it as a template option.

On the other hand, since it might be useful to many, it might be good to offer it as a more central plugin. Adding it to spartacus for a so singular reason seems a bit bloated to me, another option would be to put it into an existing plugin like serendipity_event_customarchive and add a description like "custom search" to its title.

Putting it in the core wouldn't also be too bad, but I wonder what we do with people that don't install the quicksearch plguin because they use a template where the search button is implemented? Maybe it would be best to submit a hidden input field that tells the template view=short or view=full, so that anyone witha custom template could also emit that hidden config field...

Just throwing some ideas. :)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Searchresults in list view

Post by yellowled »

garvinhicking wrote:Putting it in the core wouldn't also be too bad, but I wonder what we do with people that don't install the quicksearch plguin because they use a template where the search button is implemented?
I think there's also the issue that currently, this (I already tested it :)) acts as a "second" quicksearch sidebar plugin, which might be confusing.
garvinhicking wrote:Maybe it would be best to submit a hidden input field that tells the template view=short or view=full, so that anyone witha custom template could also emit that hidden config field...
Just my two cents, but I like that idea :)

YL
amazon Wishlist - Serendipity-Podcast (German only, sorry)
onli
Regular
Posts: 2732
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Searchresults in list view

Post by onli »

Maybe it would be best to submit a hidden input field that tells the template view=short or view=full, so that anyone witha custom template could also emit that hidden config field...
Think that's a good idea. But it would mean that the event-plugin had to be installed - or would you really want to change genpage.inc.php for that?
onli
Regular
Posts: 2732
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Searchresults in list view

Post by onli »

Ok, I totally forgot about that :D

To answer myself, the change to genpage would be really small:

Code: Select all

diff -Nur serendipity-nightly/include/genpage.inc.php /var/www/include/genpage.inc.php
--- serendipity-nightly/include/genpage.inc.php	2009-05-28 10:34:52.000000000 +0200
+++ /var/www/include/genpage.inc.php	2010-03-31 23:06:23.000000000 +0200
@@ -98,7 +98,8 @@
             $serendipity['smarty']->assign(
                 array(
                     'content_message'      => sprintf(YOUR_SEARCH_RETURNED_BLAHBLAH, '<span class="searchterm">' . $serendipity['GET']['searchTerm'] . '</span>', '<span class="searchresults">' . serendipity_getTotalEntries() . '</span>'),
-                    'searchresult_results' => true
+                    'searchresult_results' => true,
+                    'searchresult_fullentry' => $serendipity['GET']['fullentry']
                 )
             );
given this change to the quicksearch-plugin:

Code: Select all

diff -Nur serendipity-nightly/include/plugin_internal.inc.php /var/www/include/plugin_internal.inc.php 
--- serendipity-nightly/include/plugin_internal.inc.php	2010-01-13 13:28:55.000000000 +0100
+++ /var/www/include/plugin_internal.inc.php	2010-03-31 23:01:19.000000000 +0200
@@ -368,19 +368,37 @@
         $propbag->add('description',   SEARCH_FOR_ENTRY);
         $propbag->add('stackable',     false);
         $propbag->add('author',        'Serendipity Team');
-        $propbag->add('version',       '1.0');
+        $propbag->add('version',       '1.1');
+        $propbag->add('configuration', array('fullentry'));
         $propbag->add('groups',        array('FRONTEND_ENTRY_RELATED'));
     }
 
+    function introspect_config_item($name, &$propbag)
+    {
+        switch($name) {
+            case 'fullentry':
+                $propbag->add('type',       'boolean');
+                $propbag->add('name',        SEARCH_FULLENTRY);
+                $propbag->add('description', '');
+                $propbag->add('default',     true);
+                break;
+            default:
+                return false;
+        }
+        return true;
+    }
+
     function generate_content(&$title)
     {
         global $serendipity;
 
         $title = $this->title;
+        $fullentry = serendipity_db_bool($this->get_config('fullentry', true));
 ?>
 <form id="searchform" action="<?php echo $serendipity['serendipityHTTPPath'] . $serendipity['indexFile']; ?>" method="get">
     <div>
         <input type="hidden"  name="serendipity[action]" value="search" />
+        <input type="hidden"  name="serendipity[fullentry]" value="<?php echo $fullentry ?>" />
         <input alt="<?php echo QUICKSEARCH; ?>" type="text"   id="serendipityQuickSearchTermField" name="serendipity[searchTerm]" size="13" />
         <input class="quicksearch_submit" type="submit" value=">" alt="<?php echo QUICKSEARCH; ?>" name="serendipity[searchButton]" title="<?PHP echo GO; ?>" style="width: 2em;" />
     </div>
With these changes, a template could react in the entries.tpl like this:

Code: Select all

{if $searchresult_results and not $searchresult_fullentry} 
    {$entry.body|strip_tags|truncate:200}
{else}
    {$entry.body}
{/if}
It's a nice working solution, at least i think so, but it lacks a proper excerpt from the entry. Are there smarty-functions available which are a bit smarter than a simple truncate? Searchterms are marked anyway by serendipity_printEntries with a span-class...
onli
Regular
Posts: 2732
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Searchresults in list view

Post by onli »

Can this be committed or enhanced? Any comment?
garvinhicking
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Searchresults in list view

Post by garvinhicking »

Hi!

Yes! Pretty please. You do also have SVN access, right?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
onli
Regular
Posts: 2732
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Searchresults in list view

Post by onli »

As far as I know, only for additional_plugins. Which is fine for me :)
garvinhicking
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Searchresults in list view

Post by garvinhicking »

onli wrote:As far as I know, only for additional_plugins. Which is fine for me :)
Great, I committed it. Do you have a proposal for the language string "SEARCH_FULLENTRY"?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
onli
Regular
Posts: 2732
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Searchresults in list view

Post by onli »

"Show unshortened results" and german "Unverkürzte Ergebnisse anzeigen" would be my suggestion.
garvinhicking
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Searchresults in list view

Post by garvinhicking »

Hi!

Hm, how about "Show full entry"? This is a bit broader, but we could maybe use this string for other things in the future?

(German: "Vollständigen Artikel zeigen")

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
onli
Regular
Posts: 2732
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Searchresults in list view

Post by onli »

Fine with me :)
Post Reply