I made such a record for field name: picture_url:
switch ($fieldName)
{
case 'picture_url':
if (0 === count($column_header))
{
$column_header = $fieldName;
}
if (strpos($content, ','))
{
$images = explode(',', $content);
$xml = '';
$nr = 1;
$xml .= '<photos>';
foreach ($images as $image)
{
$this->contents = $image;
if ($nr === 1)
{
$xml .= '<photo nr="'.$nr.'">';
$xml .= $this->Element('filename', $cdata);
$xml .= '<main>1</main>';
$xml .= '</photo>';
$nr++;
}
else
{
$xml .= '<photo nr="'.$nr++.'">';
$xml .= $this->Element('filename', $cdata);
$xml .= '<main>0</main>';
$xml .= '</photo>';
}
}
}
$xml .= '</photos>';
return $xml;
break;
}
The loop returns this result like this:
[color=blue]<photos>
<photo nr="1"><filename><![CDATA[/images/virtuemart/product/1.jpg]]></filename><main>1</main></photo>
<photo nr="2"><filename><![CDATA[/images/virtuemart/product/2.jpg]]></filename><main>0</main></photo>
<photo nr="3"><filename><![CDATA[//images/virtuemart/product/3.jpg]]></filename><main>0</main></photo>
</photos>[/color]
How to make "file_description" in the "picture_url" loop with such a result?
[color=blue]<photos>
<photo nr="1"><filename><![CDATA[/images/virtuemart/product/1.jpg]]></filename><main>1</main><file_description>desc1</file_description></photo>
<photo nr="2"><filename><![CDATA[/images/virtuemart/product/2.jpg]]></filename><main>0</main><file_description>desc2</file_description></photo>
<photo nr="3"><filename><![CDATA[//images/virtuemart/product/3.jpg]]></filename><main>0</main><file_description>desc3</file_description></photo>
</photos>[/color]