I have created a simple custom verb which allows you to link specified resource files from circuit.xml, without having to go to the bother of writing it all in a script and including it.
For example, you can do this:
And it will convert that and place the following inside your HTML head:
<link rel="stylesheet" type="text/css" href="/res/bubbles.css"/>
This should be useful if you have a lot of different circuits that all have unique styles and scripts, and you'd rather avoid putting lots of conditional statements in your layout pages.
If you haven't used lexicons before, they're actually really simple (once you have it explained to you - thanks to Nick Tong for helping me).
Here is how to setup and use them:
- Create a lexicon directory in your application root (the same place as your circuits directory) - note: it is singular lexicon, NOT lexicons
- Create the folder for the verbs to go in. For example, you could use ht, since it is related to hypertext, although personally I've just plonked it in an existing cf one.
- Put the link.cfm verb file into this directory. So, you could have the following:
- In the relevant circuit.xml, add xmlns:ht="ht/" to the root circuit tag at the top of the document (where the first ht is the prefix, and the ht/ is the sub-directory inside your lexicon folder).
- Use the tag like this:
And that's all there is to it!
Here is a simple example circuit:
<circuit access="public" xmlns:ht="ht/"> <fuseaction name="main"> <ht:link resource="/styles/default.css"/> ... </fuseaction> </circuit>
Download: link.cfm.zip (<1KB)