💾 Archived View for chirale.org › 2008-04-18_61.gmi captured on 2024-08-31 at 11:46:52. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-05-12)

-=-=-=-=-=-=-

Image rollover on primary links Drupal howto

Tested on:

Do you remember my Customize links menu in Drupal mini-howto? You can use it to change text links in image links renaming and customizing theme_links function (from theme.inc) and adding it to your template.php.

Customize links menu in Drupal

On your template.php file, you have something like this:

$imglink_path = path_to_theme() . “/my_zen_subtheme/menu/” . str_replace(” “,”\_”,strtolower($link\[‘title’\]) . $imgsuffix . “.gif”);

$imglink = theme_image($imglink_path, $alt = $link\[‘title’\], $title = $link\[‘title’\], $attributes = NULL, $getsize = FALSE);

if(empty($imglink))

$imglink = $link\[‘title’\];

Search for images in a defined folder by link title: if link title is “My Nice Link”, a “my_nice_link.gif” image is used. Generate HTML code for “my_nice_link.gif”. Note: getsize is set to FALSE to avoid errors on rollover If Drupal cannot generate HTML code for image (e.g. file not found) link is rendered as plain text

If you want to add a rollover effect on primary links images, you have to add this JQuery javascript code on page.tpl.php:

<script type="text/javascript">// <![CDATA[ $(document).ready(function() { $("#primary a").mouseover(function () { $rollsrc = $(this).children("img").attr("src"); $matches = $rollsrc.match(/_active.gif$/); if (!$matches) { $rollON = $rollsrc.replace(/.gif$/,"_active.gif"); $(this).children("img").attr("src", $rollON); } });

$(“#primary a”).mouseout(function ()

{

$(this).children(“img”).attr(“src”, $rollsrc);

});

});

// \]\]\>\</script\>

Where “\_active” is the rollover image.

See also:

Update:

https://web.archive.org/web/20080418000000*/http://drupal.org/project/jquery_update

https://web.archive.org/web/20080418000000*/http://www.atlantajones.com/2007/09/27/easy-reusable-image-rollovers-with-jquery/

https://web.archive.org/web/20080418000000*/http://drupalmodules.com/module/signwriter

https://web.archive.org/web/20080418000000*/http://drupal.org/node/336075