

<!DOCTYPE html> <html> <head> <meta charset="[(modx_charset)]"> <title>[*pagetitle*]</title> <meta name="robots" content="noindex, nofollow"> </head> <body> [[CloakLinksRedirect]] </body> </html>
$textlink = isset ($textlink) ? $textlink : "Go to the website";
$linkelements = isset ($linkelements) ? $linkelements : "";
$targetlink = isset ($targetlink) ? $targetlink : "_blank";
$landing = isset ($landing) ? $landing : "[*id*]";
$landingurl = ($modx->makeUrl($landing, '', '', 'full'));
$LinkWeb = isset($LinkWeb) ? $LinkWeb : '';
$LinkTv = isset($LinkTv) ? $LinkTv : '';
$ErrorEmptyLink = isset($ErrorEmptyLink) ? $ErrorEmptyLink : "Empty Link";
$urlparam = isset($urlparam) ? $urlparam : "goto";
if($LinkTv == ""){
$url = $LinkWeb;
} else {
$Link = $modx->getTemplateVarOutput(''.$LinkTv.'',$id);
$url = $Link[''.$LinkTv.''];
}
$url = base64_encode($url);
$url = urlencode($url);
$linkurl = "<a $linkelements target=\"$targetlink\" rel=\"nofollow\" href=\"$landingurl&$urlparam=$url\">$textlink</a>";
if($LinkTv == "" && $LinkWeb == ""){
echo $ErrorEmptyLink;
} else {
echo $linkurl;
}[[CloakLinks? &urlparam=`` &landing=`` &LinkTv=`` &textlink=`` &linkelements=`class="" title="" id="" name=""`]]
domain.com/folder/page.html{{affiliatecode}}href="[*affiliateurl*][*affiliatecode*]"
[[CloakLinks? &urlparam=`read` &landing=`10` &LinkTv=`affiliateurl,affiliatecode` &textlink=`Read More` &linkelements=`class="external" title="External Link"`]]
The "CloakLinksRedirect" snippet:Yes, should work in a blank template with your code.
Does the following suffice for the landing page
<meta charset="[(modx_charset)]"> <title>[*pagetitle*]</title> <meta name="robots" content="noindex, nofollow"> [[CloakLinksRedirect]]
Should the "CloakLinksRedirect" snippet be called cached ([[]]) or uncached ([!!]) ?
What are the settings for the landing page, does the page need to be cached, uncached, searchable etc. ?
Sorry, it's a left-over.
The "CloakLinks" snippet:
In the url there is name=\"$NameAttribute\" - this attribute isn't pre-defined in the snippet, is it a left-over ?
Thank you - Good suggestion - added in 1.0.1
I have slightly modified the copy I have:
$textlink = isset ($textlink) ? $textlink : "Go to the website"; $linkelements = isset ($linkelements) ? $linkelements : ""; $targetlink = isset ($targetlink) ? $targetlink : "_blank"; $landing = isset ($landing) ? $landing : "[*id*]"; $landingurl = ($modx->makeUrl($landing, '', '', 'full')); $LinkWeb = isset($LinkWeb) ? $LinkWeb : ''; $LinkTv = isset($LinkTv) ? $LinkTv : ''; $ErrorEmptyLink = isset($ErrorEmptyLink) ? $ErrorEmptyLink : "Empty Link"; $urlparam = isset($urlparam) ? $urlparam : "goto"; if($LinkTv == ""){ $url = $LinkWeb; } else { $Link = $modx->getTemplateVarOutput(''.$LinkTv.'',$id); $url = $Link[''.$LinkTv.'']; } $url = base64_encode($url); $url = urlencode($url); $linkurl = "<a $linkelements="" target="\"$targetlink\"" rel="\"nofollow\"" href="\"$landingurl&$urlparam=$url\"">$textlink</a>"; if($LinkTv == "" && $LinkWeb == ""){ echo $ErrorEmptyLink; } else { echo $linkurl; }
You can see from my copy that I have added the "linkelements" parameter, this allows the addition of extras like class, title etc. to be added directly in the call e.g.
[[CloakLinks? &urlparam=`` &landing=`` &LinkTv=`` &textlink=`` &linkelements=`class="" title="" id="" name=""`]]
My Problem:
I have various affiliate links in my site from a variety of different websites, so I use the main affiliate link plus a chunk with my personal affiliate link code per website e.g:
domain.com/folder/page.html{{affiliatecode}}
The chunk is called via a TV and then built together in the page, my call in the page looks like this:
href="[*affiliateurl*][*affiliatecode*]"
If I try to call this via CloakLinks the page crashes:
[[CloakLinks? &urlparam=`read` &landing=`10` &LinkTv=`affiliateurl,affiliatecode` &textlink=`Read More` &linkelements=`class="external" title="External Link"`]]
I am not a programmer and have no idea where I should / would have to start to get this sorted, so any help is much appreciated.

<!DOCTYPE html> <html> <head> <meta charset="[(modx_charset)]"> <title>[*pagetitle*]</title> <meta name="robots" content="noindex, nofollow"> </head> <body> [!CloakLinksRedirect? &urlparam=`[*alias*]`!] </body> </html>
[[CloakLinks? &urlparam=`test1` &landing=`10` &LinkTv=``]] [[CloakLinks? &urlparam=`test2` &landing=`11` &LinkTv=``]] [[CloakLinks? &urlparam=`test3` &landing=`12` &LinkTv=``]]
$textlink = isset ($textlink) ? $textlink : "Go to the website";
$linkelements = isset ($linkelements) ? $linkelements : "";
$dummyparams = isset ($dummyparams) ? $dummyparams : "";
$targetlink = isset ($targetlink) ? $targetlink : "_blank";
$landing = isset ($landing) ? $landing : "[*id*]";
$landingurl = ($modx->makeUrl($landing, '', '', 'full'));
$LinkWeb = isset($LinkWeb) ? $LinkWeb : '';
$LinkTv = isset($LinkTv) ? $LinkTv : '';
$ErrorEmptyLink = isset($ErrorEmptyLink) ? $ErrorEmptyLink : "Empty Link";
$urlparam = isset($urlparam) ? $urlparam : "goto";
if($LinkTv == ""){
$url = $LinkWeb;
} else {
$Link = $modx->getTemplateVarOutput(''.$LinkTv.'',$id);
$url = $Link[''.$LinkTv.''];
}
$url = base64_encode($url);
$url = urlencode($url);
$linkurl = "<a $linkelements target=\"$targetlink\" rel=\"nofollow\" href=\"$landingurl$dummyparams&$urlparam=$url\">$textlink</a>";
if($LinkTv == "" && $LinkWeb == ""){
echo $ErrorEmptyLink;
} else {
echo $linkurl;
}[[CloakLinks? &urlparam=`` &dummyparams=`&pid=[*id*]&alias=[*alias*]` &landing=`` &LinkTv=`` &textlink=`` &linkelements=`class="" title="" id="" name=""`]]
// CloakLinks 1.0.2
// author: by Nicola Lambathakis
// credits: http://ctrtard.com/affiliate-marketing/better-affiliate-link-cloaking-for-seo/
//
// method 1: using a template variable [!CloakLinks? &landing=`49` &textlink=`site preview` &LinkTv=`AffiliateLink`!]
// method 1 + custom url parameter [!CloakLinks? &landing=`49` &urlparam=`visit` &textlink=`site preview` &LinkTv=`AffiliateLink`!]
// method 2 [!CloakLinks? &landing=`49` &textlink=`site preview` &LinkWeb=`http://modx.com/`!]
//
// Parameters:
// &textlink = text placeholder | default value: "Go to the website"
// &targetlink = href target attribute | default value: "_blank"
// &landing = resource id of the landing page for redirect (must contain a [[CloakLinksRedirect]] snippet call)
// &LinkTv = (method 1) name of the Text template variable containing the affiliate link
// &LinkWeb = (method 2) full affiliate link
// &AffiliateSuffix = link suffix for affiliate code (ie: 123456789 or [*affiliatecodetv*])
// &urlparam = custom parameter url | default value: "goto"
// &linkelements = allows the addition of extras like class, title (credits: iusemodx)
// &dummyparams = "Dummy" parameters (credits: iusemodx)
// &ErrorEmptyLink = text placeholder for empty tv and/or missing linkweb parameter | default value: "Empty Link"
$textlink = isset ($textlink) ? $textlink : "Go to the website";
$linkelements = isset ($linkelements) ? $linkelements : "";
$dummyparams = isset ($dummyparams) ? $dummyparams : "";
$targetlink = isset ($targetlink) ? $targetlink : "_blank";
$landing = isset ($landing) ? $landing : "[*id*]";
$landingurl = ($modx->makeUrl($landing, '', '', 'full'));
$LinkWeb = isset($LinkWeb) ? $LinkWeb : '';
$LinkTv = isset($LinkTv) ? $LinkTv : '';
$AffiliateSuffix = isset($AffiliateSuffix) ? $AffiliateSuffix : '';
$ErrorEmptyLink = isset($ErrorEmptyLink) ? $ErrorEmptyLink : "Empty Link";
$urlparam = isset($urlparam) ? $urlparam : "goto";
if($LinkTv == ""){
$url = $LinkWeb.$AffiliateSuffix;
} else {
$Link = $modx->getTemplateVarOutput(''.$LinkTv.'',$id);
$url = $Link[''.$LinkTv.''].$AffiliateSuffix;
}
$url = base64_encode($url);
$url = urlencode($url);
$linkurl = "<a $linkelements target=\"$targetlink\" rel=\"nofollow\" href=\"$landingurl$dummyparams&$urlparam=$url\">$textlink</a>";
if($LinkTv == "" && $LinkWeb == ""){
echo $ErrorEmptyLink;
} else {
echo $linkurl;
}
[[CloakLinks? &landing=`148` &dummyparams=`&pid=[*id*]&alias=[*alias*]` &textlink=`link to github` &AffiliateSuffix=`/Nicola1971` &LinkWeb=`https://github.com`]]
[ed. note: banzai last edited this post 11 years, 9 months ago.]
[[CloakLinks? &urlparam=`view` &landing=`10` &LinkTv=`affiliate-url` &AffiliateSuffix=`[*affiliate-suffix*]` &linkelements=`class="external"` &textlink=`View Item`]]
&goto=aHR0cDovL3RoZW1lZm9yZXN0Lm5ldC9pdGVtL2NvbG9ycy1tb2R4LWNyZWF0aXZlLXRoZW1lLzcyNDY4OTU%2FdGVzdDEyMw%3D%3D
&goto=aHR0cDovL3RoZW1lZm9yZXN0Lm5ldC9pdGVtL2NvbG9ycy1tb2R4LWNyZWF0aXZlLXRoZW1lLzcyNDY4OTU/dGVzdDEyMw==