linkToItemJS()
public final function linkToItemJS($cID, $cType = 'html', $request = '')
Generates JavaScript code that will redirect the viewer to a different Content Item.
Can be used in methods called by plugins. From Zenario 7.0.0 onwards.
This function will return the JavaScript code to a call to the goToItem()
JavaScript function.
While you may wish to write this manually, the inputs needed are the same as the linkToItemAnchor()
utility function. If you're adding links to a Theme then it is recommended that you call both functions and put the results into two different Merge Fields, so that Theme creators have a choice of which they use.
$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.
$request
A string of URL requests, in the format:
request1=value&request2=value...
The JavaScript code needed.
$this->mergeFields['Homepage_JS'] = $this->linkToItemJS($this->core->getLanguageHomepageAlias());
<input type="button" onclick="<!--Homepage_JS-->" value="<!--_HOME-->/>
This example illustrates how to direct a visitor to the home page when they click on a button.