Hi.
I am Miles Rout, and I'm currently converting a static HTML theme to a drupal theme. I've been wondering about the use of:
<?php print theme('links', $primary_links, array('class' => 'links primary-links')) ?> and <?php print theme('links', $secondary_links, array('class' => 'links secondary-links')) ?>
When I use these, should I need to change my CSS? Do they output the list in a funny way? Why is this using a theme(); function when they could just be <?php print $primary_links ?> or something like that? Or alternatively, why isn't the page_title something like <?php print theme('title', $page_title, array('class' => 'title page-title')) ?> ?
Thanks, Miles
Check template.php for the theme function. It might be inserting CSS for you, or other things.
A
On Tue, Aug 10, 2010 at 11:15 AM, Miles Rout miles.rout@gmail.com wrote:
Hi.
I am Miles Rout, and I'm currently converting a static HTML theme to a drupal theme. I've been wondering about the use of:
<?php print theme('links', $primary_links, array('class' => 'links primary-links')) ?> and <?php print theme('links', $secondary_links,
array('class' => 'links secondary-links')) ?> When I use these, should I need to change my CSS? Do they output the list in a funny way? Why is this using a theme(); function when they could just be <?php print $primary_links ?> or something like that? Or alternatively, why isn't the page_title something like <?php print theme('title', $page_title, array('class' => 'title page-title')) ?> ? Thanks, Miles _______________________________________________ themes mailing list themes@drupal.org http://lists.drupal.org/mailman/listinfo/themes
Hi Miles,
The theme() function outputs code in a way that allows users to override it if necessary. To see how any theme() function works, look it up on http://api.drupal.org (making the first parameter part of the function name). For example: theme('links', ...) would become theme_links(): http://api.drupal.org/api/function/theme_links/6 And theme('image', ...) would become theme_image(): http://api.drupal.org/api/function/theme_image/6
The primary and secondary links are output via a theme function as they're placed into an unordered list (see the code at the above URL). This makes it easy to output the primary or secondary links anywhere in your page template without having to re-write the unordered list each time; but you can always override the theme function in your template.php file if you want to change the unordered list to something else.
Variables such as $page_title aren't output via a theme function as they're just that; variables. They don't have any formatting associated with them, so you have to format them yourself in page.tpl.php, like putting them in H1 tags or whatever. Hope that helps explain it a bit.
On 10/08/10 19:15, Miles Rout wrote:
Hi.
I am Miles Rout, and I'm currently converting a static HTML theme to a drupal theme. I've been wondering about the use of:
<?php print theme('links', $primary_links, array('class' => 'links primary-links')) ?> and <?php print theme('links', $secondary_links,
array('class' => 'links secondary-links')) ?>
When I use these, should I need to change my CSS? Do they output the list in a funny way? Why is this using a theme(); function when they could just be <?php print $primary_links ?> or something like that? Or alternatively, why isn't the page_title something like <?php print theme('title', $page_title, array('class' => 'title page-title')) ?> ?
Thanks, Miles
Thanks, so that means that using theme functions will format your links, etc., if someone has written a function for that? How do you override that? When you're naming the function in the template.php file, do you write nameofmytheme_links or do you just write theme_links? Because when you install modules etc. it warns me that I can't have two functions named the same, which makes me tend to thing that it would be the first option...
Sorry if that doesn't make sense.
On Tue, Aug 10, 2010 at 9:32 PM, Peter Anderson list@panda.id.au wrote:
Hi Miles,
The theme() function outputs code in a way that allows users to override it if necessary. To see how any theme() function works, look it up on http://api.drupal.org (making the first parameter part of the function name). For example: theme('links', ...) would become theme_links(): http://api.drupal.org/api/function/theme_links/6 And theme('image', ...) would become theme_image(): http://api.drupal.org/api/function/theme_image/6
The primary and secondary links are output via a theme function as they're placed into an unordered list (see the code at the above URL). This makes it easy to output the primary or secondary links anywhere in your page template without having to re-write the unordered list each time; but you can always override the theme function in your template.php file if you want to change the unordered list to something else.
Variables such as $page_title aren't output via a theme function as they're just that; variables. They don't have any formatting associated with them, so you have to format them yourself in page.tpl.php, like putting them in H1 tags or whatever. Hope that helps explain it a bit.
On 10/08/10 19:15, Miles Rout wrote:
Hi.
I am Miles Rout, and I'm currently converting a static HTML theme to a drupal theme. I've been wondering about the use of:
<?php print theme('links', $primary_links, array('class' => 'links primary-links')) ?> and <?php print theme('links', $secondary_links,
array('class' => 'links secondary-links')) ?>
When I use these, should I need to change my CSS? Do they output the list in a funny way? Why is this using a theme(); function when they could just be <?php print $primary_links ?> or something like that? Or alternatively, why isn't the page_title something like <?php print theme('title', $page_title, array('class' => 'title page-title')) ?> ?
Thanks, Miles
-- Kind regards, Peter Anderson.http://panda.id.au
themes mailing list themes@drupal.org http://lists.drupal.org/mailman/listinfo/themes
On 08/13/2010 05:55 PM, Miles Rout wrote:
Thanks, so that means that using theme functions will format your links, etc., if someone has written a function for that? How do you override that? When you're naming the function in the template.php file, do you write nameofmytheme_links or do you just write theme_links? Because when you install modules etc. it warns me that I can't have two functions named the same, which makes me tend to thing that it would be the first option...
There are two ways to name the function. The first, and probably safest (for the reasons you already mentioned), is have the first line look like:
function themename_links($links, $attributes = array('class' => 'links'))
The second way that works is a generic call to phptemplate_themes, like so:
function phptemplate_links($links, $attributes = array('class' => 'links'))
Hope that helps, ~~nat