/**
* Catch the theme_node_form function, and redirect through the template api
* Allows us to customise the fields displayed on the "create content" form
*/
function phptemplate_node_form($form) {
$admin_role_id = 3;
if ((! $user->roles[ $admin_role_id ]) && ($user->uid != 1)) {
// user is not an admin, hide all the advanced fields
// Default Drupal fields
unset($form['attachments']);
unset($form['options']);
unset($form['author']);
unset($form['comment_settings']);
unset($form['revision_information']);
unset($form['menu']);
unset($form['body_field']['format']);
unset($form['path']);
//$form['format']['#title'] = 'Advanced setting: Input format'; // e.g. rename fields
// Ubercart fields
//unset($form['base']); // note: can't submit without this because display price and SKU are required
//unset($form['taxonomy']);
//unset($form['field_image_cache']);
//unset($form['google_checkout']);
// call the original function
return theme_node_form($form);
}
A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.
Jump to
Showing posts with label drupal. Show all posts
Showing posts with label drupal. Show all posts
How to find which function does what in Drupal 6
A forum post describes how to find the right function by hacking a core file.
In Drupal 6, inside the theme() function of /includes/theme.inc, change line 617 from this:
$output = call_user_func_array($info['function'], $args);
To this:
$output = '<!-- begin ' . $info['function'] . ' -->' . call_user_func_array($info['function'], $args) . '<!-- end ' . $info['function'] . ' -->' ;
The advice about not doing this on a production site stands.
Taxonomy menu for Drupal
<?php
$vid = 1; /* <---- put correct vocabulary ID here */
$terms = taxonomy_get_tree($vid);
print "<div class=\"item-list\">";
print "<ul>";
foreach ( $terms as $term ) {
$tcount = taxonomy_term_count_nodes($term->tid);
print "<li>".
l($term->name." (".$tcount.")",'taxonomy/term/'.$term->tid, array('title' => $tcount." posts in ".$term->name)).
"</li>";
} /* end foreach */
print "</ul>";
print "</div>";
?>
$vid = 1; /* <---- put correct vocabulary ID here */
$terms = taxonomy_get_tree($vid);
print "<div class=\"item-list\">";
print "<ul>";
foreach ( $terms as $term ) {
$tcount = taxonomy_term_count_nodes($term->tid);
print "<li>".
l($term->name." (".$tcount.")",'taxonomy/term/'.$term->tid, array('title' => $tcount." posts in ".$term->name)).
"</li>";
} /* end foreach */
print "</ul>";
print "</div>";
?>
How to use PHP snippets in Drupal
Enable the core 'PHP filter' module, then select the PHP filter from the 'input formats' list when creating a page.
Subscribe to:
Posts (Atom)