Get a list of all sections
This is an open discussion with 5 replies, filed under General.
Search
Maybe nickdunn's cool extension 'Entity diagram' is what you are looking for?
Hi! Thanks for your reply.
I'm not sure about that. That extension exports all sections to a .gv file. I need the list of sections currently available in the system as an XML data source.
@Albertaddu
There is no GUI way to achieve this. You have to build a custom Datasource which queries the sym_sections
table for available sections.
If you haven't created any custom DS before, search the forum, check the docs ... In the end, it's all about 2 methods:
- set this method return value to false
so Symphony won't allow editing from Administration (thus losing your changes):
public function allowEditorToParse(){ return false; }
- put your stuff in grab
method. Query the table, create an XML element and add it to output:
public function grab(&$param_pool=NULL){ $result = new XMLElement('available-sections'); $available_sections = Symphony::Database()->fetch('SELECT * FROM `sym_sections`'); foreach ($available_sections as $section) { $section_xml = new XMLElement('section', '', $section); $result->appendChild($section_xml); } return $result; }
I attached the DS as well. You should check it against a system generated DS to see the differences. You must copy this datasource to workspace/data-sources
to use it.
Well, that was what I was looking for. Thank you! :-)
Another option might be to use nickdunn's Section Schemas extension. It would be a much more verbose solution that the one offered by @vladG, but can be very useful, depending on what you're trying to accomplish, as it allows you to create a data source for each section, with details of the fields used by each section.
For example, here is the XML output for the articles
section of the default Symphony workspace.
<section-schema id="1" handle="articles" total-entries="2" total-fields="5"> <title required="yes" show-column="yes" id="1" label="Title" type="input" sortorder="0" location="main" /> <body required="yes" show-column="no" id="2" label="Body" type="textarea" sortorder="1" location="main"> <formatter>markdown</formatter> <size>20</size> </body> <date required="no" location="sidebar" show-column="yes" id="3" label="Date" type="date" sortorder="2"> <pre-populate>yes</pre-populate> <initial-value>25 August 2011 07:45</initial-value> </date> <categories required="yes" show-column="yes" id="4" label="Categories" type="selectbox_link" sortorder="3" location="sidebar"> <show-association>yes</show-association> <allow-multiple-selection>no</allow-multiple-selection> <options> <optgroup label="Categories"> <option value="1">Symphony</option> <option value="2">Announcement</option> </optgroup> </options> </categories> <publish required="no" location="sidebar" show-column="yes" id="5" label="Publish" type="checkbox" sortorder="4"> <default-state>off</default-state> <description>Publish this article</description> <initial-value>yes</initial-value> </publish> </section-schema>
This can then be used in combination with Form Controls to dynamically recreate front end forms that match the fields used by the section.
Of course, it depends what you are trying to accomplish.
Create an account or sign in to comment.
Hi, everybody.
I'm trying to get the list of all Sections, but I'm not sure if this is even possible. I would like to avoid listing them manually, so: should I create something like an extension?
Thanks for your help. —Alberto