Skip to main content

Posts

Drupal 7 Field collection on new node creation

Use $node = new StdClass(); to create the node through program. Or Example for creating node through program After node_save($node), You will get the 'nid' of created node $nid = $node->nid; Then again you load the created node from above nid $node_loaded = node_load($node->nid); then create the field collection as, $node = new StdClass();  $node ->-----// node values.....  node_save($node);  nid = $node-nid;// after saving the new it will return the nid in $node->nid in Drupal 7  node_loaded = node_load($nid);  $field_collection_item = entity_create('field_collection_item',array('field_name' => 'field_event_conference')); // fied_name  in the node manage fields $field_collection_item->setHostEntity('node', $node_loaded); $field_collection_item->field_fc_company[LANGUAGE_NONE]['0']['value'] = $company; $field_collection_item->save(); Field collection contains another f...

Drupal 7 apache solr custom query [apache_solr_drupal_query()]

/**  * custom SOLR search function.  */ function search_SOLR($keyword) {   $solr = apachesolr_get_solr();   $query = apachesolr_drupal_query("custom", array('q' => $keyword));   $query->addParam('rows', '1000'); // How many rows of result to display default it is 10.   $query->addFilter('bundle', (event OR city OR company));   $query->removeFilter('bundle');   $query->addParam('fq', "bundle:(event OR city OR company)");   $resp = $query->search();    // Only search in title   $query->replaceParam('qf', 'label');   $resp_ = $query->search(); }

Drupal 7 hook_menu with tab

The following code is the example of hook_menu with tabs /**  * Implements hook_menu().  */ function eventstab_menu() {   $items['my-events'] = array(     'title' => 'My events',     'menu_name' => 'main-menu',     'type' => MENU_CALLBACK,     'page callback' => 'drupal_get_form',     'page arguments' => array('my_events'),     'access arguments' => array('access my events page'),   );   $items['my-events/technology'] = array(     'title' => 'Technology',     'type' => MENU_DEFAULT_LOCAL_TASK,     'page callback' => 'drupal_get_form',     'page arguments' => array('my_events_technology'),     'weight' => -10   );   $items['my-events/business'] = array(     'title' => 'Business',     'type' => MENU_LOCAL_TASK,     'page callb...

Drupal Views exposed filter of Node title as drop down.

It can be done through using "Jump menu" settings in views. Download the Ctools module  http://drupal.org/project/ctools  Enable the Chaos Tools Module. This module provides a Views Style Plugin called "Jump Menu" Create a view of type node with two fields Content:nid and Cotent:title. And the path of the views page is like 'my_node_list'. For the Content:nid make sure you click on  Rewrite the output of the field . The rewritten output of the field should be  my_node_list/[nid]. Make sure you select the  exclude from display  checkbox. In the settings for  Style  in the view, select the  Jump Menu  style. Click on the settings for the style. Make sure the  Path  dropdown has 'Content:nid' choosen. Add a block display to the view. Name the block "Node details" and put the contextual filter to filter with nid. Save the view Go to block configuration under structure and configure the above block (Node details)....

Drupal 7 - Views bread crumb module

There is no module which entirely support to give the bread crumbs on the views pages. So I created one module and tried to contribute to the community which contributed a lot to my carrier. I end up to merge my code with the other contributed modules which provides the breadcrumbs. Here is my sandbox project page:-  https://drupal.org/sandbox/rakeshjames/2049937 1)   views_breadcrumb.info  name = Views breadcrumb description =  Setting bread crumbs for all the view's pages. dependencies[] = views core = "7.x" configure = admin/structure/block/manage/views_breadcrumb/views_breadcrumb_block/configure 2)   views_breadcrumb.module  <?php /**  * @file  * This module will provide a block that will helps to set the bread crumb  * for views pages.  */ /**  * Implements hook_block_info().  */ function views_breadcrumb_block_info() {   $blocks['views_breadcrumb_block'] = array(     'info' =...