Page 1 of 1

creation d'un tag petit pb ...

Posted: Sat Sep 22, 2007 9:24 am
by niconico
Bonjour
voila j'ai recuperer un tag d'image aléatoire sur http://dev.cmsmadesimple.org/ et je n'arrive pas à le lancer c'est un tirage aléatoire d'une image je l'installe bien il n'y a pas de pb mais apres quand je l'appelle genre {random_image} avec ou sans les parametres il fait rien et si je cree un tag bidon genre echo'toto' et que je l'appelle bibi et que dans ma page je met {bibi} pas de probleme il affiche toto,
le chemin est defini dans le tag proposé alors je sais plus quoi faire, les parametres n'ont pas l'air obligatoire et meme si je les mets ca change rien
le nom du tag c'est Random Image Selector

merci de me donner une solution

++ nico

Re: creation d'un tag petit pb ...

Posted: Sat Sep 22, 2007 9:53 am
by Pierre M.
Bonjour,

sur http://dev.cmsmadesimple.org/projects/randomimage je vois :
Usage: {random_image dir="something"}

quelques pistes :
-vous mettez bien ceci dans un gabarit, n'est-ce pas ?
-vous remplacez something par /un/certain/chemin/vers/un/dossier ? avec ou sans le "/" initial ? chemin absolu ou relatif à CMSms ? ça en fait des combinaisons, si vous lisez le PHP, regardez le code.
-tout le chemin pointé a bien les droits d'accès pour le serveur web, genre 755 ?
-comment avez-vous installé ce tag ?

Pierre M.

Re: creation d'un tag petit pb ...

Posted: Sat Sep 22, 2007 9:56 am
by niconico
J'utilise bien la bonne syntaxe pas de souci au niveau des permissions pas de probleme chmod777 sur le chemin a parcourir jusqu'au image.
j'ai fait un simple copier coller du fichier php fourni en faisant ajouter un tag utilisateur, j'ai enlever les balises php de début et fin.
voila
++

Re: creation d'un tag petit pb ...

Posted: Sat Sep 22, 2007 10:00 am
by niconico
j'oubliais j'ai un .htacces dans le fichier images
AuthType Basic
AuthName "images"
AuthUserFile "/home/nours/.htpasswds/public_html/guerigny/uploads/images/passwd"

ca vient peut etre de ca ??

Re: creation d'un tag petit pb ...

Posted: Sat Sep 22, 2007 11:40 am
by Pierre M.
Ne suffit-il pas d'enlever cette protection le temps d'un test pour voir si c'est la source du problème ?

Sinon, où est documentée la "bonne syntaxe" ?

Pierre M.

Re: creation d'un tag petit pb ...

Posted: Sat Sep 22, 2007 2:19 pm
by niconico
Oui je suis bien dans un gabarit et la syntaxe est celle-ci {random_image dir="uploads/images/"}, meme le fichier htaccess enlevé n'y change rien...

Re: creation d'un tag petit pb ...

Posted: Sat Sep 22, 2007 2:26 pm
by niconico
voici le code que j'ai collé dans un un nouveau tag appelle random_image:

#CMS - CMS Made Simple
#(c)2004 by Ted Kulp (wishy@users.sf.net)
#This project's homepage is: http://cmsmadesimple.sf.net
#
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

function smarty_cms_function_random_image($params, &$smarty) {
if(empty($params['dir']))
$dirn = "uploads/images";
else
$dirn = $params['dir'];

$myDir = dir($dirn);
        if( ! $myDir )
        {
          return "";
        }
        $count=1;
        while( $name = $myDir->read() ) {
  ++$count;
        }
        $myDir->close();

        $myDir = dir($dirn);
        rewinddir();
        srand(time());
        $randnum = rand(3,($count-2)+1);

        for($i=0;$iread();
                $myimage = $entryName;
        }

return $dirn . "/" . $myimage;
}

function smarty_cms_help_function_random_image() {
?>
What does this do?
Grabs a random image from the image directory specified
How do I use it?
Just insert the tag into your template/page like: {random_image dir="images/albums"}
What parameters does it take?

(optional)dir - directory containing the images.



Author: Robert Campbell<rob@techcom.dyndns.org>
Version: 1.0

Change History:
None

<?php
}

Re: creation d'un tag petit pb ...

Posted: Sun Sep 23, 2007 1:17 pm
by Pierre M.
Quel est le résultat ? Est-ce "" ou autre chose ?

Pierre M.

Re: creation d'un tag petit pb ...

Posted: Mon Sep 24, 2007 8:17 am
by niconico
il se passe rien...... aucun affichage

Re: creation d'un tag petit pb ...

Posted: Tue Sep 25, 2007 5:50 pm
by Pierre M.
Pierre M. wrote: Quel est le résultat ? Est-ce "" ou autre chose ?
Que voyez-vous dans le source HTML ?

Et ajoutez quelques "echo" mouchards...

Re: creation d'un tag petit pb ...

Posted: Fri Apr 25, 2008 1:37 pm
by athena_pallas
usage :