Comment ajouter image 2, 3, 4, ect.. sur flux rss xml ?
Bonjour,
Je suis nouveau sur le site et espère trouver quelques réponses à mes recherches..
Alors j'ai script d'annonce entièrement remodelé à ma sauce, soit simple et pas beau (lien par MP)..
Je souhaite y apporter encore des modifications mais je suis limité en codage..
Bref, je souhaite ajouter à mon flux les différentes photos de chaque annonce quand il y en a.
Ficher de flux php joint sinon pas eccepté dans le tuto, la partie image si image elle s'affiche sinon affiche pas d'image :
Code:
<g:image_link><?php if ($postImage!="" && RSS_IMAGES) echo "$postImage"; else echo "".SITE_URL."/images/no_pic.png"; ?></g:image_link>
Je cherche à faire : si plus qu'une image, afficher image 2, 3,..
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
| <?php
require_once('../includes/functions.php');
if (file_exists(SITE_ROOT.'/themes/'.THEME.'/feed-rss.php')){//feed-rss from the theme!
require_once(SITE_ROOT.'/themes/'.THEME.'/feed-rss.php');
}
else{//not found in theme
header("Content-type: text/xml; charset=utf-8");
?>
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">
<channel>
<title>RSS - <?php echo $html_title;?></title>
<description>RSS - <?php echo $html_description." ".$currentCategory;?></description>
<link><?php echo SITE_URL;?>/</link>
<pubDate><?php echo date(DATE_RFC822);?></pubDate>
<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="<?php echo SITE_URL;?>/rss/" type="application/rss+xml" />
<?php
if ($resultRSS){
foreach ( $resultRSS as $row ){
$idPost=$row['idPost'];
$postType=$row['type'];
$postTypeName=getTypeName($postType);
$postTitle=html_entity_decode($row['title'],ENT_COMPAT,CHARSET);
$postPrice=$row['price'];
/*$postPlace=$row['place'];*/
$postPhone=$row['phone'];
$postPlace= str_replace (" "," ",strip_tags(html_entity_decode($row['place'],ENT_COMPAT,CHARSET)));
if (LOCATION) $postLocation = getLocationName($row['idLocation']);
else $postLocation='';
$postDesc= $row['description'];
/*$postDesc= str_replace (" "," ",strip_tags(html_entity_decode($row['description'],ENT_COMPAT,CHARSET)));*/
$category=$row['category'];//real category name
$fcategory=$row['friendlyName'];//frienfly name category
$idCategoryParent=$row['idCategoryParent'];
$fCategoryParent=$row['parent'];
$insertDate=date(DATE_RFC822,strtotime($row['insertDate']));
if ($row["hasImages"]==1){
$postImage=getPostImages($idPost,setdate($row['insertDate']),true,true);
$expire_date = date('Y-m-d', strtotime("+30 days"));
$postImage= str_replace ("thumb_","",$postImage);
}
else $postImage="";//there's no image
$categoryUrl=$fcategory;
$postUrl=itemURL($idPost,$fcategory,$postTypeName,$postTitle,$fCategoryParent,$postPrice);
?>
<?php if ($postPrice > 0){?>
<item>
<title><![CDATA[<?php echo $postTitle;?><?php if ($postLocation!='' && LOCATION) echo ' - '.$postLocation;?>]]></title>
<link><?php echo SITE_URL.$postUrl;?></link>
<description><![CDATA[
<?php echo $postDesc;?>
<br /><br />
<hr> ]]>
</description>
<g:image_link><?php if ($postImage!="" && RSS_IMAGES) echo "$postImage"; else echo "".SITE_URL."/images/no_pic.png"; ?></g:image_link>
<g:google_product_category>Maison et jardin</g:google_product_category>
<g:condition>occasion</g:condition>
<g:shipping>
<g:country>FR</g:country>
<g:service>Standard</g:service>
<g:price>0</g:price>
</g:shipping>
<g:brand><?php echo $html_title;?></g:brand>
<g:mpn><?php echo $fcategory;?>-<?php echo $idPost;?></g:mpn>
<g:id><?php echo $idPost;?></g:id>
<g:availability>en stock</g:availability>
<g:price><?php if ($postPrice!=0) echo getPrice($postPrice);?>
<?php /*
$pourcent = 20;
$number = ($row['price'] *= (1 + $pourcent / 100));
$prix = number_format((float)$number, 2, '.', '');
echo $prix;
*/ ?>
</g:price>
<g:phone><?php echo $postPhone;?></g:phone>
<g:product_type>Maison et jardin</g:product_type>
</item>
<?php }?>
<?php
}
}
$ocdb->closeDB();
?>
</channel>
</rss>
<?php
}//if else
?> |
Si vous avez besoin de autres pages n'hésitez pas.
Merci d'avance.
Plutôt un souci de boucle...
Bonjour,
Mon problème avance.. en regardant sur le forum c'est un soucis de boucle il me semble..
En cherchant dans plusieurs pages j'ai trouvé ces codes, je tente maintenant de faire quelque chose qui marche..
Mon image s'affiche correctement sur ma page rss ici :
Code:
<g:image_link><?php if ($postImage!="" && RSS_IMAGES) echo "$postImage"; else echo "".SITE_URL."/images/no_pic.png"; ?></g:image_link>
Liée à ce code dans ma page rss :
Code:
1 2 3 4
| if ($row["hasImages"]==1){
$postImage=getPostImages($idPost,setdate($row['insertDate']),true,true);
}
else $postImage="";//there's no image |
Je me demande s'il est possible de s'inspirer des codes sur la page edit produit :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| <?php if (MAX_IMG_NUM>0){
echo "<input type='hidden' name='MAX_FILE_SIZE' value='".MAX_IMG_SIZE."' />";
?>
<?php
$images=getPostImages($post_id,$insertDate);
foreach($images as $img){
echo '<a href="'.$img[0].'" title="'.$itemTitle.' '.T_("Picture").'" target="_blank">
<img class="thumb" src="'.$img[1].'" title="'.$itemTitle.' '.T_("Picture").'" alt="'.$itemTitle.' '.T_("Picture").'" /></a>';
}
echo "<br /><b>".T_("These images will be permanently removed if you upload new ones")."</b><br /><br />";
for ($i=1;$i<=MAX_IMG_NUM;$i++){?>
<label><?php _e("Picture");?> <?php echo $i?>:</label> <input class="middle" type="file" name="pic<?php echo $i?>" id="pic<?php echo $i?>" value="<?php echo $_POST["pic".$i];?>" /><br /><br />
<?php }?> |
ou de la page fiche produit :
Code:
1 2 3 4 5 6 7 8
| <?php if (MAX_IMG_NUM>0){?>
<div id="pictures">
<?php
foreach($itemImages as $img){
echo '<a href="'.$img[0].'" title="'.T_('Picture').' '.$itemTitle.' <br><div align=center>['.SITE_NAME.']</div>" rel="gb_imageset['.$idItem.']">
<img id="enlarge" class="thumb" src="'.$img[1].'" title="'.T_('Picture').' '.$itemTitle.' ['.SITE_NAME.']" alt="'.T_('Picture').' '.$itemTitle.' ['.SITE_NAME.']" /></a>';
}
?> |
En attendant je continue à chercher..
Merci d'avance de toute aide.