hi,

I'll start this feature request with a somewhat "theoretical" opening. As we know Digg, social bookmarking and social voting is basically an alternative style of content ranking and recommendation. The traditional search was the the "keyword search" (AltaVista, Yahoo, InfoSeek, etc) -- and Drupal's in-built search inherits this logic. Then came Google -- content ranking was now determined by an automated algorithm that took account of the number of backlinks (and also forwardlinks), to and from that content. Then came the Social Bookmarking sites (Digg, StumbleUpon, SlashDot, Reddit, Facebook etc) -- content recommendation and ranking became Social. In short, as the volume of content in Web 2.0 explodes, people look to Social Bookmarking sites to see which content is being recommended by their friends or other people who are interested in the same topics. Research shows that this is particularly true of news-content.

Just like any of these Social Bookmarking sites, people will come to Drupal/Drigg-powered sites to find content that other people deemed important, cool, worth-a-look or just simply interesting.
Roughly speaking, at the moment, Drigg has 3 main ways of arranging content recommendation:
A) the classic division between Upcoming and Popular sections (especially such options as top30days and top365days)
B) Categories (with each category having it's own front-page)
c) Integration with Tagadelic module

As the perfection of Drigg continues, I propose a gradual integration of Drigg with Drupal's search functionality. There are many ways in which this can be done, so I'll start with the most simple and basic idea:

What would be absolutely great (and probably not too difficult to achieve) at this stage is if the search results returned by Search module and ActiveSearch would be displayed with Karma numbers. The attached screenshot shows what I mean (please pay attention to what I encircled in red).

At the moment drupal's core Search and the ActiveSearch (included in JStools module) will return a bullet-pointed list of nodes with only their Title, small excerpt, author, created on, # of comments and number of attachments. But the visitors of Drigg sites (and other Social Bookmarking sites) make their decision as to which content to select and read based on the ammount of votes that it got. So it would really great if instead of the bulletpoints the end-users would see the little yellow/grey squares that display the Karma score for that particular node.

I'm not a coder, but I suspect that this could be just a simple insertion (or a snippet of some kind) of small *print* function in the page.tpl

Any idea as to how this small integration can be achieved?

Thank you!

Comments

drupalina’s picture

StatusFileSize
new14.8 KB

I think it would help if I added a visual sketch of what I have in mind. I've put it together with photoshop (see attachment below).

I think this kind of display of search results would be a great enhancement for all drigg-powered sites.

mercmobily’s picture

Status: Active » Fixed

Hi,

OK, it took me about 1 hour to figure this out... however, I will probably use it as a "drupal trick" for my book.

This is not a drigg issue but a drupal issue. However, since Drupalina helped so much with the module debugging, this is my token back...

Drupalina, you will need to set your own theme_search_item() function. Yes, it's programming... but it's very basic. If you don't know how to set your own theme functions, read one of the many tutorials available. You will basically need to change your template.php file, and add a function.

The best thing to do is to copy the EXISTING theme_search_item() function from the file search.module. Then, just change it to suit your needs. This is a practical example:

[...]
  if (is_array($item['extra'])) {
    $info = array_merge($info, $item['extra']);
  }

 # THIS IS THE NEW CODE
 $n_form='';
  if($item['node']){
    $n=$item['node'];
    if($n->type=='drigg'){
      $n_form=extra_voting_forms_show_form($n,'n',3, 'big');
    }
  }

  # IN THE FOLLOWING LINE,  I SIMPLY ADD n_form
  #
  $output .= ' <dd>'. $n_form .' - '. ($item['snippet'] ? '<p>'. $item['snippet'] .'</p>' : '') .'<p class="search-info">'. implode(' - ', $info) .'</p></dd>';
 
 return $output;
[...]

This will add the voting forms for Drigg nodes only. Neat uh? :-D
I am sorry, but I really can't help you 100%. However, with this information you are 98% there!

Bye,

Merc.

drupalina’s picture

Status: Fixed » Postponed (maintainer needs more info)
StatusFileSize
new17.86 KB

Hi,

Yes it worked ... Thank you very much Merc ... (This will also allow you to have the extra voting form to be displayed in the ActiveSearch , but it won't let you to vote when you press the up/down buttons.)

BUT my main concern is that it looks a bit "crippled" (see the screenshot) and I can't do any CSS around it.

I didn't touch the template.php and I just pasted a slightly modified version of your code into search.module ... I modified it a bit to allow for dt (table) kind of appearance... but it didn't really work

$output .= ' <dt>'. $n_form .'</dt> <dd>'. ($item['snippet'] ? '<p>'. $item['snippet'] .'</p>' : '') .'<p class="search-info">'. implode(' - ', $info) .'</p></dd>';

Can anyone _please_ help?

PS: I think when we finally have a good working solution for this tweak, it should definitely be included in the Drigg Installation guide. [I can do the write-up if that's of any help]

mercmobily’s picture

Hi Drupalina,

I am sorry, but this really isn't the right spot to ask CSS questions :-/
A writeup would be nice, but don't sweat!

Can you vote for stories returned from the normal search?
What is ActiveSearch? Can you send me an email with a link to your site where ActiveSearch is?

Merc.

drupalina’s picture

Hi,

I don't think I'm asking for CSS help. All I need is for those codes to be placed in the correct dt and dd places so that the search display looks more like this:
http://drupal.org/files/issues/Extra_voting_form_in-Active.png

If I knew what those commas and apostrophes are all about, I'd do it myself .. but I can't :(

And besides, since Karma number is another content-recommendation mechanism, I think it should definitely be an integral part of any drigg website. So, if we can get this to work, it would benefit not only me personally and my end-users (who requested this in the first place), but also all other drigg-powered websites.

----------------
Yes I can still vote for stories returned from the normal search :)

-------------------
ActiveSearch is part of JStools module http://drupal.org/project/jstools
ActiveSearch adds AJAX to search and also separates the results by content types into a very neat tab display.

-----------------
I will e-mail you website address now...

mercmobily’s picture

Hi,

Well, this is now a CSS/HTML/Theming issue (even though code generates it), and I _really_ cannot leave it open in the Drigg support system. It would create a _really_ bad precedent...

I can see in your site how activesearch results are not clickable. Feel free to open an issue about this specific issue, but I think it should be open in ActiveSearch. The problem really isn't connected to Drigg at all. In all honesty, I very much doubt it's actually possible to resolve it - basically, the problem is that the result is rendered with Javascript, and the voting form itself is javascript. I think it would make more sense to show there the amount of karma, rather than the form (which wouldn't look that good). What do you think?

Here's the code:

[...]
  if (is_array($item['extra'])) {
    $info = array_merge($info, $item['extra']);
  }


# THIS IS THE NEW CODE


list($content_type, $value_type, $tag,$function)=drigg_votingapi_variables();
$n_form='';
  if($item['node']){
    $n=$item['node'];
    if($n->type=='drigg'){
      $k = votingapi_get_voting_result($content_type,$n->nid,$value_type,$tag,$function);
      $k = $k->value;
    }
  }

  # IN THE FOLLOWING LINE,  I SIMPLY ADD n_form
  #
  $output .= " <dd>". $k " . ($item['snippet'] ? '<p>'. $item['snippet'] .'</p>' : '') .'<p class="search-info">'. implode(' - ', $info) .'</p></dd>';

return $output;
[...]

Bye,

Merc.

drupalina’s picture

This code gave me a WSOD
Parse error: syntax error, unexpected '"' in C:\wamp\www\driggtest\modules\search\search.module on line 1264
line 1264 in search.module is the one that holds the following code
$output .= " <dd>". $k " . ($item['snippet'] ? '<p>'. $item['snippet'] .'</p>' : '') .'<p class="search-info">'.

I totally agree that if it was a purely CSS question and only for individual capricious customizations, then it would set a _very_ bad precedent. But this feature request is something to do with code (which impacts the User interface) AND it is a kind of a tweak that all the Social Bookmarking sites usually have... plus it is not only for myself, but also for other drigg users to have -- something that could be later included in http://www.drigg-code.org/pages/download_and_install.

-------------------
As for the inability to vote in the ActiveSearch, I will raise a separate issue in Extra Voting Forms and also in ActiveSearch queue, but will mostly pursue it there (because it has to do with them more than with EVF). [but for now, this is not the priority as far as this feature request is concerned and is ultimately unrelated to it]

--------------------
Displaying only the Karma results without the up/down buttons (like currently in drigg blocks) is also an option, but it would be a derivation from what people are used to seeing on social bookmarking sites. no?

mercmobily’s picture

Hi,

Apologies. THe line should be:

$output .= " <dd> $k " . ($item['snippet'] ? '<p>'. $item['snippet'] .'</p>' : '') .'<p class="search-info">'.

I think displaying the karma only is actually more beneficial. I am not sure people expect the voting forms in a search result.

*Any* issue, Drupalina, will benefit everybody eventually. However, we don't have any way to support anybody's look and feel... :-(

I am not sure I will add this in the custom template... maybe!

Will mark this issue fixed in 48 hours.

Merc

sikjoy’s picture

Drupalina:

I would strongly recommend that you take mercmobily's original approach and add the theme_search_item() to your theme rather than modify the original function, i.e. hack Drupal. The reason being, if and when you upgrade your Drupal installation, your changes will be lost.

--sicjoy

drupalina’s picture

I was ready to give up on the idea, but after 5-6 hours of perseverance (something that would take an expert probably just a few minutes), I got something *beautiful* working.

I was initially thinking of just going with the just a simple display of karma next to the search results, then decided that that's not "interactive" enough and decided to build a search-results output that would have the Extra Voting Forms in it as well.

Here's the write-up for Drupal 5.7:

1) Go to your Search module folder and open the file called search.module with an editor
[NOTE: you are about to hack a module that comes with drupal core, and this will create a fork - i.e a derivative version of that module]

2) find the line if (is_array($item['extra'])) {
(It would probably be located on the line 1244 of the search.module)
Highlight everything from that line 1244 until few lines down where it says return $output;
and replace these highlighted lines with the following code:

  if (is_array($item['extra'])) {
    $info = array_merge($info, $item['extra']);
  }

# THIS IS THE NEW CODE
$n_form='';
  if($item['node']){
    $n=$item['node'];
    if($n->type=='drigg'){
      $n_form=extra_voting_forms_show_form($n,'n',3, 'big');
    }
  }

  # IN THE FOLLOWING LINE,  I SIMPLY ADD n_form
  #
  $output .= ' <dl class="search_evp">'. $n_form .'</dl> <dd>'. ($item['snippet'] ? '<p>'. $item['snippet'] .'</p>' : '') .'<p class="search-info">'. implode(' - ', $info) .'</p></dd>';

return $output;

(originally written by Merc and later modified by me - so use with caution!!!)

4) Then... few lines down after that find

function theme_search_page($results, $type) {
  $output = '<dl class="search-results">';

  foreach ($results as $entry) {
    $output .= theme('search_item', $entry, $type);
  }
  $output .= '</dl>';

...and replace those 2 dl tags with dd

4) Save and close this search.module file.

5) Open search.css file (located in the same folder)
and add the following css code in the bottom:

dl.search_evp {
  margin: -17px 0 5px 0;
  padding: 0px 3px;
  width: 54px; 
  float:left;
  } 
dt.title {
  margin: 0 0 0 54px;
  padding: 2px 3px;
  font-weight: bold;
  font-size: 1.1em;
}
p.search-info {
	margin: 0 0 20px 54px;
	 border-bottom: 1px solid #ccc;
}

... and that's it - Enjoy! It's Beautiful ! And the search display is more like what people expect from a Digg-like site ... Your Extra voting form will now display with your search results ;)

NOTE: even though the Extra Voting Form will display in JStools ActiveSearch results too, you still can't vote on the nodes (I guess this hickup is caused by the fact that one javascript interferes with another, and I will post a new issue/feature-request about this in Extra Voting Forms and also JStools ActiveSearch).

PLEASE ALSO NOTE that I realise that the above solution is a bit hack-ish (it displays clean, but it is not written very clean!!! (for instance pushing the search_evp upwards by -17px ; or renaming dl into dd; also something in this solution created a huge 400px gap below the footer)

... If you can come up with a better solution, please write it here.

drupalina’s picture

hi sickjoy,

I thought that adding theme_search_item() to my theme template.php , would be a much *much* cleaner solution, but I don't know any php :( I didn't know what to do

If you could help, that would be great!!!

Also... what do you think about my solution described in #10?

mercmobily’s picture

Hi,

Drupalina, all you need to do to make the solution more "generic" is:

1) Get your modified theme_search_item()

2) Paste it into your template.php file

3) Rename the function phptemplate_search_item()

And voila', your changes are there without modifying Drupal core!

Merc.

mercmobily’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

Hi,

Closing this issue, since it's a theming issue outside Drigg.
I will see if I can incorporate something like this for the D6 version of Drigg.

Bye,

Merc.

drupalina’s picture

Priority: Normal » Minor
Status: Closed (fixed) » Postponed (maintainer needs more info)
StatusFileSize
new18.97 KB
new19.59 KB

more info:

Thanks Merc and Sicjoy. I'll re do it through the template.php

however...

WARNING: Yesterday I finally reinstalled IE7 and had a look at my website through the prism of IE7. The above method appears to work nicely for Firefox, but in IE7 it looks horrible. See the screen-shots attached.

If you try something like this on IE7 or IE6, please report back with your screenshots

I'm reopening this issue with low-priority. I will need to do some more work on this, and will write the final write-up here.

mercmobily’s picture

Hi,

Drupalina, this really, really is a theming issue.
I really can't keep this open. I am sorry.

Will close it in 24 hours.

Merc.

drupalina’s picture

Assigned: Unassigned » drupalina

ok

mercmobily’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)