Need help with this theming code snippet

TWD - July 3, 2009 - 04:14

Hello

Bit of a newb still.
I'm confused about the last two lines of this function:

$image = theme('image', $image_path, $image_text, $image_text);
$variables['go_home'] = l($image, "<front>", array('html'=> TRUE));

Is "theme" some kind of inbuild Drupal function?
and what does the "l" function in the last line do?
and why does it use a nameless array as the last parameter?

Here is the complete code.


function bolg_preprocess_page (&$variables) {
// Add a "go home" button to page.tpl.php
if ($variables['logged_in'] == TRUE && $variables['is_front'] == FALSE) {
$image_path = $variables['directory'] . "/images/go_home.jpg";
$image_text = t("Go home!");
$image = theme('image', $image_path, $image_text, $image_text);
$variables['go_home'] = l($image, "", array('html'=> TRUE));
}
} // End of the preprocess_page function

theme() is a Drupal function

nevets - July 3, 2009 - 04:23

theme() is a Drupal function used for calling theme "functions" which can be an actual function or template file (*.tpl.php), see: http://api.drupal.org/api/function/theme/6

The l() function builds links, see: http://api.drupal.org/api/function/l/6

Actually I have answered part

TWD - July 3, 2009 - 04:38

Actually I have answered part of my own question, I think.

The "l" function is a Drupal function for building links that takes the parameters
$text, //the visible rendered portion of the link
$path, //the hyperlink itself
$options = array()
where $options could contain
* 'attributes' An associative array of HTML attributes to apply to the anchor tag.
* 'query' A query string to append to the link, or an array of query key/value properties.
* 'fragment' A fragment identifier (named anchor) to append to the link. Do not include the '#' character.
* 'absolute' (default FALSE) Whether to force the output to be an absolute link (beginning with http:). Useful for links that will be displayed outside the site, such as in an RSS feed.
* 'html' (default FALSE) Whether the title is HTML, or just plain-text. For example for making an image a link, this must be set to TRUE, or else you will see the escaped HTML.
* 'alias' (default FALSE) Whether the given path is an alias already.
Source: http://www.group42.ca/creating_links_aka_anchor_tags_the_l_function
and http://api.drupal.org/api/function/l/6

Edit: thanks Nevits

 
 

Drupal is a registered trademark of Dries Buytaert.