Shoaib Nawaz
  • Member for 10 years, 8 months
  • Last seen more than 1 year ago
Send notification e-mail after new content was added
Accepted answer
19 votes

Rules is best for this, it depends on Entity API. Simple download and enable them from Admin -> Modules Now follow Admin -> Configuration -> Workflow -> Rules Click on Add new rule Define name e.g. "...

View answer
How can I get a list of all available entity view modes?
Accepted answer
14 votes

I think you are talking about view modes for entities. $entity_info = entity_get_info('node'); debug(array_keys($entity_info['view modes'])); It would result as array ( 0 => 'full', 1 => '...

View answer
Group nodes by terms
Accepted answer
12 votes

In your view add two fields: - Node title - Taxonomy Term You are right up to here. Now: Set the "Taxonomy Term" field to "Exclude from display" Select your views' format as unformatted list; use "...

View answer
How do I display an entire node content on the front page?
11 votes

Enter your site configuration to set Default front page and set the node path (node/[id]) as path to default front page.

View answer
Adding HTML5 placeholder to all drupal forms
10 votes

Slightly change it to.... function mymodule_form_alter(&$form, &$form_state, $form_id) { foreach ($form as $key => $value) { if ("textfield" == $value["#type"...

View answer
"Allowed memory size" errors on common tasks
Accepted answer
8 votes

Edit your sites/default/settings.php file, and change the line to set the memory limit: ini_set('memory_limit', '100M'); or increase memory_limit in your php.ini file.

View answer
How to render a form in table layout
Accepted answer
8 votes

A little bit tricky function your_form(){ $form = array(); ... $record_ids = array(); foreach($record_set as $record){ $record_ids[$record['id']] = ''; // Collect ids of your record as ...

View answer
Which hook to implement to limit node creation?
Accepted answer
7 votes

Alter the access callback for the menu callback: function custom_module_menu_alter(&$items){ $items['node/add/page']['access callback'] = 'my_custom_access_callback'; // Next line needed ...

View answer
In hook_user_login is there a way to know if this is the first time the user has logged in?
7 votes

Check for $account's access property. It is a timestemp the user logged in previously. It should be other than a valid time stamp in case to be a first time login. function MODULE_user_login(&$...

View answer
Posting to a Drupal Form via HTML page
7 votes

A form directly can not be posted to Drupal. But a general callback can receive post request data and can process it to store it somewhere. For this, a hook_menu entry is required to register a ...

View answer
Display view nodes in lightbox?
Accepted answer
7 votes

I managed in my project by using a custom page template and and an additional get parameter. Template.php: (In active theme directory) function phptemplate_preprocess_page(&$vars){ if( isset(...

View answer
Redirect anonymous user to login page
Accepted answer
6 votes

function MODULE_init(){ global $user; if ($user->uid == 0 && $_GET['q'] == 'node/add/project' ) { drupal_goto('user/login'); } }

View answer
user_save() returns FALSE
Accepted answer
6 votes

UPDATED: If you are going to create new users using user_save() then follow the following syntax. $user = array( 'name' => $userdata['name'], 'mail' => $userdata['mail'], 'init' => ...

View answer
Is it possible to change the "add new comment" text on certain content types?
5 votes

Check the roles/permission grid to restrict certain roles posting comments. hook_node_view_alter(&$build) would help to replace the label with your custom one. e.g. function ...

View answer
Generating <button type="submit"> with the form API
5 votes

To add some custom tag you can use the following snippets: // Drupal 6. $form = array(); // Other elements. $form['custom-form'] = array( '#value' => '<button type="submit" class="...

View answer
When using hook_FORMID_form_alter(), how does one use validation to prevent form submission?
Accepted answer
5 votes

Use form_error($form['delivery_postal_code'], $message) instead of calling drupal_set_message(). OR try form_set_error('delivery_postal_code', $message);

View answer
Taxonomy term as node css class
Accepted answer
5 votes

Edit you node-type.tpl.php for this. <?php foreach($node->taxonomy as $term){ $term_classes[] = $term->name; } ?> And print those classes in your node content wrapper....

View answer
How do I manage the meta tags 'title', 'description' and 'keywords'?
Accepted answer
5 votes

Nodewords module will help in this regard. This module will help to add meta tags on nodes and custom pages as well.

View answer
How to validate node field for minimum length for a custom content type?
Accepted answer
5 votes

hook_form_alter() would alter your node edit form to define a custom validate handler. function custom_module_form_alter(&$form, &$form_state, $form_id){ ... case 'form_id': //applying ...

View answer
Views, path problem
5 votes

Drupal menu system strictly follow the menu paths. According to my experience you do not need to add % sign while defining path. Define your argument by adding an entry from Views UI (Argument ...

View answer
Redirect to a custom page after a node has been added or edited
4 votes

This can be done by setting $form_state['redirect'], for example using one of the following lines. $form_state['redirect'] = "some-internal-path"; $form_state['redirect'] = array($path, $...

View answer
Is there a good way to inspect objects whose type is derived from the EntityDrupalWrapper class?
4 votes

I had been playing with EntityDrupalWrapper objects. debug() usually returns the output that may have prepared by __toString() I iterated EntityDrupalWrapper object using foreach and it helped to ...

View answer
One time login redirect to password change page
Accepted answer
4 votes

hook_form_alter can be used to add a custom redirect rule. Do it in your custom module. function MODULE_form_alter(&$form, &$form_state, $form_id){ if ($form_id == 'user_pass_reset'){ ...

View answer
How to define and use an external database connection in a custom module
4 votes

You will have to add into settings.php located at /sites/default/ in following syntax //Drupal 6 $db_url['default'] = 'mysql://db_user:password@localhost/db_name'; $db_url['external'] = 'mysql://...

View answer
Site in offline mode, any way to debug how this happened?
4 votes

Site offline is a matter of a global variable site_offline set to 1. Any call of variable_set('site_offline', '1') can also result to put site into offline mode. Invalid database configuration can ...

View answer
Webform add data along with submitted values
4 votes

For webform submission it is best to use hook_webform_submission_insert($node, $submission). $submission->data will contain all the submitted values arranged against form components ids. See my ...

View answer
Redirect a user after the node has been saved
Accepted answer
4 votes

In case of Drupal 6 hook_nodeapi() will help to perform on various actions, basing on the value of the first argument passed to the hook ($op). alter delete load update In Drupal 7 there is a ...

View answer
Minimum comment length?
Accepted answer
4 votes

Add a custom validator to form using hook_form_alter in your custom module. function custom_mod_form_alter(&$form, &$form_state, $form_id){ switch($form_id){ case 'comment_form': $...

View answer
Exclude Latest Article From View?
4 votes

You have to create a view with two displays of type block. Arrange some region or panel method to display them in side by side fashion. Create view, select its type as node, choose fields and filters ...

View answer
What's the difference between access arguments and access callback?
4 votes

Access callback is a function that examines if some user has some permissions. The default access callback is user_access() Access arguments lists permission those are examined by access callback. e....

View answer
1
2 3 4 5 6