Possible to change the display for the Yahoo BOSS ?

patchak - May 9, 2009 - 16:56
Project:More Like This
Version:6.x-1.1
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:febbraro
Status:won't fix
Description

Hey there, this module is great! If I can manage to fix some issues like automatically tagging content for MLT then I could really use this on a large scale project!!

Anyways, I was wondering if it's possible to change the results for the BOSS search results? For example, I would like to remove the date and maybe provide a small sentence below the link to describe the link. Is this possible by using this module, or we would be better to actually integrate with the BOSS API directly?

Thanks a lot,

Patchak

#1

febbraro - May 9, 2009 - 17:58
Assigned to:Anonymous» febbraro

Hey Patchak,

All MLT results are completely theme-able. For Yahoo BOSS News/Web search, for example, these are the default theme functions (as of v 1.1):

/**
* Theme an individual morelikethis item.
*
* @param $item
*    An More Like This object for the provided node.
*/
function theme_morelikethis_yboss_item($item) {
  return theme("morelikethis_yboss_{$item->yboss_type}_item", $item);
}

/**
* Theme an individual morelikethis web item.
*
* @param $item
*    An More Like This object for the provided node.
*/
function theme_morelikethis_yboss_web_item($item) {
  return l("$item->title ($item->date)", $item->clickurl);
}

/**
* Theme an individual morelikethis news item.
*
* @param $item
*    An More Like This object for the provided node.
*/
function theme_morelikethis_yboss_news_item($item) {
  $output = l("$item->title", $item->clickurl);
  $output .= ' - (' . l("$item->source", $item->sourceurl) . ')';
  return $output;
}

Those are just for the individual items, so in order to change it you can implement [themename]_moreliekthis_yboss_item or [themename]_morelikethis_yboss_web_item and do whatever you like.

Further, if you want to theme the overall structure of the block you can implement [themename]_morelikethis_yboss_block.

Hope that helps.

#2

patchak - May 9, 2009 - 18:19

Wow this is great!!

Hummm kinda newbie question : how can I see all the variables available to me in this function? I need to do like "print_r($item)" in my theme override to get to see it? Is there a place where I could see a list??

thanks,
Patchak

#3

febbraro - May 9, 2009 - 20:27
Status:active» won't fix

Yes you can use print_r or var_dump.

Another thing I like to do is install the devel module and use the

dpm($item);

Good luck.

#4

patchak - June 22, 2009 - 16:10

Hummm here is the theme function I have now :

/**
* Theme an individual morelikethis web item.
*
* @param $item
*    An More Like This object for the provided node.
*/
function theme_morelikethis_yboss_web_item($item) {
var_dump($item);
  return l("$item->title ($item->date)", $item->clickurl);
  print '<br />' . $item->teaser;
}

/**
* Theme an individual morelikethis news item.
*
* @param $item
*    An More Like This object for the provided node.
*/
function theme_morelikethis_yboss_news_item($item) {
  $output = l("$item->title", $item->clickurl);
  $output .= ' - (' . l("$item->source", $item->sourceurl) . ')';
  $output .= '<br />' . $item->teaser;
  return $output;
}

I added some code to print the "$item->teaser; " element, but I can't see any change when I refresh my pages. i tried resaving the node, emptying the cache, but no luck at all!

Any advice?
thanks,

Patchak

#5

febbraro - June 22, 2009 - 16:58

If those functions are defined in your theme's template.php file then you need to change [theme] to the actual name of your theme. Then you need to clear all caches (as the theme registry is cached).

Good luck

 
 

Drupal is a registered trademark of Dries Buytaert.