Plugin Link/Path/URL Function linkToItemAnchorAndJS()

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

Summary

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.

Description

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.

Parameters

$cID

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

$cType

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

$fullPath

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

$request

A string of URL requests, in the format:

request1=value&request2=value...

$alias

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.

$autoAddImportantRequests

(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.

$useAliasInAdminMode

(From 6.0.5)

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

$httpHost

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.

Example

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

...or...

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

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