Plugin Link/Path/URL Function linkToItemAnchorAndJS()

public final function linkToItemAnchorAndJS(
$cID, $cType = 'html', $fullPath = false, $request = '', $alias = false, $autoAddImportantRequests = false, $useAliasInAdminMode = false


A shortcut function for calling linkToItemAnchor() and linkToItemJS().

Where You Can Use It

Can be used in methods called by plugins. From Zenario 7.0.0 onwards.


If you are adding links to a Theme Template, it's best to add both an anchor link for <a> elements and an onclick script for buttons, so that Theme creators have a choice of which they use. This shortcut function lets you quickly add both.



The Content id of the Item to link to. If it's a html Content Item you can provide an alias instead.


The Content Type of the Item to link to. Defaults to html.


Whether to use a full URL rather than a relative URL.


A string of URL requests, in the format:



From version 6.0, you can enter the alias of the Content Item if you know it.

If you don't provide this parameter (or in versions of the CMS prior to 6.0) the alias will be automatically looked up.


(From 6.0.5)

If this is a link to the current Content Item, set this to include any requests added using the registerGetRequest() function.

Has no effect if linking to a different Content Item.


(From 6.0.5)

Set this to force use of the alias and friendly URLs in Admin mode.


When generating full URLs, you can set this variable to set the HTTP HOST.

By default, the $_SERVER['HTTP_HOST'] variable or the site's primary domain will be used.

Return Value

An array containing the return values of the linkToItemAnchor() and the linkToItemJS() functions.


list($this->mergeFields['Homepage_Anchor'], $this->mergeFields['Homepage_JS']) =
<a <!--Homepage_Anchor-->><!--_HOME--></a>


<input type="button" onclick="<!--Homepage_JS-->" value="<!--_HOME-->/>

This example illustrates how to put a link to the homepage on a theme.