Drupal, php snippets

mostra solo

Notes  

Drupal: hide Log Message textarea in node forms

tags: Drupal   php snippets  
drupal tags: user interaction   phptemplate  

If like me you are not a big fan of the Log Message functionality of Drupal (the one that adds a "Log Message" textarea at the bottom of each node form), then here is a small php snippet override to add to the template.php file of your theme to definitely hide the Message Log:

/**
* Override node form and remove "Log message" textarea
*/
function phptemplate_node_form($form) {
  $form['log']['#access'] = FALSE;
  return drupal_render($form);
}

Make a good use of it ;)

Notes  

Translate Drupal front page (i18n)

tags: Drupal   php snippets  
drupal tags: translations   i18n  
If you're using the i18n module to translate a website's contents, and you need also to have a specific homepage for each language, here are a couple of ways to get it:

if you use a custom PHPTemplate front page (page-front.tpl.php

you can call the node of the translation corresponding to the language actually in use:
Notes  

Drupal: show content only to anonymous / authenticated users

tags: Drupal   php snippets  
drupal tags: users   contents  

Is very easy to show some contents to anonymous AND some other to authenticated users in Drupal. You'll only need to adapt the following few lines of php to output your content:

<?php
global $user;
if (!
$user->uid) { ?>

    <div>anonymous content here</div>
<?php } else { ?>
    <div>authenticated content here</div>
<?php } ?>

Yep, that easy.

Notes  

How to add destination to URL in Drupal

tags: Drupal   php snippets  
drupal tags: navigation   user interaction  

Ever had the need to redirect your users to a certain page after they perform a particular task (ie: after they are invited to register to the site)?

Doing it is simple:

just translate the link in your PHPTemplate content-type file (es: node.tpl.php) from:
http://www.mywebsite.com/user/register

to:

Notes  

Make node $terms (links) point to contents from it's author only

tags: Drupal   php snippets  
drupal tags: categories   users  

Inglese: Come utilizzare i link dei termini ($terms) associati a ciascun nodo di Drupal per navigare altri contenuti dello stesso autore taggati con lo stesso termine?

Notes  

Show different content to anonymous and authenticated users

tags: Drupal   php snippets  
drupal tags: users   contents  

<?php
/**
* The following simple snippet
* displays different information to anonymous/logged in users within a page.
*
* This works with drupal 4.5 and drupal 4.6
*/
global $user;
if (
$user->uid) {
    return
"This message is only visible for logged-in users.";
}
if (!
$user->uid) {
    return
"This message is only visible for not-logged-in users.";
}
?>

Add to calendar
Twitter
Add to Technorati Favorites

Featured:

Archives

September 2010
SunMonTueWedThuFriSat
1234
567891011
12131415161718
19202122232425
2627282930
PureDivs Drupal Themes Conversions
PureDivs Conversione Temi Drupal