Vous n'êtes pas identifié.
Annonce
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.
#1 11-08-2008 02:09:07
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:
- <?php
- /*
- This file is part of Grain Theme for WordPress.
- ------------------------------------------------------------------
- File version: $Id: header.menu.php 190 2008-06-24 19:46:59Z sunside $
- */
- // get info / mosaic page
- $infoPageId = $GrainOpt->get(GRAIN_INFOPAGE_ID);
- $mosaicPageId = $GrainOpt->get(GRAIN_MOSAIC_PAGEID);
- $mosaicLinkTitle = $GrainOpt->get(GRAIN_MOSAIC_LINKTITLE);
- $thisIsInfoPage = ($infoPageId > 0) && ($post->ID == $infoPageId);
- $thisIsMosaicPage = ($mosaicPageId > 0) && ($post->ID == $mosaicPageId);
- // test the availability of some options
- $grain_newest_enabled = $GrainOpt->getYesNo(GRAIN_MNU_NEWEST_VISIBLE);
- $grain_random_enabled = $GrainOpt->getYesNo(GRAIN_MNU_RANDOM_VISIBLE);
- $grain_info_enabled = $GrainOpt->getYesNo(GRAIN_MNU_INFO_VISIBLE);
- $grain_mosaic_enabled = $GrainOpt->getYesNo(GRAIN_MOSAIC_ENABLED);
- $grain_extended_comments = $GrainOpt->getYesNo(GRAIN_EXTENDEDINFO_ENABLED);
- // get some system related values
- $isContentPage = is_single() || is_home();
- $postCount = grain_getpostcount();
- $commentCount = grain_getcommentcount();
- /**********************************************************************************************/
- // get post object
- global $post, $GrainOpt;
- // this will be the array that contains the menu items
- $links = array();
- // Navigation photo links
- if( $postCount && $isContentPage ):
- // get next / previous post link
- $prev = $next = null;
- if( get_previous_post() != null ) $prev = grain_mimic_previous_post_link( '%link', __("« photo précédente", "grain") );
- if( get_next_post() != null ) $next = grain_mimic_next_post_link( '%link', __("prochaine photo »", "grain") );
- // build the link
- $link = "";
- if( $prev ) $link = '<span id="menu-prev" class="postlink">'.$prev.'</span>';
- if( $prev && $next ) $link .= " ";
- if( $next ) $link .= '<span id="menu-next" class="postlink">'.$next.'</span>';
- // add the link
- if( !empty($link) ) {
- $classes = array();
- $classes[] = $prev ? "has-prev" : "no-prev";
- $classes[] = $next ? "has-next" : "no-next";
- $classes[] = ($prev && $next) ? "bidir" : "unidir";
- $classes = implode(" ", $classes);
- $link = '<span id="menu-navigation" class="'.$classes.' postlink">'.$link.'</span>';
- array_push( $links, $link );
- }
- // add comments link
- if( grain_can_comment() ) {
- $link = grain_generate_comments_link();
- $class = ($commentCount > 0) ? "has-comments" : "no-comments";
- array_push( $links, '<span id="menu-comments" class="'.$class.' infolink">'.$link.'</span>' );
- }
- // add permalink
- if( $GrainOpt->getYesNo(GRAIN_MNU_PERMALINK_VISIBLE) ):
- $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>';
- array_push( $links, '<span id="menu-permalink" class="postlink">'.$link.'</span>' );
- endif;
- endif;
- // Newest photo link
- if( $postCount > 1 && $grain_newest_enabled && !is_home() && ((is_single() && get_next_post()) || is_page()) ):
- $link = '<a rel="start" title="'.__("⇐ Cliquez pour voir la dernière photo", "grain").'" accesskey="h" href="'.get_settings('home').'/">'.__("photo la plus récente", "grain").'</a>';
- array_push( $links, '<span id="menu-newest" class="postlink">'.$link.'</span>' );
- endif;
- // Random photo link
- if( $postCount > 2 && $grain_random_enabled ):
- $link = grain_randompost( __("photo aléatoire", "grain") );
- array_push( $links, '<span id="menu-random" class="postlink">'.$link.'</span>' );
- endif;
- // Mosaic page link
- if( $postCount && $grain_mosaic_enabled && !$thisIsMosaicPage ):
- $mosaicpost = get_post($mosaicPageId);
- if($mosaicpost) {
- $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>';
- array_push( $links, '<span id="menu-mosaic" class="pagelink">'.$link.'</span>' );
- }
- endif;
- // Info page link
- if( $grain_info_enabled && !$thisIsInfoPage ):
- $infopost = get_post($infoPageId);
- if($infopost) {
- $link = '<a title="'.__("informations", "grain").'" accesskey="a" href="'.get_permalink($infoPageId).'">'.__("à propos", "grain").'</a>';
- array_push( $links, '<span id="menu-about" class="pagelink">'.$link.'</span>' );
- }
- endif;
- // Retour au blogue page link
- if( $grain_info_enabled && !$thisIsInfoPage ):
- $infopost = get_post($infoPageId);
- if($infopost) {
- $link = '<a title="'.__("informations", "grain").'" accesskey="a" href="'.get_permalink($infoPageId).'">'.__("à propos", "grain").'</a>';
- array_push( $links, '<span id="menu-about" class="pagelink">'.$link.'</span>' );
- }
- endif;
- // combine the array elements to one large menu
- do_action(GRAIN_BEFORE_NAVIGATION);
- echo apply_filters(GRAIN_FILTER_NAVIGATION, implode( $links, ' <span class="menu-delimiter">|</span> ') );
- do_action(GRAIN_AFTER_NAVIGATION);
- ?>
Puis de la page navlinks.
Code:
- <?php
- /*
- This file is part of Grain Theme for WordPress.
- ------------------------------------------------------------------
- File version: $Id: navlinks.php 134 2008-06-20 00:42:50Z sunside $
- *//**
- Navigation helper functions
- @package Grain Theme for WordPress
- @subpackage Navigation
- */
- if(!defined('GRAIN_THEME_VERSION') ) die(basename(__FILE__));
- /* definitions */
- define("GRAIN_FIRST_POST", -1);
- define("GRAIN_NEWEST_POST", +1);
- define("GRAIN_SURROUNDED_POST", 0);
- /* left/right navigation */
- /**
- * grain_mimic_previous_post_link() - Gets a link to the previous post
- *
- * @since 0.1
- * @see grain_mimic_next_post_link()
- * @access private
- * @param string $format Optional. The HTML markup in which the link shall be embedded. "%link" will be replaced with the actual anchor
- * @param string $link Optional. The HTML markup of the link's title. "%title" will be replaced with the post's title
- * @param bool $in_same_cat Optional. Set to TRUE if the next link in the same category shall be retrieved
- * @param mixed $excluded_categories Optional. A list of excluded categories
- * @return string HTML markup with the link to the previous post
- */
- function grain_mimic_previous_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '') {
- global $post;
- if ( is_attachment() )
- $prev = & get_post($post->post_parent);
- else
- $prev = get_previous_post($in_same_cat, $excluded_categories);
- if ( !$prev )
- return;
- $addon = "";
- //if( grain_extended_comments() ) $addon = '?info=' . ((isset($_REQUEST['info']) && $_REQUEST['info'] == 'on') ? 'on' : 'off');
- $title = apply_filters('the_title', $prev->post_title, $prev);
- $string = '<a rel="prev" href="'.get_permalink($prev->ID).$addon.'">';
- $link = str_replace('%title', $title, $link);
- $link = $string . $link . '</a>';
- $format = str_replace('%link', $link, $format);
- return $format;
- }
- /**
- * grain_mimic_next_post_link() - Gets a link to the next post
- *
- * @since 0.1
- * @see grain_mimic_previous_post_link()
- * @access private
- * @param string $format Optional. The HTML markup in which the link shall be embedded. "%link" will be replaced with the actual anchor
- * @param string $link Optional. The HTML markup of the link's title. "%title" will be replaced with the post's title
- * @param bool $in_same_cat Optional. Set to TRUE if the next link in the same category shall be retrieved
- * @param mixed $excluded_categories Optional. A list of excluded categories
- * @return string HTML markup with the link to the previous post
- */
- function grain_mimic_next_post_link($format='%link »', $link='%title', $in_same_cat = false, $excluded_categories = '') {
- global $post;
- $next = get_next_post($in_same_cat, $excluded_categories);
- if ( !$next )
- return;
- $title = apply_filters('the_title', $next->post_title, $next);
- $string = '<a rel="next" href="'.get_permalink($next->ID).'">';
- $link = str_replace('%title', $title, $link);
- $link = $string . $link . '</a>';
- $format = str_replace('%link', $link, $format);
- return $format;
- }
- /* comment link generation */
- /**
- * grain_generate_comments_link() - Generates a link to the comments
- *
- * The behavior of this function depends on the mode Grain is using. If in popup mode,
- * this link will open the popup. If in extended info mode, this link will lead to the details.
- *
- * @since 0.1
- * @access private
- * @global $GrainOpt Grain options
- * @using $post Global post object
- * @return string HTML markup with the link to the comments
- */
- function grain_generate_comments_link() {
- global $post, $GrainOpt;
- $grain_extended_comments = $GrainOpt->getYesNo(GRAIN_EXTENDEDINFO_ENABLED);
- $comments_open = $post->comment_status == "open";
- $link = '';
- // get the comment count
- $comment_count = grain_commentcount_string();
- // display the comment popup link
- if( !$grain_extended_comments && !GRAIN_REQUESTED_OTEXINFO )
- {
- // get string
- $_hmn_comments_more = str_replace( "%", $comment_count, __("commentaires (%)", "grain") );
- // inf info enforcement is on, we skip directly to the comments on the popup
- $internal = ($GrainOpt->getYesNo(GRAIN_CONTENT_ENFORCE_INFO) && $GrainOpt->getYesNo(GRAIN_POPUP_JTC) ? '#comments' : '');
- // build link
- $link .= (!$comments_open ? '<del class="closed-comments">' : '');
- $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>';
- $link .= (!$comments_open ? '</del>' : '');
- }
- else
- {
- // get strings
- $_hmn_comments_more = str_replace( "%", $comment_count, __("commentaires (%)", "grain") );
- $_hmn_comments_less = str_replace( "%", $comment_count, __("cacher les commentaires", "grain") );
- // set text
- //$text = (isset($_SESSION['grain:info']) && $_SESSION['grain:info'] == 'on') ? $_hmn_comments_less : $_hmn_comments_more;
- $text = GRAIN_REQUESTED_EXINFO ? $_hmn_comments_less : $_hmn_comments_more;
- // select behavior (open/close)
- // $target = ($GrainOpt->getYesNo(GRAIN_CONTENT_ENFORCE_INFO) ? '#comments' : '#info');
- $target = "#info";
- $infomode = GRAIN_REQUESTED_EXINFO ? 'off' : 'on'.$target;
- // append info to permalink, based on whether it contains an ampersand or not
- $contains_amp = strstr(get_permalink($post->ID), '?');
- $permalink = get_permalink($post->ID) . ($contains_amp !== FALSE ? '&info='.$infomode : '?info='.$infomode);
- // build link
- $link .= (!$comments_open ? '<del class="closed-comments">' : '');
- $link .= '<a class="open-extended" title="'.__("voir les commentaires et détails", "grain").'" accesskey="i" rel="details" href="'.$permalink.'">'.$text.'</a>';
- $link .= (!$comments_open ? '</del>' : '');
- }
- return $link;
- }
- /* Header Menu */
- /**
- * grain_inject_navigation_menu() - This function injects the navgation menu
- *
- * The navigation menu is defined in ./header.menu.php
- *
- * @since 0.1
- * @access private
- * @global $GrainOpt Grain options
- */
- function grain_inject_navigation_menu($location)
- {
- global $GrainOpt;
- $target = $GrainOpt->get(GRAIN_NAVBAR_LOCATION);
- if($location != $target ) return;
- global $post;
- if( $location == GRAIN_IS_HEADER )
- $class = "in-header";
- else
- $class = "in-body";
- ?>
- <div id="headermenu" class="<?php echo $class; ?>">
- <?php
- include (TEMPLATEPATH . '/header.menu.php');
- ?>
- </div>
- <?php
- }
- ?>
Merci pour l’attention 
Dernière modification par radiCarl (11-08-2008 02:10:00)
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
#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
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
