Session 3 E: For Developers: theme able functions and the views module

Events happening in the community are now at Drupal community events on www.drupal.org.
Petrina's picture
Start: 
2006-06-28 16:00 - 17:30 Etc/GMT

Learn all about themable functions, the views module and the crazy things you can do in the theme layer to make your site super cool.

Comments

theme_breadcrumb

cathycracks's picture

about theme_breadcrumb
http://api.drupal.org/api/HEAD/function/theme_breadcrumb

in template.php file

function phptemplate_breadcrumb($breadcrumb) {
return _phptemplate_callback('breadcrumb', array('breadycrumb' => $breadcrumb));
}

in breadcrumb.tpl.php file

<?php
  
if(!empty($breadcrumb)){
$output .= '<div class="breadcrumb">'. implode('  » ', $breadcrumb) .'</div>';
}
?>

//basic print
<?php print $output; ?>
//print short form
<?= $output ?>

the implode is putting the array into a string.
Yes, you can change the weird character " »", which is the separator drupal uses in its original breadcrumb.

slight modification of breadcrumb.tpl.php

ngstigator's picture

I got it to work after switching the parameters in the implode call.

<div class="breadcrumb">
<?php
 
print implode($breadcrumb, ' | ');
?>

</div>

theme_user_profile

cathycracks's picture

about them_user_profile
http://api.drupal.org/api/HEAD/function/theme_user_profile

<div class="profile">
    <?= $account->name ?>
<?= theme('user_picture', $account) ?>
</div>

for permissions:
in user_profile.tpl.php

<?php
  
global $user;
  if(
$user->uid > 0){
 
//
}
?>

(user id 0 is always the anonymous user)

<?php
global $user;
  if(
user_access('')) {
   
//
}
 
$result = db_query("SELECT n.nid FROM { node} n WHERE n.uid = $d n.type='BLOG' AND n.status = 1 ORDER BY n.created DESC", $account->uid);
   if(
db_num_rows($result) > 0) {
  while (
$row = db_fetch_object($result)) {
     
$blog .= node_view(node_load(array('nid' => $row->nid)), true);
        }
  }
?>

In case you are wondering

cathycracks's picture

the software steve uses to code is zend.
http://www.zend.com/products/zend_studio

theme_user_list

cathycracks's picture

about theme_user_list
http://api.drupal.org/api/HEAD/function/theme_user_list
Basically the profile listing page
A good example of that: http://www.askaninja.com/profile
(By default it shows a list of user names)

if you look at list reference on http://api.drupal.org, you will find out about where the functions are used. (only on core modules)

Drupal Camp Seattle

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: