Easy method to get WowHead tooltips at website

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
kivol's picture

Hello,
as you know WowHead.com starts to provide its own tooltips system based on JavaScrips. What to do to get this unbelievable useful feature on your guild website?

First, I visited http://www.wowhead.com/tooltips, learn a bit about syntax. I thought that best location for this script will be node.module file, just right at beginning of the file, so next I made back up of node.module file (YOUR_WEBSITE_ADDRESS/modules/node/node.module, changed its name to exp. node_.module), edited node.module in some editor (exp. Notepad from Windows) and before first "<?php" mark I added:

saved file. I had to use Full HTML support during writing new messages (creating new contest), because of need of using 12345 ect. That is all, now pushed confirm button, but I saw blank page, BUT news was added and script works, only after confirm of making new news (or editing) I'm not receiving information about success process, only this empty page, how to resolve this problem? I traied to change another files, node.tpl.php, but without any results, maybe I should change another files then "node"? Some ideas?

Comments

Wowhead tooltips

ytwater's picture

Lets see. The easiest way to add wowhead tooltips to a Drupal website is to install the Lootz modules (http://drupal.org/project/lootz). It'll do everything for you as well as allow you to add [item]21134[/item] or [item]Dark Edge of Insanity[/item] links that will automatically convert to wowhead links.

If you want to do it manually, you'll want to edit the page.php.tpl (for drupal 6) or html.php.tpl (for drupal 7), if I recall the file names correctly. In those files, you'll be able to add wowhead's script tag inside the head area of each page.

Hope that helps!

Drupal 7

canucked's picture

So Lootz no longer works with D7. Last night I spent some time figuring out what it does and how to get info from wowhead, when I learned that wowhead provides an XML page for every item based on name or id.
From this I wrote a quick function for test purposes...

function get_wowhead_item_info($var){

  if(!is_numeric($var)){
    //if the string is text let's prepare it for the url
    $var = drupal_encode_path(ucwords($var));
  }

  $xml_path ='http://www.wowhead.com/item='.$string.'&xml';
  //Get the XML data from wowhead... need to make sure CDATA works
  $xml = simplexml_load_file($xml_path,'SimpleXMLElement', LIBXML_NOCDATA);
   
  if(!isset($xml->error)){
    //if there is no error let's get a move on
    $id = (string) $xml->item['id'];
    $name = $xml->item->name;
    $quality = strtolower($xml->item->quality);
    $url = 'http://www.wowhead.com/item='.$id;
    // build the link following...
    // <a href="http://www.wowhead.com/item=[ID]" class="loot [quality]">Item Name</a>
    $link = l('['.t($name).']',$url,array('attributes' => array('class' => array(t($quality),'loot'))));
    return $link;
  }

  return false;
}

I hacked the lootz module and was able to get this working. The function I wrote would replace over 200 lines of code currently in the module.

Lootz

Mrbjorklund's picture

Could you share the code for Lootz?

Best regards
Mr Bjorklund

Close!

andy68man's picture

You're missing a few things I'm afraid - what you've written will work if you put in the id number, but Lootz works if you just type in the name of the item. It will even search and produce the first item in the search if there are more than one.

I implemented this for my

Azelphur's picture

I implemented this for my site, It supports [item]Name, Partial name or ID[/item] and http://www.wowhead.com/item=ITEMID links. Enjoy.
http://drupal.org/node/1330012 :)

You can have a check at this

Sylvain Lecoy's picture

You can have a check at this project: http://drupal.org/project/wow.

Tooltips for wowhead are supported out the box !