Drupal 6:打印无误的主要链接和所有的孩子 [英] Drupal 6: Printing Unadulterated Primary Links and all children

查看:123
本文介绍了Drupal 6:打印无误的主要链接和所有的孩子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

世界如何可能?我发誓,我已经读了相当于3个百科全书,没有用。我在区域内尝试过解决方案,page.tpl.php和block。他们都没有给我我需要的东西...我知道有很多其他人也需要这个!

How in the WORLD is possible? I swear, I've read the equivalent of 3 encyclopedias to no avail. I've tried solutions within regions, page.tpl.php and blocks. None of them give me what I need... and I know there are so many other people that need this too!

我得出结论,我想要打印出我的page.tpl.php中的菜单...所以没有阻止解决方案,请。

I've come to the conclusion that I want to print out the menu within my page.tpl.php ... so no block solutions, please.

我想要能够循环访问主菜单链接AND children),并重写输出,以便没有默认的Drupal类标记。我找到的最接近的是这个例子:

I want to be able to loop through the primary menu links (AND children) and rewrite the output so that there's no default Drupal class tagging. The closest I've found is this example:

<?php if (is_array($primary_links)) : ?>
<ul id="sliding-navigation">
<?php foreach ($primary_links as $link): ?>
<li class="sliding-element"><?php        
        $href = $link['href'] == "<front>" ? base_path() : base_path() . drupal_get_path_alias($link['href']);
        print "<a href='" . $href . "'>" . $link['title'] . "</a>";            
        ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>

正如你所看到的,链接正在重新打印一个自定义UL和LI类...这是伟大的!但是,没有孩子被印刷。我如何扩展这个代码,以便所有的孩子都是列表的一部分?注意:我不想让孩子只出现在他们的父母页面上,他们必须一直在场。否则,我计划的下拉菜单是无用的。

As you can see, links are being reprinted with a custom UL and LI class ... that's GREAT! However, no children are being printed. How would I extend this code so that all children are a part of the list? NOTE: I don't want the children to only appear on their parent page, they must be present all the time. Otherwise, the drop-down menu I have planned is useless.

我真诚地感谢您提前减少我的巨大头痛!

I sincerely thank you in advance to lessening my gargantuan headache!

推荐答案

一旦达到page.tpl就很难影响输出 - 你可能会更好地寻找template.php函数。

It's hard to affect the output once it's got as far as the page.tpl - you might do better looking for template.php functions.

这是我用来修改主链接的类的一个:

This is one I used to alter the classes of my primary links:

function primary_links_add_icons() {
  $links = menu_primary_links();
  $level_tmp = explode('-', key($links));
  $level = $level_tmp[0];
  $output = "<ul class=\"links-$level\">\n";   
  if ($links) {
    foreach ($links as $link) {
        $link = l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment']);
        $output .= '<li class="sublevel">' . $link .'</li>';
    };
    $output .= '</ul>';
  }
  return $output;
}

然后在page.tpl.php中,我就像这样调用: / p>

And then in page.tpl.php I just called it like this:

<?php if ($primary_links) :?>
    <?php print '<div id="menu">'; ?>
    <?php print primary_links_add_icons(); ?>
    <?php print '</div>'; ?>
<?php endif;?> 

这篇关于Drupal 6:打印无误的主要链接和所有的孩子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆