layoutManager Mach-II plugin
Usage
Place layoutManager.cfc in the MachII plugins folder. Place this in the plugins section of the Mach-II configuration file (typical usage):
<plugin name="layoutManager" type="MachII.plugins.layoutManager">
<parameters>
<parameter name="defaultLayoutEvent" value="layout.main" />
<parameter name="finalOutputKey" value="request.content.final" />
</parameters>
</plugin>
In the event-handlers section:
<event-handler event="layout.main" access="private">
<view-page name="layout.main" contentKey="request.content.final" />
</event-handler>
This will announce layout.main at the end of the event queue. If you need to use a different layout event (such as for popups where you don’t require the normal site layout) set an event argument named layoutEvent to your chosen alternate layout event name. You can also set an event argument named skipLayoutEvent to true if you wish skip the layout altogether (such as when the output is an XML file or an image).
The final content (contained in request.content.final) will be stripped of all unnecessary whitespace. You can disable this by not setting the finalOutputKey parameter and not specifying a content key for the final layout view.
Plugin parameters
*These parameters have no effect when the finalOutputKey parameter is omitted.
Event arguments used by layoutManager
Note: Use the argumentPrefix parameter to modify the following argument names. This can be helpful to avoid clashes with other event args such as form and url values. For example, if you set argumentPrefix to "LM_" the following argument names will be LM_layoutEvent, LM_contentType, etc).
*These event arguments have no effect when the finalOutputKey parameter is omitted.
Notes
Exceptions
When an exception is thrown and the exception event is announced, layoutManager will still announce the layout event at the end of the queue. If you are using the finalOuputKey method, your exception event has to write content to this content key. If the error was thrown by the layout event, you will get a white screen of death. A possible solution to this would be to add an event mapping in your layout event-handler to redirect all exceptions to an event that disables the layoutManager (using the disableLayoutManager event argument).
CFCONTENT
When using the finalOutputKey method, layoutManager always includes a cfcontent tag just before outputing the content. This means that you shouldn’t use cfcontent elsewhere in your code.
If you have any problems using this plugin don’t hesitate to post comments on this page.
September 18th, 2005 at 12:14 pm
Cool, my XML was stripped out from my config. Can I email it to you?
#9: Mike Kollen Says:September 18th, 2005 at 12:13 pm
Thanks for the plug-in. Do know why this doesn’t work:
-or-
Neither one works.
Thanks,
Mike
#8: Sami Hoda Says:September 7th, 2005 at 10:54 pm
Martin,
Is there a list we can be on to receive notification when new releases of code come out?
Sami
#7: Brad Says:July 6th, 2005 at 2:13 pm
I’m quite new to mach-ii (2 days) and I’m strugging to piece together all the required elements. I’ve gone through Trond Ulseth’s 2 tutorials which were great, but now I’m trying to figure out how to apply this to my current project.
I’m used to using included for headers, footers and menu’s and I’m not sure how to properly handle this using mach-ii. Also, what is the proper way to refer to the CSS, etc.
I’m looking over your layoutManager.cfc and trying to understand if this is what this file is for. There isn’t alot of documentation on plugins and filters (unless you could direct me).
Thanks for contributing to mach-ii. I would say congratulations on winning the Olympic bid, but given your home country, I’m sure you are of two minds.
#6: Daniel Says:June 29th, 2005 at 10:11 am
Nice and very usefull PugIn, thanks for that work.
There is one thing I get confused. As soon as use the plugIn and got an exception, in the exception Message from Mach-II I don’t get the real exception message anymore.
Whatever exceptions occured, I get “Element CONTENT is undefined in REQUEST”, which is the content variable in the mainLayoutpage.
How do I configure the plugIn to show me the the exception messages.?
#5: Martin Says:May 28th, 2005 at 4:02 am
By the way Sami, Phil is not the author of this plugin. I am. Phil runs the MachII.info site and has kindly linked to my blog from his exchange section.
#4: Sami Hoda Says:May 27th, 2005 at 8:00 pm
Oops, caught my mistake. Its fixed now. Thanks.
#3: Sami Hoda Says:May 27th, 2005 at 7:35 pm
Phil, when setting an event (popup) I used the following code:
Where I used skipLayoutEvent. Yet when run, I get the following error:
Exception
Message cannot convert the value “” to a boolean
This references line 38 in the plugin. Any ideas?
#2: Sami Hoda Says:May 18th, 2005 at 4:22 pm
Well done!
#1: Phil Says:October 6th, 2004 at 4:56 pm
Nice plugin. Do you mind if I add a listing for this in the Mach-ii.info Exchange? (http://mach-ii.info/index.cfm?event=exchange)