/libraries/ajax.gateway.php
153change:
$caption = $filename;to$caption = ((strpos("img_")==-1)?"":$filename);/libraries/ajax.gateway.phpfile I made some modifications. I wanted to take the var
$filenameand check that against an xml file for the same value (ie: img_32.jpg). A tag in the xml, look below for example, lists the filename and a caption. If the filename tag matches the $filename, then take the value of the caption tag and store it into a new var
$title. If the
$filenamedoesn't find an exact match, then return with a
$title='no title'; Now of course this has to loop for each node in the xml (and this is where my problem is), My only problem right now is with the conditional statement inside the for loop. I have it set at a value of 2 because in the xml, there are two entries. However, when the page loads it loads the value of the second entry. If I change the value to 1, then it loads the first entry.
foreach ($thumbs as $key => $filename) {
$img = $filename;
/*//added code to replace img filename with a caption loaded from xml*/
include 'example.php';
$xml = new SimpleXMLElement($xmlstr);
for ($i = 0; $i < 2; $i = $i) {
if ((string) $xml->image[$i]->filename == $filename) {
foreach ($xml->image[$i]->title as $title) {
}
} else {
$title = 'no title';
}
}
$caption = $title;
/*//end of added code*/
/* Victor: there is more code after this, not shown here for space reasons */
<images>
<image>
<filename>img_01.jpg</filename>
<title type="caption">caption for image 1</title>
</image>
<image>
<filename>img_02.jpg</filename>
<title type="caption">caption for image 2</title>
</image>
</images>