$language object
and
$view_mode don't exist (anymore ?!!)

to get language string you need to do
$build["#language"];

and for view_mode you need
$build["#view_mode"]

and to get the $node object you need
$build["#node"]

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

GiorgosK’s picture

Title: document variables available in simplenews-newsletter-body.tpl.php » document variables available in simplenews-newsletter-body.tpl.php + footer.tpl.php
Category: task » feature

footer only contains
$format
$key
$language (string not object)
$test_message
$unsubscribe test

it would be nice to have the $build object just like in the body template

but at least the $variables have to be documented correctly inside the .php files

Berdir’s picture

Patches are welcome :)

Most changes are probably just due to underlying core changes, $build is simply whatever has been returned by node_view().

And it should be available in the footer as well.

GiorgosK’s picture

I will provide patches
but the footer does not get the $build object (I checked with netbeans debugger)
please check again that build gets included

Olivier.b’s picture

I'm looking for the node url or the node id variable. How can i insert one of those in simplenews-newsletter-body.tpl.php ?

GiorgosK’s picture

#4
next time open up a separate support request

print $build["#node"]->id;
print $build["#node"]->path; 

should do it

Olivier.b’s picture

#5
It doesn't work. This cause an error : "Notice : Undefined property: stdClass::$id in include()..."

I also tried

print render($build["#node"]->id); 
print render($build["#node"]->path); 

it just render an empty string.

Sorry if it's not the place to post this request i thought the subject of this issue was relevant for me because i just need documentation about "variables available in simplenews-newsletter-body.tpl.php"

GiorgosK’s picture

;-)
well you are almost correct about the title

do a

print_r($build);
or 
print_r($build["#node"]);

to see what you have available in the body.tpl.php
footer.tpl.php has less variables available

Berdir’s picture

I am positive that $build is there for the footer, it's used in the preprocess function.

  // Add specific suggestions that can override the default implementation.
  $variables['theme_hook_suggestions'] = array(
    'simplenews_newsletter_footer__' . $variables['category']->tid,
    'simplenews_newsletter_footer__' . $variables['build']['#view_mode'],
    'simplenews_newsletter_footer__' . $variables['category']->tid . '__' . $variables['build']['#view_mode'],
  );

Also, when you create a patch, you can probably remove the theme() functions for body/footer, they seem to be old and are obviously never used.

miro_dietiker’s picture

Related to
#374222: Template files do not work when using admin theme

There's happening a lot of cleanup.

Berdir’s picture

Category: feature » task
Status: Active » Needs review
FileSize
3.66 KB

The patch adds back $language and $view_mode for the body template and updates the existing documentation.

Status: Needs review » Needs work

The last submitted patch, improve_template_documentation.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
3.68 KB

This one should pass.

Berdir’s picture

Status: Needs review » Fixed

Commited.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.