Hi.
I would like to keep the same template for the whole site;
How can I include some javascript files only in certain documents; let say in document 21, 25 and 30 for example.
thanks
You could do a TV that includes the javascripts.. For examply a checkbox TV that includes the scripts if the checkbox is checked, or just text field where you can write the javascript include. Or you could do a snippet what checks for document id and includes the scripts if needed..
for example:
$includeIds = (isset($includeIds)) ? explode(",",$includeIds) : array();
$docId = $modx->documentIdentifier;
if (array_search($docId, $includeIds)) {
$strJavascript = "assets/js/prototype.js";
// or
$strJavascript = "<script type='text/javascript'>alert('some javascript');</script>";
// or
$strJavascript = $modx->getChunk("chunkname");
$modx->regClientStartupScript($strJavascript);
}
return;
That snippet would take the document ids like [[includeJsSnippet? &includeIds=`21,25,30`]]
"He can have a lollipop any time he wants to. That's what it means to be a programmer."
yes, base_url is needed if you enable friendly alias paths
"He can have a lollipop any time he wants to. That's what it means to be a programmer."
-
☆ A M B ☆
- 24,524 Posts
So what’s the difference between base_url and site_url?
if I have modx installed in a subfolder in my siteroot called "modx", base_url is "/modx/" site_url is "www.mydomain.com/modx/"
"He can have a lollipop any time he wants to. That's what it means to be a programmer."