IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Zend Framework PHP Discussion :

Récupération d'une variable


Sujet :

Zend Framework PHP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre à l'essai
    Inscrit en
    Mai 2010
    Messages
    4
    Détails du profil
    Informations forums :
    Inscription : Mai 2010
    Messages : 4
    Par défaut Récupération d'une variable
    Bonjour je suis nouveau débutant du framework zend et je galére pour résoudre ce probleme, voila mon probléme.

    J'ai crée une pagination avec zend paginator et tous marche bien, sur mon il ya 2 langue anglais et francais, je veux envoyé 2 variable qui contient "previous/next" ou "précedent/suivant" seulon le choix de l'utilisateur et les récupérer dans pagination.phtml que je l'appele avec <?=$this->paginator ?> dans produits.phtml.

    Dans le controller j'initialise les 2 variable

    $this->view->previous = "valeur";
    $this->view->next = "valeur";

    Dans pagination.phtml j'appele avec

    <?=$this->previous ?>

    Mé ca ne m'affiche rien du tout.

    Et merci pour qui peu m'aider

  2. #2
    Membre éprouvé
    Homme Profil pro
    Ingenieur BI - Dev Web Senior
    Inscrit en
    Décembre 2009
    Messages
    118
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Ingenieur BI - Dev Web Senior

    Informations forums :
    Inscription : Décembre 2009
    Messages : 118
    Par défaut
    Bonjour m4r14ch1,

    Normalement les deux attributs : previous et next sont prédéfinis dans le Paginator de Zend!

    Tu peux montrer comment tu créer ou/et tu initialise ton paginator?


    Merci.

  3. #3
    Membre à l'essai
    Inscrit en
    Mai 2010
    Messages
    4
    Détails du profil
    Informations forums :
    Inscription : Mai 2010
    Messages : 4
    Par défaut
    Voila mon controller
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    public function displayAction()
        {
            Zend_View_Helper_PaginationControl::setDefaultViewPartial('product_pages.phtml');
     
            $produits = new Produits();
     
            if (is_numeric($this->_request->getParam('cat_id'))) $cat_id = $this->_request->getParam('cat_id');
            else $cat_id = 0;
     
            $page = $this->_getParam('page',1);
            $itemsPerPage = 3;
     
            $recherche = '';
            if($this->_request->isGet())
            {
     
                $recherche = explode(' ',$this->getRequest()->getParam('wath'));
                $this->view->wath=$this->getRequest()->getParam('wath');
            }
     
            $select = $produits->get_all_products($this->lang_id, $cat_id, $recherche, $page, $itemsPerPage);
            $this->view->produits = $select;
     
            $ar_paginator = range(0, $produits->count_product($this->lang_id, $cat_id, $recherche));
     
            $paginator = Zend_Paginator::factory($ar_paginator);
            $paginator->setCurrentPageNumber($page);
            $paginator->setItemCountPerPage($itemsPerPage);
            $this->view->paginator = $paginator;
     
            $this->view->next = $this->translate->_('next')
            $this->view->previous = $this->translate->_('previous')
    le view qui affiche les produit paginer

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    <? 
                                                } 
                                                else 
                                                {
                                                    foreach ($this->produits as $key => $val)
                                                    {
                                                    if (empty($val['photo']))$photo = SPACE_PHOTO;
                                                    else $photo = $this->photo->make_photo_format($_SERVER['DOCUMENT_ROOT'].'/photos/'.$val['products_id'], $_SERVER['DOCUMENT_ROOT'].'/photos/'.$val['products_id'], $val['photo'], 100, 100, '/photos/'.$val['products_id'].'/');
     
                                                    $title = stripslashes($val['products_name']);
                                                    if (strlen($title) > 50) $title = substr($title, 0, 50);
     
                                                    if ($val['price'] == 0) $price = '';                                            
                                                    else $price = number_format($val['price'], 2).'$';
     
                                                    if ($val['price_promotion'] == 0) $price = '&nbsp;<span class="Price">'.$price.'</span>';
                                                    else $price = '&nbsp;<span class="BlackPrice"><s>'.$price.'</s></span>&nbsp;<span class="Price">'.(number_format($val['price_promotion'], 2)).'$</span>';
     
                                                    $description = stripslashes($val['products_description']);
                                                    if (strlen($description) > 200) $description = substr($description, 0, 200).'...';
     
                                                    if ($val['parentcat_name'] != null) $categorie = $val['parentcat_name'].' : '.$val['cat_name'];
                                                    else $categorie = $val['cat_name'];
     
                                                    if (strlen($categorie) > 40) $categorie = substr($categorie, 0, 40);
                                            ?>
                                            <tr>
                                                <td>
                                                    <img src="/images/pixel_trans.gif" border="0" alt="" width="100%" height="10">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <table border="0" width="100%" cellspacing="0" cellpadding="0" class="productListing">
                                                        <tr class="productListing-even">
                                                            <td align="center" width="100" height="100" class="productListing-data"><? if ($photo != '') { ?><img src="<?=$photo?>"><? } ?></td>
                                                            <td class="productListing-data">
                                                                <table border="0" cellspacing="5" cellpadding="0" height="100" width="100%">
                                                                    <tr height="10">
                                                                        <td colspan="2" class="NameProd"><a href="/product/info/prod_id/<?=$val['products_id']?>"><b><?=$title?></b></a></td>
                                                                        <td class="NameProd" align="right"><nobr><?=$price?></td>
                                                                    </tr>
                                                                    <tr valign="top" height="50">
                                                                        <td colspan="3" class="Date">
                                                                            <div align="justify">
                                                                                <?=$description?>
                                                                            </div>
                                                                        </td>
                                                                    </tr>
                                                                    <tr height="10">
                                                                        <td align="center"  width="10%">
                                                                            <div class="bt_90_20_gc" style="cursor:pointer" onclick="window.location='/product/info/prod_id/<?=$val['products_id']?>/backto/<?=urlencode(urlencode($_SERVER['REQUEST_URI']))?>'">
                                                                                <a href="javascript:void(0)" class="bt_90_20_gc-link"><?=htmlentities($this->translate->_('BUTTON_MORE_INFO'))?></a>
                                                                            </div>
                                                                        </td>
                                                                        <td align="center" class="productListing-data" width="80%">
                                                                            <?=$categorie?>
                                                                        </td>
                                                                        <td align="center" width="10%">
                                                                            <div class="bt_115_20_gc" style="cursor:pointer" onclick="window.location='/shoppingcart/add/prod_id/<?=$val['products_id']?>/backto/<?=urlencode(urlencode($_SERVER['REQUEST_URI']))?>'">
                                                                                <a href="javascript:void(0)" class="bt_115_20_gc-link"><?=htmlentities($this->translate->_('BUTTON_ADD_TO_CART'))?></a>
                                                                            </div>
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                            <?
                                                }
                                            } 
                                            ?>
                                            <tr>
                                                <td height="10px"></td>
                                            </tr>
                                            <tr>
                                                <td align="center">
     
                                                    <?=$this->paginator ?>
                                                </td>
                                            </tr>
    et la bare de pagination

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    <?if ($this->pageCount)
      {      
          $Pagination_Session = new Zend_Session_Namespace('Pagination_Session'); 
    ?>
            <div id="paginationControl">
            <!-- Previous page link --> 
                <?
                    if (isset($this->previous))
                      { ?>
                        <a href="<?=$this->url(array('action'=>'display', 'page' => $this->previous)); ?>">
                            &laquo;<?=$this->previous ?>
                        </a>&nbsp;
                <?                   
                    } 
                ?>
                <!-- Numbered page links -->
                <? 
                    if(count($this->pagesInRange) > 1)
                    {
                        foreach ($this->pagesInRange as $page)
                        {
                            if ($page != $this->current) 
                            {
                ?>                
                            <a href="<?=$this->url(array('action'=>'display', 'page' => $page)) ?>">
                            <?=$page ?>
                            </a>  &nbsp;
                            <?
                            }
                            else 
                            {
                            ?>
                            <span class="pagination">
                            <?=$page?>
                            </span>  &nbsp;
                <?
                            }      
                        }
                     }
                 ?>
                <!-- Next page link --> 
                <?if (isset($this->next))
                  { ?> 
                    <a href="<?=$this->url(array('action'=>'display', 'page' => $this->next)); ?>">
                        <?=$this->next ?>&raquo;
                    </a>
     
                <? }?> 
            </div> 
    <?}?>

  4. #4
    Membre à l'essai
    Inscrit en
    Mai 2010
    Messages
    4
    Détails du profil
    Informations forums :
    Inscription : Mai 2010
    Messages : 4
    Par défaut
    J'ai résolu le problème en envoyons les deux paramètre en
    <?php echo $this->paginationControl($this->paginator, 'Sliding', 'pagination.phtml', array("precedent" => htmlentities($this->translate->_('PREVIOUS')), "suivant" => htmlentities($this->translate->_('NEXT')))); ?>
    et je récupère les valeur avec $this->precedent et $this->suivant.

    ces 2 variable je les utilises seulement pour le texte afficher pour la traduction.
    les 2 variable vont afficher en anglais previous-next ou en francais précèdent-suivant .

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 3
    Dernier message: 29/05/2006, 23h46
  2. [Conception] récupération d'une variable php dans une autre page
    Par vali7 dans le forum PHP & Base de données
    Réponses: 4
    Dernier message: 18/01/2006, 11h19
  3. petite question sur la récupération d'une variable
    Par minusette dans le forum Langage
    Réponses: 6
    Dernier message: 17/11/2005, 16h57
  4. [C#] Récupération d'une variable d'environnement
    Par jamy79 dans le forum ASP.NET
    Réponses: 1
    Dernier message: 17/08/2005, 14h03
  5. Récupération d'une variable
    Par cach dans le forum Windows
    Réponses: 7
    Dernier message: 22/02/2005, 11h19

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo