drupal 6:node.tpl.php $links 变量,在哪里配置内容?

发布于 2024-10-15 09:56:32 字数 86 浏览 3 评论 0原文

我需要定义 $links 输出的顺序 现在我有 2 个模块显示其内容: 评论并添加此 我在哪里可以定义节点的顺序并修改它的节点设置... 甚至定制一点显示?

I need to define the order of the $links output
now I have 2 modules displaying its contents on that:
comments and addthis
where can I define the order of the and modify it's settings for nodes...
even customize a little bit the display?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

掩于岁月 2024-10-22 09:56:32

编辑:可以使用 http://drupal.org/project/linkweights< 更改链接权重/a>

我不确定是否有任何类型的 UI 用于重新排序/自定义节点链接。
不过,您可以通过以下几种方式来完成此操作:

创建一个实现 hook_link_alter() 的自定义模块并执行自定义。

/**
 * hook_link_alter() implementation
 * for more details see 
 * http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_link/6
 * http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_link_alter/6
 */
function mymodule_link_alter(&$links, $node) {
  foreach ($links as $link => $values) {
    // do something with $link

  }
return $links;
}

您可以更进一步,创建一个管理页面,该页面将获取所有链接,将它们输出到可排序的表(如 /admin/build/block)中,并将顺序保存在变量中。啊,您的模块需要具有最高的权重才能捕获所有其他链接。

--或者--

修改主题的 template.php 并添加 mytheme_preprocess_node() 函数,或者编辑它或 phptemplate_preprocess_node() (如果存在)

function phptemplate_preprocess_node(&$vars) {
  $links= $vars['node']->links;
  // uncomment the next line to see the current links
  //var_dump($links);

  // add a new link
  $link_all = array(
    'title' => 'See all nodes',
    'href' => PATH,
    //'attributes' => array('class' => 'link_class', 'id' => 'link_id', 'title' => 'link title'),
  );
  $links['link_all'] = $link_all;

  //Modify an existing link. in this case the above added one
  $links['link_all']['title'] = t('This is my custom text');

  $vars['links'] = theme_links($links);
}

要重新排序,请参阅 http://drupal.org/node/44435#comment-861385

Edit: links weights can be changed using http://drupal.org/project/linkweights

I am not sure there is any kind of UI for reordering/customizing the node links.
However you can accomplish this in a couple of ways:

Create a custom module that implements hook_link_alter() and perform the customizations.

/**
 * hook_link_alter() implementation
 * for more details see 
 * http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_link/6
 * http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_link_alter/6
 */
function mymodule_link_alter(&$links, $node) {
  foreach ($links as $link => $values) {
    // do something with $link

  }
return $links;
}

You can go even further and create an administration page that will get all the links, output them in a sortable table (a la /admin/build/block) and save the order in a variable. Ah, your module needs to have the highest weight in order to catch all the other links.

--OR--

Modify your theme's template.php and add the mytheme_preprocess_node() function or edit it or phptemplate_preprocess_node() if it exists

function phptemplate_preprocess_node(&$vars) {
  $links= $vars['node']->links;
  // uncomment the next line to see the current links
  //var_dump($links);

  // add a new link
  $link_all = array(
    'title' => 'See all nodes',
    'href' => PATH,
    //'attributes' => array('class' => 'link_class', 'id' => 'link_id', 'title' => 'link title'),
  );
  $links['link_all'] = $link_all;

  //Modify an existing link. in this case the above added one
  $links['link_all']['title'] = t('This is my custom text');

  $vars['links'] = theme_links($links);
}

To reorder see http://drupal.org/node/44435#comment-861385

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文