Category Archives: CMS

Drupal 7 – Field Permissions for Node Title

Previously we talked about how to set the Field Permissions on role level.
Drupal 7 – Set field permission by role using Field Permissions

As i have mentioned, it does not work for the default node title field. One solution is to hide the node title field and set it automatically. This could be achieved by the Automatic Nodetitles.

1. Install the module.

Continue reading Drupal 7 – Field Permissions for Node Title

Drupal 7 – Customize the exposed filter selection list

Yesterday we have talked about how to use selection list for selecting Entity reference in Views exposed filter.
Drupal 7 – Selection list for Entity reference in Views exposed filter

Now i want to have more control on the selection list. For example, i have a content type called competition and i want to limit the number of options in the Entity reference selection list. In this case, we have to create a custom module and alter the views_exposed_form.
Continue reading Drupal 7 – Customize the exposed filter selection list

Drupal 7 – Selection list for Entity reference in Views exposed filter

When you want to set an Entity reference field in Views exposed filter, it only allows free text input filter. But i want to have a selection list instead of a free text input.

Just simply go to the field setting page @ admin/structure/types/manage/<content-type>/fields/<field-name> and check the Render Views filters as select list option. Continue reading Drupal 7 – Selection list for Entity reference in Views exposed filter

Drupal – Disable the default node page

In Drupal 6, the default <front> page has the path /node which will list out the latest nodes. Although we could point the <front> page to another path, the /node page is still accessible.

Create a custom module and add the following piece of code would help redirecting /node page back to the <front> page.

/**
 * Implementation of hook_menu_alter().
 */
function YOUR_MODULE_NAME_menu_alter(&amp;$items) {
  $items['node']['page callback'] = '_internal_custom_function_name_here_redirect_to_frontpage';
}

/**
 * Redirect back to the frontpage for specific pages.
 */
function _internal_custom_function_name_here_redirect_to_frontpage() {
  if($_GET['q'] == 'node') {
    $_REQUEST['destination'] = &quot;&lt;front&gt;&quot;;
    drupal_goto();
  }
}

 

I haven’t tried it in Drupal 7, please let me know if you have any idea.

Done =)

Reference: disable the default node page

Drupal 7 – Update the module schema by hook_update_N()

Recently i start working on BeansTag again as some users request to add the meta robots and canonical options.

This time, the update involves a change in the module schema. In this case, we need to implement the hook_update_N() in .install.

The following piece of code is added to beanstag.install. Continue reading Drupal 7 – Update the module schema by hook_update_N()

Drupal 7 – Get the prev and next node ID using Previous/Next API

For developers, the Flippy module which i mentioned might be not flexible enough.
Drupal 7 – Display Previous and Next node links on node view using Flippy module

Then you could consider another module called Previous/Next API. With this module, you can add the previous and next node links in any preprocess functions, template.php or module files using the API functions provided by this module.

Another advantage is that it caches all the links in its own database table which could speed up the query and this also reduces the database loading. Let’s see how this module work.
Continue reading Drupal 7 – Get the prev and next node ID using Previous/Next API