Ticket #1189: dropdown_pages.diff
File dropdown_pages.diff, 3.5 KB (added by , 20 years ago) |
---|
-
template-functions-post.php
311 311 if (!isset($r['depth'])) $r['depth'] = 0; 312 312 if (!isset($r['show_date'])) $r['show_date'] = ''; 313 313 if (!isset($r['child_of'])) $r['child_of'] = 0; 314 if ( !isset($r['title_li']) ) $r['title_li'] = __('Pages'); 314 if (!isset($r['title_li']) ) $r['title_li'] = __('Pages'); 315 if (!isset($r['style'])) $r['style'] = 'list'; 315 316 316 317 317 // Query pages. 318 318 $pages = & get_pages($args); 319 319 if ( $pages ) : 320 320 321 if ( $r['title_li'] )321 if ( $r['title_li'] && 'list' == $r['style'] ) 322 322 echo '<li id="pagenav">' . $r['title_li'] . '<ul>'; 323 else 324 echo "<select name='page_id'>\n"; 325 323 326 // Now loop over all pages that were selected 324 327 $page_tree = Array(); 325 328 foreach($pages as $page) { … … 350 353 // Output of the pages starting with child_of as the root ID. 351 354 // child_of defaults to 0 if not supplied in the query. 352 355 _page_level_out($r['child_of'],$page_tree, $r); 353 if ( $r['title_li'] )356 if ( $r['title_li'] && 'list' == $r['style'] ) 354 357 echo '</ul></li>'; 358 else 359 echo "</select>\n"; 355 360 endif; 356 361 } 357 362 … … 360 365 361 366 $queried_obj = $wp_query->get_queried_object(); 362 367 363 if ($depth)368 if ($depth) { 364 369 $indent = str_repeat("\t", $depth); 365 //$indent = join('', array_fill(0,$depth,"\t")); 370 $pad = str_repeat(' ', $depth * 3); 371 } 366 372 367 373 foreach($page_tree[$parent]['children'] as $page_id) { 368 374 $cur_page = $page_tree[$page_id]; 369 375 $title = $cur_page['title']; 370 376 371 $css_class = 'page_item'; 372 if( $page_id == $queried_obj->ID) { 373 $css_class .= ' current_page_item'; 374 } 375 376 echo $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page_id) . '" title="' . wp_specialchars($title) . '">' . $title . '</a>'; 377 378 if(isset($cur_page['ts'])) { 379 $format = get_settings('date_format'); 377 if ('list' == $args['style']) { 378 $css_class = 'page_item'; 379 if( $page_id == $queried_obj->ID) { 380 $css_class .= ' current_page_item'; 381 } 382 383 echo $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page_id) . '" title="' . wp_specialchars($title) . '">' . $title . '</a>'; 384 385 if(isset($cur_page['ts'])) { 386 $format = get_settings('date_format'); 380 387 if(isset($args['date_format'])) 381 388 $format = $args['date_format']; 382 389 echo " " . mysql2date($format,$cur_page['ts']); 383 }384 echo "\n";385 386 if(isset($cur_page['children']) && is_array($cur_page['children'])) {387 $new_depth = $depth + 1;388 389 if(!$args['depth'] || $depth < ($args['depth']-1)) {390 echo "$indent<ul>\n";391 _page_level_out($page_id,$page_tree, $args, $new_depth);392 echo "$indent</ul>\n";393 390 } 391 echo "\n"; 392 393 if(isset($cur_page['children']) && is_array($cur_page['children'])) { 394 $new_depth = $depth + 1; 395 396 if(!$args['depth'] || $depth < ($args['depth']-1)) { 397 echo "$indent<ul>\n"; 398 _page_level_out($page_id, $page_tree, $args, $new_depth); 399 echo "$indent</ul>\n"; 400 } 401 } 402 echo "$indent</li>\n"; 403 } elseif ('dropdown' == $args['style']) { 404 echo "\t<option value=\"".$page_id."\""; 405 if ($page_id == $queried_obj->ID) 406 echo ' selected="selected"'; 407 echo '>'; 408 echo "$pad$title"; 409 echo "</option>\n"; 410 if(isset($cur_page['children']) && is_array($cur_page['children'])) { 411 $new_depth = $depth + 1; 412 _page_level_out($page_id, $page_tree, $args, $new_depth); 413 } 394 414 } 395 echo "$indent</li>\n";396 415 } 397 416 } 398 417