drupal中可用的全局常量和函数有哪些

发布于 2024-10-05 20:38:41 字数 162 浏览 0 评论 0原文

我是 drupal 的新手,我想了解 drupal 中可用的全局常量和函数,例如 Wordpress 中的全局常量和函数。如果有像 is_home 或 is_page 这样的函数,类似于 wordpress,我可以在我的主题中使用它,那就太酷了。我在我的主题中尝试了 if($is_front) 但它不起作用。

I am new to drupal and i want to know the global constants and functions available in drupal like in Wordpress. It will be cool if there is functions like is_home or is_page, similar to wordpress, which i can use in my theme.I tried if($is_front) in my theme but it is not working.

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

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

发布评论

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

评论(2

才能让你更想念 2024-10-12 20:38:41

请参阅 http://api.drupal.org/api/drupal/globals 获取列表Drupal 中定义的全局变量。除了全局变量之外,各种模板字段中还提供本地变量。例如,在 page.tpl 中.php模板中,定义了变量$is_front。模板文件中可用的变量在模块和主题提供的模板预处理函数中设置(通常在 template.php 中)文件)。

如果您正在研究主题,则应该查看主题指南

See http://api.drupal.org/api/drupal/globals for a list of globals defined in Drupal. In addition to globals variables, local variables are available in the various template fiel. For instance, in the page.tpl.php template, the variable $is_front is defined. Variables available in template files are set in template preprocess functions provided by modules and theme (usually in the template.php file).

If your are working on themes, you should check the Theming Guide.

依 靠 2024-10-12 20:38:41

我知道纸质书不再那么流行了,但是 Pro Drupal Development 对于概述 API 来说非常有价值。

就变量而言:

<?php
print_r(array_keys(get_defined_vars()));
?>

当您在模板文件中时,这是一个重要的开始。

I know paper book aren't terribly popular anymore, but Pro Drupal Development is pretty invaluable for outlining the API.

As far a variables go:

<?php
print_r(array_keys(get_defined_vars()));
?>

is a big start when you are inside a template file.

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