سؤال

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.

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top