Drupal 7

User login

Drupal 7: Reset User 1 Password quick and easy using Drush

There are many solutions out there to reset User 1's password in a Drupal 7 website. A really convenient way is to use Drush, to generate a one time login URL - no mails involved. The output would be directly on the console, and it is simple to just copy and paste it in a browser. 
The drush command is the following:
 
drush php-eval 'echo user_pass_reset_url(user_load(1));
 
and once logged in, the password can be easily changed in the user edit screen. 

Drupal 7: How to remove "More information about formatting options" link

The code below goes in your template.php and removes the "More information about formatting options" link.

<?php
/**
 * Remove the comment filters' tips
 */
function MyThemeName_filter_tips($tips, $long = FALSE, $extra = '') {
  return
'';
}
/**
 * Remove the comment filter's more information tips link
 */
function MyThemeName_filter_tips_more_info () {
  return
'';
}
?>

Please remember to clear the cache in order for the changes to trigger.

Drupal 7: Hide a field depending on the value of a checkbox

I recently had the requirement to hide a horizontal tab in node display depending on the value of a checkbox i.e. Show tab X. For the horizontal tabs I was using the excellent Fieldgroup module.

In order to achieve the above, I created a little custom module and used the newly introduced in drupal 7 hook, hook_node_view_alter.

blog:

Drupal 7: Add a custom link in admin menu

Here is some code to be used in a custom module in Drupal 7 in order to create a custom link in the admin menu. This item will show up in the Configuration section and it is particularly useful with the administration menu module.

blog:

Remove duplicate entries from views results... the hard way.

In some cases it is seems impossible to get rid of the duplicate entries that views return in the output.
Not an elegant way, but this small module would do the trick...

So let's create a module the usual way, and put the following code in the .module file.
This one is called remove_duplicates.


<?php
function <MY_MODULE>_views_pre_render(&$view)
{
 
$used_nids = array();

          foreach (
$view->result as $row)
      {
        if (!
in_array($row->nid, $used_nids))
        {
         
$new_view_result[] = $row;
         
$used_nids[] = $row->nid;
        }
?>

Pages

Subscribe to Drupal 7