User login

template

Why are twig template comparisons such annoying strings?

A boolean field told in display settings to show as zero or one is actually rendered like this:

" 0 "
" 1 "

That is, a string of the number with a space on either side. Why?

That is from testing using {% set lightbox_class = content.field_lightbox|render %}

At least this works:

{% set lightbox_class = content.field_lightbox|render|trim == 1 ? ' lightbox' %}

So does:

{% set lightbox_class = content.field_lightbox|render|trim ? ' lightbox' %}

Inline Read More links for teasers when output as one of several fields in a View with a row style of field

http://drupal.org/node/287812#comment-939923

See also:

displaying read more in teaser view list
http://drupal.org/node/513168

I did this with a crazy use of calling ed_readmore functions in template.php for a views template preprocess function. Do not attempt by trial and error, i can get the code from openmedia's repository.

Remove page headline for a given content type

To remove the page title (the one that prints in the page itself, not in the browser bar) for a specific node type, use this simple code in your template_preprocess_page() function.

Make sure you wrap the code that outputs the header in page.tpl.php in a conditional if statement, so that if there is no title it does not output the <h1></h1> tags.

This code goes in template.php of a theme named "example":

Load a node for a template file- in exactly the same way a node object is presented to a theme

Motivation for this function: sure, we could use a plain node_load($nid) and wrap every $node->field['0']['value'] in a check_plain or the function for rendering with the proper input format (check_plain). The proper format is available to be grabbed from the data provided by a regular node_load. But that's a lot of work and not the way we're used to theming things in .tpl.php

Syndicate content