1. piekielko
  2. RO CSVI
  3. Friday, 07 December 2018
  4.  Subscribe via email
In: administrator/components/com_csvi/helper/file/export/xml/mycustom.php

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]
Accepted Answer Pending Moderation
Hello,

How to make "file_description" in the "picture_url" loop with such a result?
That is not going to be easy because CSVI processes the export on a field by field basis. So first the picture_url goes out and gets processed and later the description is being processed. You would need to store the picture_url values in memory until you get to the description and then export them both together.

Alternatively you could combine the picture_url and description on export and then you will have 1 field that contains both with your own separator. When you process that field you will have both and you can add them to your XML. Since it has your own separator you can just separate them based on your own separator.
Kind regards,

RolandD

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 1
  • Page :
  • 1


There are no replies made for this post yet.
Be one of the first to reply to this post!