Annonce

Important, migration recommandée : WordPress 2.6.3 est disponible en français.À lire avant la migration !
Annonce 1 : Le Codex en français a besoin de vous pour avancer !
Annonce 2 : Avant de poster, n'oubliez pas de faire une petite Recherche et de lire les règles de ce forum.
Annonce 3 : Lisez notre blog, il regorge de bonnes informations.
  • Index
  •  » Thèmes
  •  » rajouter un hyperlien dans une barre de navigation bizarre

#1 11-08-2008 02:09:07

radiCarl
Passionné WP
Lieu: Québec
Date d'inscription: 17-11-2006
Messages: 102
Site web

rajouter un hyperlien dans une barre de navigation bizarre

- Version de WordPress 2.6 :
- Thème Grain :

Bonjour,

Depuis deux semaines, je développe un deuxième blog spécifiquement consacré à la photographie.

http://radicarl.net/webalbum

Or, le thème de ce blog, Grain, est autant génial que relativement complexe à saisir. En effet, mon problème réside simplement de rajouter dans la barre de navigation du photoblog (en haut à droite) un hyperlien menant à mon premier blogue. Simple en théorie… mais complexe à rajouter dans le code de grain.

Si vous voulez bien m’aider à résoudre mon problème, je vous en serais évidemment reconnaissant. Je vous laisse donc ci-bas le code PHP de la page header.menu.

Code:

  1. <?php
  2. /*     
  3.   This file is part of Grain Theme for WordPress.
  4.   ------------------------------------------------------------------
  5.   File version: $Id: header.menu.php 190 2008-06-24 19:46:59Z sunside $
  6. */
  7.  
  8.   // get info / mosaic page
  9.   $infoPageId      = $GrainOpt->get(GRAIN_INFOPAGE_ID);
  10.   $mosaicPageId    = $GrainOpt->get(GRAIN_MOSAIC_PAGEID);
  11.     $mosaicLinkTitle = $GrainOpt->get(GRAIN_MOSAIC_LINKTITLE);
  12.   $thisIsInfoPage  = ($infoPageId > 0) && ($post->ID == $infoPageId);
  13.   $thisIsMosaicPage  = ($mosaicPageId > 0) && ($post->ID == $mosaicPageId);
  14.  
  15.   // test the availability of some options
  16.   $grain_newest_enabled = $GrainOpt->getYesNo(GRAIN_MNU_NEWEST_VISIBLE);
  17.   $grain_random_enabled = $GrainOpt->getYesNo(GRAIN_MNU_RANDOM_VISIBLE);
  18.   $grain_info_enabled = $GrainOpt->getYesNo(GRAIN_MNU_INFO_VISIBLE);
  19.   $grain_mosaic_enabled = $GrainOpt->getYesNo(GRAIN_MOSAIC_ENABLED);
  20.   $grain_extended_comments = $GrainOpt->getYesNo(GRAIN_EXTENDEDINFO_ENABLED);
  21.  
  22.   // get some system related values
  23.   $isContentPage = is_single() || is_home();
  24.   $postCount = grain_getpostcount();
  25.   $commentCount = grain_getcommentcount();
  26.  
  27. /**********************************************************************************************/
  28.  
  29.   // get post object
  30.   global $post, $GrainOpt;
  31.  
  32.   // this will be the array that contains the menu items
  33.   $links = array();
  34.  
  35.   // Navigation photo links
  36.   if( $postCount && $isContentPage ):
  37.  
  38.     // get next / previous post link
  39.     $prev = $next = null;
  40.     if( get_previous_post() != null ) $prev = grain_mimic_previous_post_link( '%link', __("&laquo; photo pr&eacute;c&eacute;dente", "grain") );
  41.     if( get_next_post() != null )  $next = grain_mimic_next_post_link( '%link', __("prochaine photo &raquo;", "grain") );
  42.  
  43.     // build the link
  44.     $link = "";
  45.     if( $prev )       $link = '<span id="menu-prev" class="postlink">'.$prev.'</span>';
  46.     if( $prev && $next )  $link .= " ";
  47.     if( $next )       $link .= '<span id="menu-next" class="postlink">'.$next.'</span>';
  48.    
  49.     // add the link
  50.     if( !empty($link) ) {
  51.       $classes = array();
  52.       $classes[] = $prev ? "has-prev" : "no-prev";
  53.       $classes[] = $next ? "has-next" : "no-next";
  54.       $classes[] = ($prev && $next) ? "bidir" : "unidir";
  55.       $classes = implode(" ", $classes);
  56.      
  57.       $link  = '<span id="menu-navigation" class="'.$classes.' postlink">'.$link.'</span>';
  58.       array_push( $links, $link );
  59.     }
  60.  
  61.     // add comments link
  62.     if( grain_can_comment() ) {
  63.       $link = grain_generate_comments_link();
  64.       $class = ($commentCount > 0) ? "has-comments" : "no-comments";
  65.       array_push( $links, '<span id="menu-comments" class="'.$class.' infolink">'.$link.'</span>' );
  66.     }
  67.  
  68.     // add permalink
  69.     if( $GrainOpt->getYesNo(GRAIN_MNU_PERMALINK_VISIBLE) ):
  70.       $link = '<a rel="permalink" class="tooltipped" id="permalink" alt="'.__("Permalien pour: ", "grain").$post->post_title.'" title="'.grain_thumbnail_title(__("Permalien", "grain"), $post->post_title).'" href="'.get_permalink($post->ID).'">'.$GrainOpt->get(GRAIN_MNU_PERMALINK_TEXT).'</a>';
  71.       array_push( $links, '<span id="menu-permalink" class="postlink">'.$link.'</span>' );
  72.     endif;
  73.  
  74.   endif;
  75.  
  76.   // Newest photo link
  77.   if( $postCount > 1 && $grain_newest_enabled && !is_home() && ((is_single() && get_next_post()) || is_page()) ):
  78.     $link = '<a rel="start" title="'.__("&lArr; Cliquez pour voir la derni&egrave;re photo", "grain").'" accesskey="h" href="'.get_settings('home').'/">'.__("photo la plus r&eacute;cente", "grain").'</a>';
  79.         array_push( $links, '<span id="menu-newest" class="postlink">'.$link.'</span>' );
  80.   endif;
  81.  
  82.   // Random photo link
  83.   if( $postCount > 2 && $grain_random_enabled ):
  84.     $link = grain_randompost( __("photo al&eacute;atoire", "grain") );
  85.         array_push( $links, '<span id="menu-random" class="postlink">'.$link.'</span>' );
  86.   endif;
  87.  
  88.   // Mosaic page link
  89.   if( $postCount && $grain_mosaic_enabled && !$thisIsMosaicPage ):
  90.     $mosaicpost = get_post($mosaicPageId);
  91.     if($mosaicpost) {
  92.       $link = '<a rel="contents" class="tooltipped" title="'.grain_thumbnail_title($mosaicpost->post_title,__("vue globale", "grain"), "navigation").'" accesskey="m" href="'.get_permalink($mosaicPageId).'">'.$GrainOpt->get(GRAIN_MOSAIC_LINKTITLE).'</a>';
  93.       array_push( $links, '<span id="menu-mosaic" class="pagelink">'.$link.'</span>' );
  94.     }
  95.   endif;
  96.  
  97.  
  98.  
  99.   // Info page link
  100.   if( $grain_info_enabled && !$thisIsInfoPage ):
  101.     $infopost = get_post($infoPageId);
  102.     if($infopost) {
  103.       $link = '<a title="'.__("informations", "grain").'" accesskey="a" href="'.get_permalink($infoPageId).'">'.__("&agrave; propos", "grain").'</a>';
  104.       array_push( $links, '<span id="menu-about" class="pagelink">'.$link.'</span>' );
  105.     }
  106.   endif;
  107.  
  108.       // Retour au blogue page link
  109.     if( $grain_info_enabled && !$thisIsInfoPage ):
  110.     $infopost = get_post($infoPageId);
  111.     if($infopost) {
  112.       $link = '<a title="'.__("informations", "grain").'" accesskey="a" href="'.get_permalink($infoPageId).'">'.__("&agrave; propos", "grain").'</a>';
  113.       array_push( $links, '<span id="menu-about" class="pagelink">'.$link.'</span>' );
  114.     }
  115.   endif;
  116.  
  117.   // combine the array elements to one large menu
  118.   do_action(GRAIN_BEFORE_NAVIGATION);
  119.   echo apply_filters(GRAIN_FILTER_NAVIGATION, implode( $links, ' <span class="menu-delimiter">|</span> ') );
  120.   do_action(GRAIN_AFTER_NAVIGATION);
  121.  
  122. ?>

Puis de la page navlinks.

Code:

  1. <?php
  2. /*     
  3.   This file is part of Grain Theme for WordPress.
  4.   ------------------------------------------------------------------
  5.   File version: $Id: navlinks.php 134 2008-06-20 00:42:50Z sunside $
  6.  
  7. *//**
  8.  
  9.   Navigation helper functions
  10.  
  11.   @package Grain Theme for WordPress
  12.   @subpackage Navigation
  13. */
  14.  
  15.   if(!defined('GRAIN_THEME_VERSION') ) die(basename(__FILE__));
  16.  
  17. /* definitions */
  18.  
  19.   define("GRAIN_FIRST_POST", -1);
  20.   define("GRAIN_NEWEST_POST", +1);
  21.   define("GRAIN_SURROUNDED_POST", 0);
  22.  
  23. /* left/right navigation */
  24.  
  25.   /**
  26.    * grain_mimic_previous_post_link() - Gets a link to the previous post
  27.    *
  28.    * @since 0.1
  29.    * @see grain_mimic_next_post_link()
  30.    * @access private
  31.    * @param string $format Optional. The HTML markup in which the link shall be embedded. "%link" will be replaced with the actual anchor
  32.    * @param string $link Optional. The HTML markup of the link's title. "%title" will be replaced with the post's title
  33.    * @param bool $in_same_cat Optional. Set to TRUE if the next link in the same category shall be retrieved
  34.    * @param mixed $excluded_categories Optional. A list of excluded categories
  35.    * @return string HTML markup with the link to the previous post
  36.    */
  37.   function grain_mimic_previous_post_link($format='&laquo; %link', $link='%title', $in_same_cat = false, $excluded_categories = '') {
  38.     global $post;
  39.  
  40.     if ( is_attachment() )
  41.       $prev = & get_post($post->post_parent);
  42.     else
  43.       $prev = get_previous_post($in_same_cat, $excluded_categories);
  44.  
  45.     if ( !$prev )
  46.       return;
  47.  
  48.     $addon = "";
  49.       //if( grain_extended_comments() ) $addon = '?info=' . ((isset($_REQUEST['info']) && $_REQUEST['info'] == 'on') ? 'on' : 'off');
  50.  
  51.     $title = apply_filters('the_title', $prev->post_title, $prev);
  52.     $string = '<a rel="prev" href="'.get_permalink($prev->ID).$addon.'">';
  53.     $link = str_replace('%title', $title, $link);
  54.     $link = $string . $link . '</a>';
  55.  
  56.     $format = str_replace('%link', $link, $format);
  57.  
  58.     return $format;
  59.   }
  60.  
  61.   /**
  62.    * grain_mimic_next_post_link() - Gets a link to the next post
  63.    *
  64.    * @since 0.1
  65.    * @see grain_mimic_previous_post_link()
  66.    * @access private
  67.    * @param string $format Optional. The HTML markup in which the link shall be embedded. "%link" will be replaced with the actual anchor
  68.    * @param string $link Optional. The HTML markup of the link's title. "%title" will be replaced with the post's title
  69.    * @param bool $in_same_cat Optional. Set to TRUE if the next link in the same category shall be retrieved
  70.    * @param mixed $excluded_categories Optional. A list of excluded categories
  71.    * @return string HTML markup with the link to the previous post
  72.    */
  73.   function grain_mimic_next_post_link($format='%link &raquo;', $link='%title', $in_same_cat = false, $excluded_categories = '') {
  74.     global $post; 
  75.  
  76.     $next = get_next_post($in_same_cat, $excluded_categories);
  77.  
  78.     if ( !$next )
  79.       return;
  80.  
  81.     $title = apply_filters('the_title', $next->post_title, $next);
  82.     $string = '<a rel="next" href="'.get_permalink($next->ID).'">';
  83.     $link = str_replace('%title', $title, $link);
  84.     $link = $string . $link . '</a>';
  85.     $format = str_replace('%link', $link, $format);
  86.  
  87.     return $format;
  88.   }
  89.  
  90. /* comment link generation */
  91.  
  92.   /**
  93.    * grain_generate_comments_link() - Generates a link to the comments
  94.    *
  95.    * The behavior of this function depends on the mode Grain is using. If in popup mode,
  96.    * this link will open the popup. If in extended info mode, this link will lead to the details.
  97.    *
  98.    * @since 0.1
  99.    * @access private
  100.    * @global $GrainOpt Grain options
  101.    * @using $post Global post object
  102.    * @return string HTML markup with the link to the comments
  103.    */
  104.   function grain_generate_comments_link() {
  105.     global $post, $GrainOpt;
  106.    
  107.     $grain_extended_comments = $GrainOpt->getYesNo(GRAIN_EXTENDEDINFO_ENABLED);
  108.     $comments_open = $post->comment_status == "open";
  109.     $link = '';
  110.  
  111.     // get the comment count
  112.     $comment_count = grain_commentcount_string();
  113.  
  114.       // display the comment popup link
  115.     if( !$grain_extended_comments && !GRAIN_REQUESTED_OTEXINFO )
  116.     {
  117.       // get string
  118.       $_hmn_comments_more = str_replace( "%", $comment_count, __("commentaires (%)", "grain") );
  119.      
  120.       // inf info enforcement is on, we skip directly to the comments on the popup
  121.       $internal = ($GrainOpt->getYesNo(GRAIN_CONTENT_ENFORCE_INFO) && $GrainOpt->getYesNo(GRAIN_POPUP_JTC) ? '#comments' : '');
  122.       // build link
  123.       $link .= (!$comments_open ? '<del class="closed-comments">' : '');
  124.       $link .= '<a class="open-popup" onclick="wpopen(this.href); return false" title="'.__("commentaires", "grain").'" accesskey="c" href="?comments_popup='.$post->ID.$internal.'">'.$_hmn_comments_more.'</a>';
  125.       $link .= (!$comments_open ? '</del>' : '');
  126.      
  127.     }
  128.     else
  129.     {
  130.       // get strings
  131.       $_hmn_comments_more = str_replace( "%", $comment_count, __("commentaires (%)", "grain") );
  132.       $_hmn_comments_less = str_replace( "%", $comment_count, __("cacher les commentaires", "grain") );
  133.      
  134.       // set text
  135.       //$text = (isset($_SESSION['grain:info']) && $_SESSION['grain:info'] == 'on') ? $_hmn_comments_less : $_hmn_comments_more;
  136.       $text = GRAIN_REQUESTED_EXINFO ? $_hmn_comments_less : $_hmn_comments_more;
  137.      
  138.       // select behavior (open/close)
  139.       // $target = ($GrainOpt->getYesNo(GRAIN_CONTENT_ENFORCE_INFO) ? '#comments' : '#info');
  140.       $target = "#info";
  141.       $infomode = GRAIN_REQUESTED_EXINFO ? 'off' : 'on'.$target;
  142.      
  143.       // append info to permalink, based on whether it contains an ampersand or not
  144.       $contains_amp = strstr(get_permalink($post->ID), '?');
  145.       $permalink = get_permalink($post->ID) . ($contains_amp !== FALSE ? '&info='.$infomode : '?info='.$infomode);
  146.      
  147.       // build link
  148.       $link .= (!$comments_open ? '<del class="closed-comments">' : '');
  149.       $link .= '<a class="open-extended" title="'.__("voir les commentaires et d&eacute;tails", "grain").'" accesskey="i" rel="details" href="'.$permalink.'">'.$text.'</a>';
  150.       $link .= (!$comments_open ? '</del>' : '');
  151.     }
  152.    
  153.     return $link;
  154.   } 
  155.  
  156. /* Header Menu */
  157.  
  158.   /**
  159.    * grain_inject_navigation_menu() - This function injects the navgation menu
  160.    *
  161.    * The navigation menu is defined in ./header.menu.php
  162.    *
  163.    * @since 0.1
  164.    * @access private
  165.    * @global $GrainOpt Grain options
  166.    */
  167.   function grain_inject_navigation_menu($location)
  168.   {
  169.     global $GrainOpt;
  170.     $target = $GrainOpt->get(GRAIN_NAVBAR_LOCATION);
  171.    
  172.     if($location != $target ) return;
  173.    
  174.     global $post;
  175.    
  176.     if( $location == GRAIN_IS_HEADER )
  177.       $class = "in-header";
  178.     else
  179.       $class = "in-body";
  180.     ?>
  181.  
  182.   <div id="headermenu" class="<?php echo $class; ?>">
  183.     <?php
  184.     include (TEMPLATEPATH . '/header.menu.php');
  185.     ?>
  186.   </div>   
  187.    
  188.     <?php
  189.   } 
  190.  
  191. ?>

Merci pour l’attention wp

Dernière modification par radiCarl (11-08-2008 02:10:00)

Hors ligne

 

#2 15-08-2008 00:48:07

radiCarl
Passionné WP
Lieu: Québec
Date d'inscription: 17-11-2006
Messages: 102
Site web

Re: rajouter un hyperlien dans une barre de navigation bizarre

Je n'ai toujours pas trouvé sad

Hors ligne

 

#3 15-08-2008 09:54:53

freshvalerio
Membre WP
Date d'inscription: 14-08-2008
Messages: 7

Re: rajouter un hyperlien dans une barre de navigation bizarre

Et tu as essayé dans le div headermenu ?

Hors ligne

 

#4 16-08-2008 21:04:22

radiCarl
Passionné WP
Lieu: Québec
Date d'inscription: 17-11-2006
Messages: 102
Site web

Re: rajouter un hyperlien dans une barre de navigation bizarre

Merci, j'ai trouvé

Hors ligne

 

#5 16-08-2008 21:12:36

Lumière de Lune
Not a plastic girl
Lieu: Allemagne - Maroc
Date d'inscription: 15-08-2007
Messages: 2078
Site web

Re: rajouter un hyperlien dans une barre de navigation bizarre

Et ? Comme ça ça pourrait servir ?


Voyage au Maroc
Photos et web au Maroc
... tout ça sous WordPress, bien sûr !
Avez-vous lu les Dix commandements du débuggueur de blog ?

Hors ligne

 

#6 17-08-2008 00:00:51

radiCarl
Passionné WP
Lieu: Québec
Date d'inscription: 17-11-2006
Messages: 102
Site web

Re: rajouter un hyperlien dans une barre de navigation bizarre

Salut,

Après avoir activé la page "a propos" dans les option du thème, j'ai simplement ajouté ce code dans le fichier header.menu.php

// Retour au blogue page link
        if( $grain_info_enabled && !$thisIsInfoPage ):
        $infopost = get_post($infoPageId);
        if($infopost) {
            $link = '<a title="'.__("retour au blogue principal (radicarl.net)", "grain").'" accesskey="a" href="http://radicarl.net">'.__("blogue/accueil", "grain").'</a>';
            array_push( $links, '<span id="menu-about" class="pagelink">'.$link.'</span>' );
        }
    endif;

Hors ligne

 
  • Index
  •  » Thèmes
  •  » rajouter un hyperlien dans une barre de navigation bizarre

Pied de page des forums

Propulsé par PunBB 1.2.20
© Copyright 2005-2006 WordPress France