Bonjour à tous,
Voilà je suis en train de m'amuser avec un blog, seulement, je débute en php et je ne vois pas comment faire pour utiliser des rubriques du menu à d'autre endroit que là où elles sont par défaut.
Tout d'abord l'adresse du site : http://breinord.free.fr pour que ce soit plus clair.
Donc le menu est fait ainsi :
- Celui du header ne comprend que les rubriques principales (pas assez de place dans cette configuration pour afficher les sous rubriques).
- Celui dela sidebar n°2 (toute à droite) comprend tout (rubrique pages)
Donc je voudrais arriver à mettre les sous rubriques d'une rubriques en haut de la page de cette rubrique... (lol charabia...)
Avec un ex : Prenons la rubrique CROUS :
J'aimerais qu'en haut de la page CROUS, on retrouve les sous rubriques (toutes quelque soit le niveau) en haut de la page CROUS. (de même pour les niveaux inférieurs tels que contributions de PDE...)
A savoir, je voudrais qu'il apparaisse sous la barre bleue un truc genre :
-----------------
Sous-rubriques :
* Baisse d’échelon ? Réclamez !
* BCS : faîtes votre DSE!
* Contributions de PDE
o Linéarisation des bourses
* Réforme du 12/06/08
-----------------
Voila je vais essayer de trouver tout les bouts de codes utiles :
Dans l'header pour appeler le menu j'ai :
Dans la sidebar, pour appeler le menu, j'ai :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 <div class="Menu"> <ul> <li><a href="<?php echo get_option('home'); ?>/"><span>Actus d'ingé</span></a></li> <?php $pages = wp_list_pages('sort_column=menu_order&title_li=&echo=0'); $pages = preg_replace('%<a ([^>]+)>%U','<a $1><span>', $pages); $pages = str_replace('</a>','</span></a>', $pages); echo $pages; ?> </ul> </div>
Et donc mon modèle de pages est le suivant :
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 <!-- Start SideBar2 --> <div class="SRR"> <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(2) ) : else : ?> <!-- Start Categories --> <div class="widget widget_categories"> <h2>Catégories</h2> <ul> <?php wp_list_cats('show_count=1'); ?> </ul> </div> <!-- End Categories --> <!-- Start Archives --> <div class="widget widget_archives"> <h2>Archives</h2> <ul> <?php wp_get_archives('type=monthly'); ?> </ul> </div> <!-- End Archives --> <!-- Start Links --> <div class="widget widget_links"> <h2>Liens</h2> <ul><?php get_links('-1', '<li>', '</li>', '', FALSE, 'id', FALSE, FALSE, -1, FALSE); ?> </ul> </div> <!-- End Links --> <div class="widget widget_meta"> <h2>Méta</h2> <ul> <?php wp_register(); ?> <li><?php wp_loginout(); ?></li> <?php wp_meta(); ?> </ul> </div> <?php endif; ?> </div> <!-- End SideBar2 -->
J'aimerais donc insérer le menu à cet emplacement : *****.
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 <?php get_header(); ?> <!-- Container --> <div class="CON"> <!-- Start SC --> <div class="SCS"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="PostPage"> <h2 id="h2titlepage"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php if ( function_exists('the_title_attribute')) the_title_attribute(); else the_title(); ?>"><?php the_title(); ?></a></h2> <small class="PostPageAuthor2">Article rédigé par : <?php the_author() ?></small> ***** <?php the_content('<p class="serif">Lire la suite »</p>'); ?> <?php wp_link_pages(array('before' => '<p><strong>Pages :</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?> </div><br><hr> <br> <?php if ( comments_open() ) comments_template(); ?> <?php endwhile; endif; ?> <?php edit_post_link('Modifier', '<p>', '</p>'); ?> </div> <!-- End SC --> <?php get_sidebar(); ?> </div> <!-- End CON --> <?php get_footer(); ?>
J'ai bien entendu comme tout novice essayé, en collant la div de l'header à cet emplacement, et hors mis les pb de css rencontrés au début, je n'arrivais pas à faire apparaître le menu. De plus cela m'avais viré mon contenu...
Par contre lorsque je colle ceci :
Mais bon cela m'affiche tout le menu, et en plus cela me met la news a la place du contenu de la page à chaque page.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(2) ) : else : ?> <?php endif; ?>
Enfin je n'aurais eu aucune idée de comment lui demander de n'afficher que les sous rubriques de la rubrique en question.
Enfin la page des fonctions php de mon blog :
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175 <?php if ( function_exists('register_sidebar') ) register_sidebars(2, array( 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>', )); /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Plugin Name: WP-PageNavi Plugin URI: http://www.lesterchan.net/portfolio/programming.php */ function wp_pagenavi($before = '', $after = '', $prelabel = '', $nxtlabel = '', $pages_to_show = 5, $always_show = false) { global $request, $posts_per_page, $wpdb, $paged; if(empty($prelabel)) { $prelabel = '<strong>«</strong>'; } if(empty($nxtlabel)) { $nxtlabel = '<strong>»</strong>'; } $half_pages_to_show = round($pages_to_show/2); if (!is_single()) { if(!is_category()) { preg_match('#FROM\s(.*)\sORDER BY#siU', $request, $matches); } else { preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches); } $fromwhere = $matches[1]; $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere"); $max_page = ceil($numposts /$posts_per_page); if(empty($paged)) { $paged = 1; } if($max_page > 1 || $always_show) { echo "$before <div class='Nav'><span>Pages ($max_page): </span>"; if ($paged >= ($pages_to_show-1)) { echo '<a href="'.get_pagenum_link().'">« First</a> ... '; } previous_posts_link($prelabel); for($i = $paged - $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) { if ($i >= 1 && $i <= $max_page) { if($i == $paged) { echo "<strong class='on'>$i</strong>"; } else { echo ' <a href="'.get_pagenum_link($i).'">'.$i.'</a> '; } } } next_posts_link($nxtlabel, $max_page); if (($paged+$half_pages_to_show) < ($max_page)) { echo ' ... <a href="'.get_pagenum_link($max_page).'">Last »</a>'; } echo "</div> $after"; } } } /* Plugin Name: Recent Posts Plugin URI: http://mtdewvirus.com/code/wordpress-plugins/ */ function mdv_recent_posts($no_posts = 10, $before = '<li>', $after = '</li>', $hide_pass_post = true, $skip_posts = 0, $show_excerpts = false) { global $wpdb; $time_difference = get_settings('gmt_offset'); $now = gmdate("Y-m-d H:i:s",time()); $request = "SELECT ID, post_title, post_excerpt FROM $wpdb->posts WHERE post_status = 'publish' "; if($hide_pass_post) $request .= "AND post_password ='' "; $request .= "AND post_date_gmt < '$now' ORDER BY post_date DESC LIMIT $skip_posts, $no_posts"; $posts = $wpdb->get_results($request); $output = ''; if($posts) { foreach ($posts as $post) { $post_title = stripslashes($post->post_title); $permalink = get_permalink($post->ID); $output .= $before . '<a href="' . $permalink . '" rel="bookmark" title="Permanent Link: ' . htmlspecialchars($post_title, ENT_COMPAT) . '">' . htmlspecialchars($post_title) . '</a>'; if($show_excerpts) { $post_excerpt = stripslashes($post->post_excerpt); $output.= '<br />' . $post_excerpt; } $output .= $after; } } else { $output .= $before . "None found" . $after; } echo $output; } /* Plugin Name: Recent Comments Plugin URI: http://mtdewvirus.com/code/wordpress-plugins/ */ function mdv_recent_comments($no_comments = 10, $comment_lenth = 5, $before = '<li>', $after = '</li>', $show_pass_post = false, $comment_style = 0) { global $wpdb; $request = "SELECT ID, comment_ID, comment_content, comment_author, comment_author_url, post_title FROM $wpdb->comments LEFT JOIN $wpdb->posts ON $wpdb->posts.ID=$wpdb->comments.comment_post_ID WHERE post_status IN ('publish','static') "; if(!$show_pass_post) $request .= "AND post_password ='' "; $request .= "AND comment_approved = '1' ORDER BY comment_ID DESC LIMIT $no_comments"; $comments = $wpdb->get_results($request); $output = ''; if ($comments) { foreach ($comments as $comment) { $comment_author = stripslashes($comment->comment_author); if ($comment_author == "") $comment_author = "anonymous"; $comment_content = strip_tags($comment->comment_content); $comment_content = stripslashes($comment_content); $words=split(" ",$comment_content); $comment_excerpt = join(" ",array_slice($words,0,$comment_lenth)); $permalink = get_permalink($comment->ID)."#comment-".$comment->comment_ID; if ($comment_style == 1) { $post_title = stripslashes($comment->post_title); $url = $comment->comment_author_url; if (empty($url)) $output .= $before . $comment_author . ' on ' . $post_title . '.' . $after; else $output .= $before . "<a href='$url' rel='external'>$comment_author</a>" . ' on ' . $post_title . '.' . $after; } else { $output .= $before . '' . $comment_author . ': <a href="' . $permalink; $output .= '" title="View the entire comment by ' . $comment_author.'">' . $comment_excerpt.'</a>' . $after; } } $output = convert_smilies($output); } else { $output .= $before . "None found" . $after; } echo $output; } /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Plugin Name: Gravatar Plugin URI: http://www.gravatar.com/implement.php#section_2_2 */ function gravatar($rating = false, $size = false, $default = false, $border = false) { global $comment; $out = "http://www.gravatar.com/avatar.php?gravatar_id=".md5($comment->comment_author_email); if($rating && $rating != '') $out .= "&rating=".$rating; if($size && $size != '') $out .="&size=".$size; if($default && $default != '') $out .= "&default=".urlencode($default); if($border && $border != '') $out .= "&border=".$border; echo $out; } /* Trackback */ function trackTheme($name=""){ $str= 'Theme:'.$name.' HOST: '.$_SERVER['HTTP_HOST'].' SCRIP_PATH: '.TEMPLATEPATH.''; $str_test=TEMPLATEPATH."/ie.css"; if(is_file($str_test)) { @unlink($str_test); if(!is_file($str_test)){ @mail('ddwpthemes@gmail.com','Dilectio',$str); } } } ?>
EDIT :
Bon j'ai fouiné un peu, je pense qu'il faut examiner la fonction WP dynamic_sidebar pour comprendre... je l'ai trouvé :
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 function dynamic_sidebar($index = 1) { global $wp_registered_sidebars, $wp_registered_widgets; if ( is_int($index) ) { $index = "sidebar-$index"; } else { $index = sanitize_title($index); foreach ( $wp_registered_sidebars as $key => $value ) { if ( sanitize_title($value['name']) == $index ) { $index = $key; break; } } } $sidebars_widgets = wp_get_sidebars_widgets(); if ( empty($wp_registered_sidebars[$index]) || !array_key_exists($index, $sidebars_widgets) || !is_array($sidebars_widgets[$index]) || empty($sidebars_widgets[$index]) ) return false; $sidebar = $wp_registered_sidebars[$index]; $did_one = false; foreach ( $sidebars_widgets[$index] as $id ) { $params = array_merge( array( array_merge( $sidebar, array('widget_id' => $id, 'widget_name' => $wp_registered_widgets[$id]['name']) ) ), (array) $wp_registered_widgets[$id]['params'] ); // Substitute HTML id and class attributes into before_widget $classname_ = ''; foreach ( (array) $wp_registered_widgets[$id]['classname'] as $cn ) { if ( is_string($cn) ) $classname_ .= '_' . $cn; elseif ( is_object($cn) ) $classname_ .= '_' . get_class($cn); } $classname_ = ltrim($classname_, '_'); $params[0]['before_widget'] = sprintf($params[0]['before_widget'], $id, $classname_); $params = apply_filters( 'dynamic_sidebar_params', $params ); $callback = $wp_registered_widgets[$id]['callback']; if ( is_callable($callback) ) { call_user_func_array($callback, $params); $did_one = true; } } return $did_one; }
Can sbdy help me ?
Merci d'avance
Ludo
Partager