Advertisement
lherry

category-agenda.php

Jan 25th, 2013
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.98 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Page de catégories : Agenda (category-agenda.php)
  4.  * Category Agenda du thème
  5.  *
  6.  * @package WordPress
  7.  */
  8. ?>
  9. <?php get_header(); ?>
  10.     <section id="main-area" class="wrap breadcrumbs clearfix" role="main">
  11.         <div class="breadcrumbs top clearfix">
  12.             <aside>Vous êtes ici:</aside>
  13.             <ul>
  14.                 <li><a href="<?php bloginfo('url') ?>" title="">Accueil</a></li>
  15.                 <li class="current">Agenda</li>
  16.             </ul>
  17.         </div>
  18.         <section id="agenda" class="clearfix">
  19.             <header class="clearfix">
  20.                 <h1>L'agenda</h1>
  21.                 <aside>
  22.                     <ul id="social-buttons">
  23.                         <li><div class="fb-like" data-href="<?php the_permalink(); ?>" data-send="false" data-layout="button_count" data-width="90" data-show-faces="false"></div></li>
  24.                         <li><a href="https://twitter.com/share" class="twitter-share-button" data-url="<?php the_permalink(); ?>" data-lang="fr" data-count="none">Tweeter</a></li>
  25.                         <li><div class="g-plusone" data-size="medium"></div></li>
  26.                     </ul>
  27.                 </aside>
  28.         <p><?php echo category_description( get_category_by_slug( 'agenda' )->term_id ); ?></p>
  29.             </header>
  30.             <nav class="filters clearfix">
  31.                 <ul>
  32.                     <li>Filtrez les news par catégorie</li>
  33.                     <li><a href="<?php echo get_category_link( get_category_by_slug( 'agenda' )->term_id ); ?>" title="" <?php if( is_category( 'agenda' )): ?>class="active"<?php endif; ?>>Tout<span class="status"></span></a></li>
  34.                     <?php $categories = get_categories( array( 'orderby' => 'id',
  35.                                                                'order' => 'ASC',
  36.                                                                'child_of' => get_category_by_slug( 'agenda' )->term_id,
  37.                                                                'hide_empty' => 0 )); ?>
  38.                     <?php foreach( $categories as $category ) : ?>
  39.                     <li><a href="<?php echo get_category_link( $category->term_id ); ?>" title="<?php sprintf( __( "View all posts in %s" ), $category->name ); ?>" <?php if( is_category( $category->term_id )): ?>class="active"<?php endif; ?>><?php echo $category->name; ?><span class="status"></span></a></li>
  40.                     <?php endforeach; ?>
  41.                 </ul>
  42.             </nav>
  43.             <?php
  44.               /**/
  45.               // LHE : Gestion des plages de dates
  46.               switch( getCurrentCatID() ) {
  47.              
  48.                 case get_category_by_slug( 'agenda' )->term_id:
  49.                   // Appeler les articles futurs pour les catégories "Concerts", "Masterclasses" et "Stages"
  50.                   $agenda = new WP_Query( array( 'category__in' => array( get_category_by_slug( 'concerts'           )->term_id,
  51.                                                                           get_category_by_slug( 'masterclass-agenda' )->term_id,
  52.                                                                           get_category_by_slug( 'stages'             )->term_id ),
  53.                                                  'meta_key' => 'date',
  54.                                                  'meta_value' => getDateWithTol(),
  55.                                                  'meta_compare' => '>=',
  56.                                                  'orderby' => 'meta_value_num',
  57.                                                  'order' => 'ASC',
  58.                                                  'post_status' => 'publish',
  59.                                                  'posts_per_page' => get_option('posts_per_page'),
  60.                                                  'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1 ));
  61.                   break;
  62.                  
  63.                 case get_category_by_slug( 'concerts'           )->term_id:
  64.                 case get_category_by_slug( 'masterclass-agenda' )->term_id:
  65.                 case get_category_by_slug( 'stages'             )->term_id:
  66.                   // Appeler les articles futurs pour la catégorie sélectionnée
  67.                   $agenda = new WP_Query( array( 'cat' => getCurrentCatID(),
  68.                                                  'meta_key' => 'date',
  69.                                                  'meta_value' => getDateWithTol(),
  70.                                                  'meta_compare' => '>=',
  71.                                                  'orderby' => 'meta_value_num',
  72.                                                  'order' => 'ASC',
  73.                                                  'post_status' => 'publish',
  74.                                                  'posts_per_page' => get_option('posts_per_page'),
  75.                                                  'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1 ));
  76.                   break;
  77.  
  78.                 case get_category_by_slug( 'actualites' )->term_id:
  79.                   // Appeler les articles d'actualité dans la période de tolérance
  80.                   $agenda = new WP_Query( array( 'cat' => getCurrentCatID(),
  81.                                                  'meta_key' => 'date',
  82.                                                  'meta_value' => getDateWithTol(get_field('duree_vie_actualite', 'option')),
  83.                                                  'meta_compare' => '>=',
  84.                                                  'orderby' => 'meta_value_num',
  85.                                                  'order' => 'ASC',
  86.                                                  'post_status' => 'publish',
  87.                                                  'posts_per_page' => get_option('posts_per_page'),
  88.                                                  'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1 ));
  89.                   break;
  90.  
  91.                 // Archives
  92.                 case get_category_by_slug( 'archives' )->term_id:
  93.                   // Appeler les articles toutes catégories passés
  94.                   $agenda = new WP_Query( array( 'cat' => getCurrentCatID(),
  95.                                                  'meta_key' => 'date',
  96.                                                  'meta_value' => getDateWithTol(),
  97.                                                  'meta_compare' => '<',
  98.                                                  'orderby' => 'meta_value_num',
  99.                                                  'order' => 'ASC',
  100.                                                  'post_status' => 'publish',
  101.                                                  'posts_per_page' => get_option('posts_per_page'),
  102.                                                  'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1 ));
  103.                   break;
  104.                  
  105.                 default:
  106.               } // endswitch;
  107.               /**/
  108.             ?>
  109.             <?php if( $agenda->have_posts() ) : while ( $agenda->have_posts() ) : $agenda->the_post(); ?>
  110.             <?php $date = DateTime::createFromFormat('Ymd', get_field( 'date' )); ?>
  111.             <article id="post-<?php the_ID(); ?>" class="large clearfix">
  112.                 <div><?php if(has_post_thumbnail()): the_post_thumbnail('thumb-agenda',array('title' => "")); endif; ?></div>
  113.                 <section class="content">
  114.                     <aside><?php echo( getUsefulCats( ' / ' )); // the_category(', '); ?></aside>
  115.                     <time datetime="<?php echo $date->format('Y-m-d'); ?>" pubdate="<?php the_time('Y-m-d'); ?>"><?php echo $date->format('d/m/Y'); ?></time>
  116.                     <h2><?php the_title(); ?></h2>
  117.           <?php // LHE Ajout des balises spécifiques pour les évènements ?>
  118.           <h5><?php if( get_field( 'date_fin' )) : $dateFin = DateTime::createFromFormat('Ymd', get_field( 'date_fin' )); ?>Du <?php echo getFrenchDate( $date ); ?> au <?php echo getFrenchDate( $dateFin ); ?> &ndash; <?php endif; ?><?php $heure='heure'; if( intval( get_field( 'durée' )) > 1 ) $heure .= 's'; ?>Durée <?php echo get_field( 'durée' ) . ' ' . $heure; ?></h5>
  119.                     <?php if( get_field( 'horaires' )) : ?><h6>Horaires : <?php echo get_field( 'horaires' ); ?></h6><?php endif; ?>
  120.                     <?php the_content(); ?>
  121.                     <?php // LHE : Gestion du rattachement des intervenants à l'évènement
  122.                     if( get_field( 'intervenants_rattaches' )) :
  123.                       echo( '<p><u>Intervenant(s) :</u></p><ul>' ); //
  124.                       // Parcourir chaque élément
  125.                       while( has_sub_field( 'intervenants_rattaches' )) :
  126.                         // Pour chaque enseignant afficher le lien ?>
  127.                         <li><a href="<?php echo get_sub_field( 'intervenant' ); ?>" target="_blank"><?php echo get_sub_field( 'libellé' ); ?></a></li>
  128.                     <?php endwhile; ?></ul>
  129.                     <?php endif; /**/ ?>
  130.                     <h7>Tarif : <?php echo get_field( 'tarif' ); ?> &euro;</h7>
  131.                     <?php if( get_field('intitulé_du_bouton' )) : ?>
  132.                       <a href="<?php the_field( 'bouton' ); ?>" title="" class="button"><?php the_field('intitulé_du_bouton'); ?></a>
  133.                   <?php endif; ?>
  134.                 </section>
  135.             </article>
  136.              <?php endwhile; else: ?>
  137.                <?php _e('Désolé, il n\'y a pas d\'évènement dans cette catégorie.'); ?>
  138.              <?php endif; ?>
  139.             <?php wp_reset_postdata(); wp_reset_query(); ?>
  140.             <footer>
  141.                 <?php if(function_exists('wp_paginate')) wp_paginate(); ?>
  142.             </footer>
  143.         </section>
  144.         <div class="breadcrumbs bottom">
  145.             <aside>Vous êtes ici:</aside>
  146.             <ul>
  147.                 <li><a href="<?php bloginfo('url') ?>" title="">Accueil</a></li>
  148.                 <li class="current">Agenda</li>
  149.             </ul>
  150.         </div>
  151.     </section>
  152. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement