Xindi CMS

Xindi CMS is a small, lightweight and flexible content management system. It's great for web developers looking for a simple way to make site content editable by their clients.

Open source, free and flexible, Xindi is available in CFML and PHP versions.

Find out more »

About Me

I am a web developer living and working in Exeter, Devon (United Kingdom). I use my blog to document and share the things I learn and I hope fellow developers will find it to be a useful resource.

Read more »

If you are using a jQuery plugin on a single page of your site, to optimise site performance, it's good practise to include the associated JavaScript and CSS files on only that page. In MODX you can use a Snippet to do this. In the following example I am installing the BXSlider plugin.

Firstly download and unzip the plugin files to a location within your MODX assets directory.

Next, in the MODX Manager under the Elements tab on the left navigation, right click Snippets and select New Snippet. Enter "bxslider" as the snippet name and enter the following code as the Snippet Code. You'll need to update the file paths accordingly to point to your files.

In MODX the method regClientCSS will add a link to the CSS file to the <head> of your document. Similarly, regClientHTMLBlock will add an HTML block to your document before the closing </body> tag.

Save the snippet.

You can now install the snippet by editing the desired page and dropping "[[!bxslider]]" into the Content field along with your correctly marked up list (see code comments above) to which the slider will be applied.

That's it!


Tags


Share


Comments

Monday, December 3, 2012 Mark Hamstra

Mark Hamstra If you're on Revo 2.1.5 or up, you can also set up a textarea template variable "header" and "footer", and just put the [ [*header]] and [ [*footer]] tags in the right position in the template.

Then you can also define per-resource specific header/footer things.

You could also (and I use that on my site for gallery javascript/css in my blog articles) use a checkbox template variable.. if it's checked, add the css/js, otherwise don't :)


Tuesday, December 4, 2012 Mark Cyrulik

Mark Cyrulik Is there a reason that you chose to use $modx->regClientHTMLBlock instead of
$modx->regClientStartupScript?


Tuesday, December 4, 2012 Simon Bingham

Simon Bingham $modx->regClientHTMLBlock inserts the code block before the closing BODY tag, whereas $modx->regClientStartupScript inserts it inside the HEAD tag.

To improve site performance it's better to link to external JavaScript files at the bottom of your document so the JavaScript is loaded after the rest of the content.


Add Comment

Your email address will not be displayed on this blog.

The URL of your blog or web site.

2 + 2 =
Host Media ColdFusion Hosting
"I've never made a stupid programming mistake."

No one, ever.