[56K WARN] Modifying an XML file to change content layout
Posted: Wed May 16, 2007 9:08 am
Hey,
With my open-source CMS that'll be released late-june this year, I use an XML file which contains/describes the content layout. Here is an example sector_map.xml file:
Each sectorID (S1, S2) refers to a tag in the main template file ( eg, {S1} ) - and then my CMS replaces the tag {S1} with all of the controllers/modules that are set in the above XML file. This all works great and is very customizable when just editing the text-file ... however, I can not just let users of my CMS edit a xml file every time they want to change their content layout!
I've began work on the view for my controller/module that will handle the content layout - here is what it looks like, should give you an idea of what I'm trying to do.

The Placement and Order headings will become drop-down select boxes and the user can then change where a module is and in what order it appears in etc. Attatch new module will allow again for a user to select a Module (via drop-down box) and then select which Sector it's to go in (drop down box) and then hit ok, it would submit the form and edit the XML object, add the new module/controller in and then re-save/write the sector_map.xml file.
Attatching a new module/controller I could probably do, but editing a previous one .... no idea. Say I want to change the placement of the "menu" controller/module that is currently in S1::Topbar, and I want to put it in S2::Right Sidebar, I can't do it by ID's - as there are non, and I can't do it by module/controller name as there could be another controller in there with the same name! It's driving me mad and I probably make no sense at all =(
With my open-source CMS that'll be released late-june this year, I use an XML file which contains/describes the content layout. Here is an example sector_map.xml file:
Code: Select all
<?xml version="1.0" ?>
<sectors>
<sector>
<id>S1</id>
<description>Top Bar</description>
<controllers>
<controller>
<mod>menu</mod>
<con>index</con>
<sec>index</sec>
<config>
<wrap_controller>false</wrap_controller>
<display_title>false</display_title>
<display_category>21</display_category>
</config>
</controller>
</controllers>
</sector>
<sector>
<id>S2</id>
<description>Right Sidebar</description>
<controllers>
<controller>
<mod>session</mod>
<con>index</con>
<sec>index</sec>
<config>
<wrap_controller>true</wrap_controller>
<display_title>true</display_title>
</config>
</controller>
<controller>
<mod>menu</mod>
<con>index</con>
<sec>index</sec>
<config>
<wrap_controller>true</wrap_controller>
<display_title>true</display_title>
<display_category>1</display_category>
</config>
</controller>
</controllers>
</sector>
</sectors>
I've began work on the view for my controller/module that will handle the content layout - here is what it looks like, should give you an idea of what I'm trying to do.

The Placement and Order headings will become drop-down select boxes and the user can then change where a module is and in what order it appears in etc. Attatch new module will allow again for a user to select a Module (via drop-down box) and then select which Sector it's to go in (drop down box) and then hit ok, it would submit the form and edit the XML object, add the new module/controller in and then re-save/write the sector_map.xml file.
Attatching a new module/controller I could probably do, but editing a previous one .... no idea. Say I want to change the placement of the "menu" controller/module that is currently in S1::Topbar, and I want to put it in S2::Right Sidebar, I can't do it by ID's - as there are non, and I can't do it by module/controller name as there could be another controller in there with the same name! It's driving me mad and I probably make no sense at all =(