Skip to content

Commit

Permalink
Added Section Information to Output XML
Browse files Browse the repository at this point in the history
  • Loading branch information
brendo committed Feb 2, 2010
1 parent ec523bf commit da6bd41
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions fields/field.selectbox_link.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,36 @@ public function appendFormattedElement(&$wrapper, $data, $encode=false){

if(!is_array($data['relation_id'])) $data['relation_id'] = array($data['relation_id']);

foreach($data['relation_id'] as $value){
$primary_field = $this->__findPrimaryFieldValueFromRelationID($value);

$item_handle = Lang::createHandle($primary_field['value']);
$item_value = $primary_field['value'];
foreach($data['relation_id'] as $relation_id){
$primary_field = $this->__findPrimaryFieldValueFromRelationID($relation_id);

if($encode) $item_value = General::sanitize($item_value);
$value = $primary_field['value'];
if($encode) $value = General::sanitize($value);

$section = $this->Database->fetchRow(0, sprintf(
"
SELECT
s.name, s.handle
FROM
`tbl_sections` AS s
WHERE
s.id = %d
LIMIT 1
",
$primary_field['parent_section']
));

$item = new XMLElement('item');
$item->setAttribute('id', $relation_id);
$item->setAttribute('handle', Lang::createHandle($primary_field['value']));
$item->setValue($value);

if (isset($section['name']) and isset($section['handle'])) {
$item->setAttribute('section-handle', $section['handle']);
$item->setAttribute('section-name', General::sanitize($section['name']));
}

$list->appendChild(new XMLElement('item', $item_value, array('handle' => $item_handle, 'id' => $value)));
$list->appendChild($item);
}

$wrapper->appendChild($list);
Expand Down

0 comments on commit da6bd41

Please sign in to comment.