Annexe 1

PrintFriendly and PDF

[ A+ ] /[ A- ]

ANNEXE 1

  1. Générer le module avec: generate:module frontend platform
  2. Routing:
  3. platform:
    
    url: /platform
    
    param: { module: platform, action: index }
    
    platform_show_platform:
    
    url: /platform/:id/:name_platform_slug
    
    class: sfDoctrineRoute
    
    options:
    
    model: platform
    
    type: object
    
    param:
    
    module: platform
    
    action: show
    
    requirements:
    
    id: \d+
    
    sf_method: [get]

     

  4. Slug (Platform.class.php)
  5. public function getNamePlatformSlug(){
    
    return Videogames::slugify($this->getNamePlatform());
    
    }
  6. actions.class.php
  7. public function executeIndex(sfWebRequest $request)
    
    {
    
    $this->platforms = Doctrine_Core::getTable('platform')->findAll();
    
    }
    
    public function executeShow(sfWebRequest $request)
    
    {
    
    $this->platform = Doctrine_Core::getTable('platform')->find(array($request->getParameter('id')));
    
    $this->games = $this->platform->getGames();
    
    }
  8. indexSuccess.php
  9. <?php slot('title')?>
    
    <?php echo 'LLG: Platforms' ?>
    
    <?php end_slot();?>
    
    <h1>Platforms</h1>
    
    <span class="little">Choose a platform for listing all the games belonging to it.</span>
    
    <table>
    
    <tbody>
    
    <?php foreach ($platforms as $platform): ?>
    
    <tr>
    
    <td><a href="<?php echo url_for('platform_show_platform',$platform) ?>"><?php echo $platform->getNamePlatform() ?></a> (<?php echo $platform->getAcronyme()?>)</td>
    
    </tr>
    
    <?php endforeach; ?>
    
    </tbody>
    
    </table>
    
    <a href="<?php echo url_for('@homepage') ?>">Games</a>
    
    <a href="<?php echo url_for('@genre') ?>">Genres</a>

     

  10. showSuccess.php
  11. <?php slot('title') ?>
    
    <?php echo sprintf('%s','LLG: '.$platform->getNamePlatform()) ?>
    
    <?php end_slot(); ?>
    
    <h1><?php echo $platform->getNamePlatform() ?></h1>
    
    <?php if(sizeof($games)>0): ?>
    
    <table>
    
    <tbody>
    
    <tr>
    
    <th>Game</th>
    
    <th>Developer</th>
    
    <th>Publisher</th>
    
    <th>Release Date</th>
    
    <?php foreach($games as $game): ?>
    
    <tr>
    
    <td><a href="<?php echo url_for('game_show_game',$game) ?>"><?php echo $game->getNameGame()?></a></td>
    
    <td><?php echo $game->getDeveloper() ?></td>
    
    <td><?php echo $game->getPublisher() ?></td>
    
    <td><?php echo $game->getReleaseDate() ?></td>
    
    </tr>
    
    <?php endforeach; ?>
    
    </tbody>
    
    </table>
    
    <?php else:?>
    
    <span>There are no games currently listed for this platform.<br>Return to:</span>
    
    <?php endif;?>
    
    <a href="<?php echo url_for('@homepage') ?>">Games</a>
    
    <a href="<?php echo url_for('@genre') ?>">Genres</a>
    
    <a href="<?php echo url_for('@platform')?>">Platforms</a>

     

  12. Liens dans la fiche du jeu
  13.  

    <tr>
    
    <th>Platforms:</th>
    
    <td><?php foreach ($platforms as $platform){
    
    echo '<a href="'.url_for('platform_show_platform',$platform).'">'.$platform.'</a><br/>';} ?></td>
    
    </tr>

 

Vous avez trouvé l'article intéressant? Partagez-le!

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *

11 − 10 =