Free Videos about Mastering Views

How To: Use Beauty Tips Module to Enhance Your Drupal Views

Play Video
Movie link (right-click to download)
Problem with this video? Contact me

When it comes to Web 2.0, it’s all about the GUI, UX, UE, WYSIWYG, FTW, WTH*. Ok, ok, enough acronyms. Let’s just leave things simple. “I saw this cool feature on another web site and I want that feature too.”

Typically, the feature you’re seeking to incorporate entails the use of AJAX or Javascript. While the cost for adding such features used to be quite high, the use of jQuery and its firm acceptance within Drupal make things much easier.

Enter modules such as Beauty Tips, and their integration with Views, and the tasty, gooey GUI you’re seeking becomes a reality.

This video presents a technique for using Beauty Tips to hover over a link, inbound from an RSS feed (pulled in via FeedAPI module), and show a quick synopsis of what the underlying link is about. The shortened body is presented within a Web 2.0 bubble, making it easy for scanning topics of interest. There are many ways to use modules such as Beauty Tips, and the presented technique is only one of many.

* (What the Heck - because WTF is just so juvenile)

You use the hook_preprocess_block() preprocess function. Wouldn't this do the beautyTip setup over and over for as many blocks you have on your page? Can you use the hook_preprocess_page() to do this once?

Yes, there are a number of places you can make the call to beautytips_add_beautytips(). Here's my understanding of why calling it within preprocess_block makes a bit more sense [at least to me - at my current level of understanding].

When PHP is loaded, no matter how much memory it uses to load your whole Drupal site (just to present the one page being requested), the functions are loaded into memory and ready to be called. Calling them takes very little time but multiplied, will add up (actually the total amount of code being loaded into memory is more of a concern first). If a particular function is called multiple times, which, in the case of preprocess_block, it would be, you're still talking about micro-micro-seconds of time.

Beyond this, most functions do some checking that asks questions like this, "Is this code already loaded to be used?". You can see this in many modules where you have lines of code like these

  • if (!$added) - in beautytips module, which then adds jquery code and css required
  • if (empty($javascript)) - in drupal_add_js to prevent adding Drupal's js multiple times, etc.
  • // Make sure the settings are not added more than once - A comment line in beautytips module

So, all of these function calls have single lines of code which determine if the rest of the code in the function should run. While, yes, it serves to reason that calling it within preprocess_page would save cpu cycles, we're really talking about an issue that's going to be an optimization issue when traffic gets to a pain point. Having it within preprocess_block (because in this case it's operating within a block seems to make more sense).

When you throw APC [an opcode cache] and/or memcache into the equation, which most certainly will happen if traffic is your problem (a great problem to have by the way), this issue may even be less of an issue.

Truth being told, I'm not a guru when it comes to the fine details of saving milliseconds of time based on a call to preprocess_page vs. preprocess_block. I'm sure there are discussions on Drupal.org about this very topic.

I personally chose preprocess_block because there have been situations where putting it within another preprocess function didn't render the results desired. An example might be a module which defines its own template and bypasses the page template and the preprocess_page function. In this case, because blocks would be loaded, you can be assured that your code will load and function properly. I will grant you that it requires a deeper understanding of the processing sequence and what the impacts are to making certain decisions. However, at this level of understanding. You're going to know that you have the option of preprocess_page vs. preprocess_block and how that relates to the theme and templates you are using.

If another developer, with more insight into the guts of Drupal is reading this, then by all means, chime in.

I've tried many different setups (d6 or acquia)... However when I try to add the Mapper module I get the following error (after I run update/cron)

* warning: array_keys() [function.array-keys]: The first argument should be an array in /Users/COMPUTERNAME/www/1sandbox/RSS.dev/sites/all/modules/feedapi/feedapi.module on line 1375.
* warning: Invalid argument supplied for foreach() in /Users/COMPUTERNAME/www/1sandbox/RSS.dev/sites/all/modules/feedapi/feedapi.module on line 1376.

Should I just ignore it ?
Have you seen this error before?

I've narrowed the error to Mapper module after many trial & error module installations. OSX with MAMP

Thanks for this nice video!! It is great and easy to use.

Great video, thank you! I followed your instructions and everything worked as a charm. But recently I upgraded to the latest Views 6.x-2.6 and the alt property in a View now returns nothing but the actual node title even when I write [body] in the alt property. I am baffled what's gone wrong. Have you run into a similar issue after upgrade?

Hi, it is a great video, thank you!
I would like to have the original feed url for the title. Is it possible?

hi there

i'm trying this code in template.php of a basic theme
but get no response -
any ideas what might the problem?

if( module_exists('beautytips') ) {
$options['bt_filemaker_blocks'] = array(
'area' => '#block-views-Twitter-block_1 .views-field-title a',
'contentSelector' => '$(this).attr("alt")',
'trigger' => array(0 => 'mouseover'),
'width' => 300,
);
 beautytips_add_beautytips($options);

I'd really like to use BeautyTips and views together in order to create a BeautyTip with an image in it. I've already defined the views field with the image URL, but I can't just drop it in the alt text. BeautyTips documentation requires an image to be specified in the jQuery, which in this example is static.

Any suggestions?

Hi,
Thank you very much for this video. I was looking for this since very long. Although, in this video, you have showed how to show feeds with beautytips within a specific block.. I followed your video and used content panes instead of blocks to show the RSS feed with beautytips. Could you please tell me a way how to show different RSS feeds of same content type with different blocks/content panes to show on the same page. Let me explain it more clearly, i want to do what POPURLS.is doing means showing RSS feeds from different sites. I'm trying to make a medical site showing RSS feeds from different Journal sites as well as other contents such as news, vidoes, pictures from different medical related sites. I have created a 'journal article' content type where i have put the RSS feeds of all the medical journals. Now, i want to show RSS feeds of every journal site with its own block/content pane but I'm not sure how to do that. I would be extremely grateful if you could help me find a way to do that.
Thanking you.
Regards,
Valley H

Ah very intereresting - so its kind of similar to the functionality on sites like popurls.
Have been looking for something like that for my world cup site.

ok i have 2 problems first one being when using the firebug i can see the body text which i want to under the alt tag but is being inserted into the title tag ? i can hover over the link and see adefault Alt tag information just having troubles gettign this to display with beauty tips

secondly

with the implementation i have found my template has no preprocces block functions ? any help as to where to put the code ? or as to what to do now ?

hope some one can point me in the right direction
cheers
 Mike

Great! I appreciate you very much! Thanks for sharing this with us!!
classifieds |ads|anaheim banquet hall