GetSimple Support Forum

Full Version: How to read field from XML config file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I want to create a component for sidebar to list categories, that I've created in i18n Special Pages, and I would like to read it from one location, because number of categories can change in future so I want to maintain it in one place. Is it possible to read this information with some function already present in GS ? In XML, it's like this:

Code:
<item>
      <name><![CDATA[main_cat]]></name>
      <label><![CDATA[Category]]></label>
      <type><![CDATA[dropdown]]></type>
      <option><![CDATA[not set]]></option>
      <option><![CDATA[Model]]></option>
      <option><![CDATA[Engine]]></option>
      <option><![CDATA[Wheels]]></option>
    </item>

Thank you for any suggestions
getXML($file)

make sure your xml has a header
<?xml version="1.0" encoding="UTF-8"?>
eheh, that was easy Blush

if somebody would be interested in future, here's an example:
(hardware is special page type, item[3] is the field with category custom field)

PHP Code:
$file getXml(GSDATAOTHERPATH."/i18n_special_hardware.xml");
foreach(
$file->fields->item[3]->option as $option) {
    echo 
$option;

you can also use xpath for this