menu, breadcrumbs, links, page and node template... how?

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
reibian's picture

また、クダラナイ質問かも知れません。オックスファムのサイト、Drupal 5.x で運営してるみたいですが、 http://oxfam.org のメニューと残パンの作り方に感心しています。例えば、"About Us" をクリックするとそのメニューにバックグランドのイメージを変える事によりそれを焦点とし、残パンもそれに従っている。その "About Us" の中の真中のリンクにクリックしても、メニューの焦点は、変わらず、また残パンも一致している。これは、node template を使って、それとも page template で出来る事でしょうか?
また、6.x で残パンが思うようにならないので、検索し下記のコードを template.php に入れてみましたが、思った通りには出来ません。やはりノードか、ページで振り分けるのでしょうか?

宜しくお願い致します。

My apologies if, again, I am asking a "dah" question here. I am rather impressed with Oxfam's website, looked to be done in 5.x, http://oxfam.org, the way the breadcrumbs and the menu work. For instance, if "About Us" is clicked, it is focused by the use of different background image and the breadcrumbs follow. Going further "down" in "About Us" the menu still is "lit up" and the breadcrumbs follow. Is this accomplished by having, either different page template, or note template, you think? Also, I couldn't get the breadcrumbs to work in 6.x so I did a bit of search and found the following code online to put it in the "template.php" but no desired "effect." Do I need to use different "node" or "page" templates to do this, you think?

Please let me know. (Thanks in advance)

function phptemplate_breadcrumb($breadcrumb) {
        $uri_request_id = $SERVER['REQUEST_URI'];
        $urlexplode = explode("?", $uri_request_id);
        $url = explode("/",$urlexplode[0]);
        $args = count($url);

        $output =  " home";
        $path = '';
        $replace = array('
','-','+','%20');

        // If there is more than one directory or page after home print it
        if(isset($url[1]) && $args > 1){
                for($x = 1; $x < $args; $x++) {
                        $text = htmlspecialchars(str_replace($replace,' ',$url[$x]));
                        if($x < ($args-1)) {
                                $path .= '/' . urlencode($url[$x]);
                                $output .= " > <a href=\"" . $path . "\">" . $text  . "</a>";
                        } else {
                                $output .= " > " . $text;
                        }
                }
        }
        return '<div id="breadcrumb">' . $output . '</div>';
}

Comments

同じHTMLの例です

kyk's picture

oxfamでは、OrderedListをCSS使ってインラインで表示しているようです。セパレーターの">"もCSSのbackgroundImageですね。
全く同じHTMLを出力するには以下のようになるかと思われます。

<?php
function phptemplate_breadcrumb($breadcrumb) {
 
$title = drupal_get_title();
 
$breadcrumb = array_filter(array_merge(
    array(
'You are Here:'),
   
$breadcrumb,
    array(
drupal_is_front_page() ? NULL : l($title, $_GET['q'])),
    array(
$title ? $title : t('Home'))
  ));
 
 
$output = "<div class=\"breacrumb\"><ol>\n";
  foreach (
$breadcrumb as $key => $val) {
    if (
$key == count($breadcrumb) -1) {
     
$output .= '<li class="selected">'. $val;
    }
    else {
     
$output .= '<li>'. $val;
    }
   
$output .= "</li>\n";
  }
 
$output .= "</ol></div>\n";
  return
$output;
}
?>

末端のcssクラスが必要なければ、10行ほどお得になります :)

<?php
return '<div id="breadcrumlb"><ol><li>'. implode('</li><li>', $breadcrumb) .'</li></ol></div>';
?>

訂正。

返信有難う御座いました。

reibian's picture

ARRAYS! 'n tertiaries...
manual を見ながら解読中です。(笑) 勉強してます。

有難う御座います。

Easier way for breadcrumbs

Dokuro's picture

There is an easier way to do this:

http://drupal.org/project/custom_breadcrumbs

This module really has come a long ways in the past year. It now can be used with Taxonomy/pathauto/content types and more. Really great module for breadcrumbs.