You are here:  » Formatting hyperlinks


Formatting hyperlinks

Submitted by dbfcs on Mon, 2006-09-25 12:29 in

I am looking to change URLS from being

<a href="http://www.google.com">Google</a>

to something like

<a href="http://www.google.com" title="Google">Google</a>

where google is any page on my site and the title tag reads the page title tag.

I am looking for this for accessibility reasons.

I need this to work for any dynamically derived hyperlinks.

Extending this further, I would also like img tags to have an alt and a title tag. Advice on how to change these (for the thumbnails and the actual pictures) would be gratefully welcomed!

Thanks,

Dave

Submitted by support on Mon, 2006-09-25 12:41

Hi Dave,

Taking your points in reverse order...

> I would also like img tags to have an alt and a title tag

The images currently only have an alt='Product Name' tag. To make a title='Product Name' tag you'll need to make changes in html/searchresults.php and html/product.php.

In searchresults.php, look for the following code (line 10):

<img border='0' width='80' src='<?php print $product["image_url"]; ?>' alt='<?php print $product["name"]; ?>' />

...and change that to read:

<img border='0' width='80' src='<?php print $product["image_url"]; ?>' alt='<?php print $product["name"]; ?>' title='<?php print $product["name"]; ?>' />

Likewise, in product.php, look for the following code (line 7):

<img width='180' src='<?php print $mainProduct["image_url"]; ?>' alt='<?php print $mainProduct["name"]; ?>' />

...and change that to read:

<img width='180' src='<?php print $mainProduct["image_url"]; ?>' alt='<?php print $mainProduct["name"]; ?>' title='<?php print $mainProduct["name"]; ?>' />

For the title element of the dynamically generated hyperlinks to the merchant, would "go to Merchant Name" be suitable? For example, again in html/product.php you could change (line 11):

<h3><a href='<?php print tapestry_buyURL($mainProduct); ?>' <?php print javascript_statusBar(translate("go to")." ".$mainProduct["merchant"]); ?>><?php print $mainProduct["name"]; ?></a></h3>

to:

<h3><a title='go to <?php print $mainProduct["merchant"?>' href='<?php print tapestry_buyURL($mainProduct); ?>' <?php print javascript_statusBar(translate("go to")." ".$mainProduct["merchant"]); ?>><?php print $mainProduct["name"]; ?></a></h3>

Is that sort of what you're looking to do?

Hope this helps,
Cheers,
David.

Submitted by dbfcs on Mon, 2006-09-25 12:47

Spot on, thanks!