Functions:fullyQualifyAllURLs
From Whirlwind eCommerce Wiki
Revision as of 03:06, 25 February 2009 by 71.163.185.8 (Talk) (New page: == Description == eV::fullyQualifyAllURLs($domain,$copy) returns a string where all non-fully qualified URLs are prepended with the value $domain. This is useful for pages that will be pre...)
Description
eV::fullyQualifyAllURLs($domain,$copy) returns a string where all non-fully qualified URLs are prepended with the value $domain. This is useful for pages that will be presented outside of the domain of the website (emailed, used for API data, etc).
Syntax
$string = eV::fullyQualifyAllURLs($domain,$copy);
Paramaters
- $domain STRING REQUIRED
- the domain name to prepend all non-fully qualified URLs. Should include protocol and no trailing slash (http://www.website.com).
- $copy STRING REQUIRED
- the string that will have it's non-fully qualified URL contents prepended.
Return Values
Returns a string identical to the incoming $copy string, except for URLs that where non-fully qualified are no fully qualified with the passed $domain.
Examples
// set data to be fixed. $dataString = " This is some text with an <a href=\"page.html\">absolute link</a>, a <a href=\"http://www.google.com\">fully qualified domain name link</a> and a <form action=\"anotherpage.html\" method=\"post\">form</form> "; // convert all non-fully qualified URLs to fully qualified $newDataString = eV::fullyQualifyAllURLs('http://www.website.com',$dataString); // output the resulting string echo $newDataString; /* this string will look like the following: -------------------------- This is some text with an <a href=\"http://www.website.com/page.html\">absolute link</a>, a <a href=\"http://www.google.com\">fully qualified domain name link</a> and a <form action=\"http://www.website.com/anotherpage.html\" method=\"post\">form</form> */