A total newbie question….
I am developing a Joomla template and in this I want to make provision to load the assets (Images, JavaScript and CSS) from a remote location or locally.
I am using the following code for the same:
<?php
class MyclassName {
function CDNPath(){
return $this->getParam("cdn-path","templates/myTemplate/cdn");
}
}
?>
Now in this I want to call the value for $cdn_path via user-input. I am able to get the path but it is removing the '/' marks. Please see the example below:
The correct path to CDN is http://mydomain.com/cdn
It is suppose to read as:
<link rel="stylesheet" href="/joomla/http://mydomain.com/cdn/css/template.css" type="text/css" media="screen" />
whereas it is reading as:
<link rel="stylesheet" href="/joomla/http:mydomain.comcdn/css/template.css" type="text/css" media="screen" />
The breakup for this joomla is the root directory of joomla and http://mydomain.com/cdn/ is the user input
Two challenges:
-
it is removing all the
'/'characters from the user-input. -
It is adding the Joomla Root
'joomla'to the begining of the path.
Am I coding wrong? If yes then what is the correct syntax.
Please feel free to suggest any new approach if you feel will be better than this.
Kindly help.
If you are getting the input via post (im not sure how you are taking input from user. )
so you can try something like this to add slashes :
if its array..