Actions

Difference between revisions of "JDocumentHTML/addHeadLink"

From Joomla! Documentation

(New page: Adds a link tag to the document head. ===Syntax=== void addHeadLink( $href, $relation, $relType, $attribs ) where: {| class="wikitable" !Argument !Data type !Description !Default |- |$hre...)
 
m (Missed & in code sample.)
Line 33: Line 33:
 
To add a link for an RSS feed to the document, you could use:
 
To add a link for an RSS feed to the document, you could use:
 
<source lang="php">
 
<source lang="php">
$doc = JFactory::getDocument();
+
$doc =& JFactory::getDocument();
 
$href = '/joomla/index.php?format=feed&amp;type=rss';  
 
$href = '/joomla/index.php?format=feed&amp;type=rss';  
 
$attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');  
 
$attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');  

Revision as of 05:04, 8 September 2008

Adds a link tag to the document head.

Syntax

void addHeadLink( $href, $relation, $relType, $attribs )

where:

Argument Data type Description Default
$href strng URL of the linked resource.
$relation string Relation
$relType string Relation type. May be 'rel' indicating a forward relation, or 'rev' for a reverse relation. 'rel'
$attribs array Associative array of remaining attributes.

Example

To add a link for an RSS feed to the document, you could use:

$doc =& JFactory::getDocument();
$href = '/joomla/index.php?format=feed&amp;type=rss'; 
$attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); 
$doc->addHeadLink( $href, 'alternate', 'rel', $attribs );

When the document is rendered this will produce the following in the HTML <head> section:

<link href="/joomla/index.php?format=feed&amp;type=rss" rel="alternate" type="application/rss+xml" title="RSS 2.0" />

See also