Plugin Link/Path/URL Function linkToItemAnchor()

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

Summary

Generates attributes for a hyperlink to a Content Item.

Where You Can Use It

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

Description

An alternate version of the linkToItem() function, this provides you with a link suitable for placing in a Merge Field for a Theme Template.

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

The HTML attributes needed for the link.

Example

$this->mergeFields['Homepage_Anchor'] =
    $this->linkToItemAnchor($this->core->getLanguageHomepageAlias());
<a [cms:merge name='Homepage_Anchor'/]>[cms:phrase code='_HOME'/]</a>

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