Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to read field from XML config file
#1
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
Reply
#2
getXML($file)

make sure your xml has a header
<?xml version="1.0" encoding="UTF-8"?>
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#3
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;

Reply
#4
you can also use xpath for this
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply




Users browsing this thread: 1 Guest(s)