Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

problème mise en cache + interpretation block

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: French
View previous topic :: View next topic  
Author Message
gtraxx
Smarty Regular


Joined: 08 Jan 2008
Posts: 56

PostPosted: Sun Aug 10, 2008 12:23 am    Post subject: problème mise en cache + interpretation block Reply with quote

Bonjour tous le monde, j'ai un petit souçi avec la mise en cache.
J'ai une galerie photo que je charge dynamiquement depuis une base de donnée.
j'ai donc créer une fonction smarty pour permettre d'utiliser la balise dynamic qui exclus de la mise en cache certaine partie.
mais en utilisant cette fonction j'ai droit a un "notice" :
Code:
Notice: Undefined index: num in /Applications/MAMP/htdocs/fremor/_scriptroot/galery/frontend/index.php on line 52

Mon php :
Code:
function __construct(){
      $this->smarty = new MySmarty();
      if (isset($_GET['num'])) {
         if ($GET['num']=!null) {
            
            if (is_int($_GET['num'])) {
               
               $this->num = $_GET['num'];
            }
         }
      }
         $this->cache_id = 'galery'.$_GET['num'];
   }
   /**
    * function display society page frontend
    *
    */
   function displayGalery(){
      
      $this->smarty->caching = 2;
      $this->smarty->cache_lifetime = 60 * 5;
      $this->smarty->register_block('dynamic', 'smarty_ClashBlock_Dynamic', false); 
      
      $result = new DbLoadGalery();
      $this->smarty->assign('galery', $result->loadGalery());
      if(!$this->smarty->is_cached('galery/index.tpl',$this->cache_id)){

         $this->smarty->clear_cache('galery/index.tpl');
      }
      $this->smarty->display('galery/index.tpl',$this->cache_id);
   }

Mon template :
Code:
{if $smarty.get.num}
         {dynamic}
             {foreach from=$selcat key=attr item=i}
              <h2 class="Titre2">{$i.categories|upper}</h2>
          <div id="galery">
             {if $galery == !null}
              {foreach from=$galery key=attr item=i}
                 <div class="pictures"><a href="{$_scripRootUrl}galery/{$i.categories}/{$i.pict_name}" title="{$i.pict_desc}" rel="shadowbox">
                    <img src="{$_scripRootUrl}galery/{$i.categories}/{$i.pict_name}" width="150px" height="110px" alt="{$i.pict_name|truncate:20}" /></a>
                    <p>{$i.pict_name|truncate:20}</p></div>
              {/foreach}   
             {else}
                 <img src="{$_scripRootUrl}img/important.png" width="22px" height="22px" />Aucune photos dans la galerie
             {/if}
              <div style="clear:left;"></div>
           </div>
           {/foreach}
           <div id="pagi">
            {foreach from=$categ key=attr item=pagi}
               <a href="{$_scripRootUrl}photos-{$pagi.cat_num}">{$pagi.cat_num}</a>
            {/foreach}
         </div>
      {/dynamic}
      {else}
         {dynamic}
        <div id="paggalery">
           <h2>Visitez nos galeries</h2>
              <div class="pagpict">
                 <a href="{$_scripRootUrl}photos-1"><img src="{$_scripRootUrl}img/vignette1.png" width="150px" height="140px" alt="Illustrations" /></a>
              </div>
              <div class="pagpict">
                 <a href="{$_scripRootUrl}photos-2"><img src="{$_scripRootUrl}img/vignette2.png" width="150px" height="140px" alt="Bande dessinée" /></a>
              </div>
              <div class="pagpict">
                 <a href="{$_scripRootUrl}photos-3"><img src="{$_scripRootUrl}img/vignette3.png" width="150px" height="140px" alt="Photos" /></a>
              </div>
              <div class="pagpict">
                 <a href="{$_scripRootUrl}photos-4"><img src="{$_scripRootUrl}img/vignette4.png" width="150px" height="140px" alt="Esquisses" /></a>
              </div>
              <div style="clear:left;"></div>
        </div>
       {/dynamic}
     {/if}

Alors en prime ma condition concernant la galerie a null ne fonctionne pas, cette partie :
Quote:
<img src="{$_scripRootUrl}img/important.png" width="22px" height="22px" />Aucune photos dans la galerie
n'est jamais afficher.
De temps en temps j'ai aussi un gros warning qui dit que la fonction "dynamic" est indéfinie alors que je l'ai bien dans les plugins smarty.
Je précise que ce n'est pas systématique.
Un bug ???
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: French All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP