Sujet fermé
Note de ce sujet :
  • Moyenne : 0 (0 vote(s))
  • 1
  • 2
  • 3
  • 4
  • 5

[Résolu]Le retour de ma balise qui liste les fichiers d'un dossier
#15

Merci beaucoup, le petit $ a tout changé. Les news fonctionnent correctement Big Grin

Pour les téléchargement :
l'udt :
Code :
[== PHP ==]
/* repertoire du dossier */
$config = cmsms()->getConfig();
$dir = $config['root_path']."/uploads/telechargements/".$params['name'];
$dh  = opendir($dir);

$i=0;
while ( $file = readdir($dh) )
{
  /* enleve les fichiers . et .. */
  if ($file != '.' && $file != '..')
  {
    /* on passe les datas dans un tableau */
    $ListFiles[$i]=$file;
    $i++;
   }
}
closedir($dh);

/* tri par ordre decroissant */
if(count($ListFiles)!=0)
{
  if($list_tri == 'DESC')
  {
    rsort($ListFiles);
   }
   else
   {
     sort($ListFiles);
    }
}

if(count($ListFiles)!=0)
{

echo '<ul style="line-height:0px;">';

/* on affiche chaque element */
foreach($ListFiles as $elem)
{

if (preg_match("#.pdf$#", $elem)) {
    $icon="Pdf.png";
} elseif (preg_match("#.xlsx$#", $elem)) {
    $icon="Excel.png";
} elseif (preg_match("#.xls$#", $elem)) {
    $icon="Excel.png";
} elseif (preg_match("#.docx$#", $elem)) {
    $icon="Word.png";  
} elseif (preg_match("#.doc$#", $elem)) {
    $icon="Word.png";  
} elseif (preg_match("#.pptx$#", $elem)) {
    $icon="PowerPoint.png";  
} elseif (preg_match("#.ppt$#", $elem)) {
    $icon="PowerPoint.png";  
} elseif (preg_match("#.ppsx$#", $elem)) {
    $icon="PowerPoint.png";  
} elseif (preg_match("#.pps$#", $elem)) {
    $icon="PowerPoint.png";  
} elseif (preg_match("#.zip$#", $elem)) {
    $icon="Zip.png";
}else {
    $icon="inconnu.png";
}

echo '<div align="center" style="text-align:left; margin-left:50px;"><li style="list-style-type:none;"><a href="/uploads/telechargements/'.$params['name'].'/'.$elem.'"><img src="uploads/telechargements/icones/'.$icon.'" title="'.$elem.'"></a>
<a href="/uploads/telechargements/'.$params['name'].'/'.$elem.'" title="'.pathinfo($elem,PATHINFO_FILENAME).'">'.pathinfo($elem,PATHINFO_FILENAME).'</a></li><br/></div>';

} //Fin du foreach

} //Fin du if

Pour les fichiers j'utiliserai un css par la suite

Mon gabarit :
Code :
[== Indéfini ==]
{* Affiche les fichiers a telecharger *}
{page_attr key="extra3" assign="ex3"}
{capture assign='fichier'}
{telechargements name= $ex3}
{/capture}
{if $ex3 != "" && $ex2 !=""}
{*if (file_exists($fichier))*}
{if (file_exists($smarty.capture.fichier))}
<div align="center" style="background-image: url(./uploads/telechargements/icones/download.png); background-position: 15px -10px; background-repeat: no-repeat; font-size: smaller; width:270px ; margin-left: 0px; padding:2px ; border-left:1px; border-right:1px; border-bottom:1px; border-top:1px; height:72px; margin-top:-78px;">
{$fichier}
</div>
{/if}
{else}
{*if (file_exists($fichier))*}
{if (file_exists($smarty.capture.fichier))}
<div align="center" style="background-image: url(./uploads/telechargements/icones/download.png); background-position: 15px -10px; background-repeat: no-repeat; font-size: smaller; width:270px ; margin-left: 160px; padding:2px ; border-left:1px; border-right:1px; border-bottom:1px; border-top:1px; height:72px; margin-top:-10px;">
{$fichier}
</div>
{/if}
{/if}
{*Fin telechargement*}

Cool
Sujet fermé


Messages dans ce sujet

Atteindre :


Utilisateur(s) parcourant ce sujet : 1 visiteur(s)