Ciao a tutti!
Sto usando la galleria jcarousel di jquery.
Nella sua versione base si mostrano la/le foto in una riga tramite una funzione:
codice:
function mycarousel_itemAddCallback(carousel, first, last, xml) {
// Set the size of the carousel
carousel.size(parseInt(jQuery('total', xml).text()));
jQuery('image', xml).each(function(i) {
carousel.add(first + i, mycarousel_getItemHTML(jQuery(this).text()));
});
};
questa richiama la funzione
codice:
function mycarousel_getItemHTML(url) {
return '<p align="center" style="margin-top:4px;margin-bottom:2px;">[img]' + url + '[/img]</p>'; };
il campo image viene valorizzato tramite la chiamata ad una pagina php e in particolare dal seguente codice (dove l'array $images[] contiene gli url delle immagini da mostrare):
codice:
$total = count($images);
$selected = array_slice($images, $first, $length);
// --- header('Content-Type: text/xml');
echo '<data>';
// Return total number of images so the callback
// can set the size of the carousel.
echo ' <total>' . $total . '</total>';
foreach ($selected as $img) {
echo ' <image>' . $img . '</image>';
}
echo '</data>';
Fin qui tutto ok.
Il mio problema sorge quando voglio stampare per ogni slide del carousel (immagine,name,cognome,anni,etc...)
Ho modificato le funzioni come segue ma non ho ottenuto il risultato sperato.
codice:
function mycarousel_itemAddCallback(carousel, first, last, xml) {
// Set the size of the carousel
carousel.size(parseInt(jQuery('total', xml).text()));
jQuery('image', xml).each(function(i) {
carousel.add(first + i, mycarousel_getItemHTML(jQuery(this).text(),jQuery('name', xml).text(),jQuery('surname', xml).text(),jQuery('age', xml).text(),jQuery('city', xml).text())); }); };
codice:
function mycarousel_getItemHTML(url,name,surname,age,city) {
return '<div>\n\ <div style="float:left;">[img]' + url + '[/img]</div>\n\ <div style="float:right;margin-right:100px;margin-top:70px;font-size:20px;color:black;">'+name+' '+surname+', '+age+'
'+city+'</div>\n\ </div>\n\ <div><video id="player_a" width="492" height="297" style="border: 2px solid #808080;background-color:black;" controls></video>\n\ <source src="" type="video/ogg" /></video>\n\ <source src="" type="video/mp4" /></video>\n\ <source src="" type="video/webm" /></p>\n\ </div>'; };
stavolta ho piu' array contenenti le informazioni da stampare.
in ogni pagina voglio stampare un'informazione per ogni array che corrispondono allo stesso utente
codice:
$total = count($images);
$imageselected = array_slice($images, $first, $length);
$nameselected = array_slice($name, $first, $length);
$surnameselected = array_slice($surname, $first, $length);
$ageselected = array_slice($age, $first, $length);
$cityselected = array_slice($city, $first, $length);
// --- header('Content-Type: text/xml'); echo '<data>';
// Return total number of images so the callback
// can set the size of the carousel.
echo ' <total>' . $total . '</total>';
for($i=0;$i<count($imageselected);$i++) {
echo ' <image>' . $imageselected[$i] . '</image>';
echo ' <name>' . $nameselected[$i] . '</name>';
echo ' <surname>' . $surnameselected[$i] . '</surname>';
echo ' <age>' . $ageselected[$i] . '</age>';
echo ' <city>' . $cityselected[$i] . '</city>'; } echo '</data>';
Finche' stampo delle stringe passandole dalla mycarousel_itemAddCallback alla mycarousel_getItemHTML non ho nessun problema.
Quando ivece devo prelevare i campi di name,surname,age,city dalla pagina php per passarli a mycarousel_itemAddCallback che le passa a mycarousel_getItemHTML il tutto non funziona piu'.
Spero di essermi spiegato.
Grazie!