I'd like to know if I can use BeautyTips to display text from webpages, specifically, Drupal book pages (i.e. not necessarily an .html file)...

If this is possible, what's the syntax?

Comments

kleinmp’s picture

Yes, that is possible. For example, if you have the popup loading over a link with class 'example':

$options['ajax_example'] = array(
  'area' => 'a.example',
  'ajaxPath' => array('$(this).attr("href"), '#id.example p'),
);

So, '$(this).attr("href")' grabs the link 'href' attribute from the link. Then, it places the content contained in '#id.example p' from the other page into the popup. You probably don't want an entire page Drupal book page displayed in the popup, so it's a good idea to just select what you need from that page.

You should also be able to hard link a page that doesn't end in .html. (Use 'ajaxPath' => array(http://www.example.com/example, '#id.example p')).

Anonymous’s picture

I can't get it to work...

I want a hard-coded link, so am trying to use the following code:

<input type="text" id="my_field" title="title text" />

<?php
  $options['my_help'] = array(
    'area' => '#my_field',
    'ajaxPath' => array('http://localhost/drupal/my_help'),
  );
  beautytips_add_beautytips($options);
?>

My book page is located at: http://localhost/drupal/my_help

Using the above code, I'm not even getting the 'loading' or 'error' popups; I'm not getting any popup at all...

kleinmp’s picture

I would check if the beautytip is being added to the page element #my_field. If beautytips is recognizing it, then an attribute called bt_title will be added to #my_field.

Also, what file are you calling beautytips_add_beautytips($options); from? Note that If you call it from template_page_preprocess, then it is too late to add the jquery. At that point all javascript has already been added.

Anonymous’s picture

This is the code for #my_field:
<input id="my_field" class="bt-active" type="text" title="" bt-xtitle="title text"/>

I've put both the field code and PHP code in a page node, set to the PHP input format, but still no luck...

Anonymous’s picture

It works when I comment out the 'ajaxPath' line (it shows the title text in the popup), so BeautyTips is working.
It just doesn't seem to like something in 'ajaxPath' => array('http://localhost/drupal/my_help'),...

Any ideas?

kleinmp’s picture

Try doing this instead of using an array
'ajaxPath' => '/my_help',

or if there's a particular place on that page that you're trying to grab:
'ajaxPath' => '/my_help #example-id',

I haven't tested it too much, but it doesn't seem to like a full site url in this way.

Anonymous’s picture

Status: Active » Fixed

Thanks kleinmp, that worked!

For the record, I had to add /drupal to the beginning of the URL for it to work on my setup, and I was even able to go back to using the full URL: 'ajaxPath' => 'http://localhost/drupal/my_help #example-id',.

There must have just been an issue with setting it as an array...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.