Ivan Zugec

Drupal Consultant

Note

Here are my notes on how to setup Apache Solr for a Drupal site on Linode hosting.

Prepare

Make sure you are up to date.

You'll need to create a custom module and use the hook_form_alter() function.

function example_form_alter(&$form, $form_state, $form_id) {
  $form['taxonomy'][2]['#default_value'] = array(0 => $term->tid);
}

Please note that the $form['taxonomy'][2]['#default_value'] is the vocabulary id.

Version: 

First you'll have to make use of hook_form_alter() function.

function example_form_alter(&$form, $form_state, $form_id) {
  $form['field_example_reference']['#pre_render'] = array('example_change_node_reference');
}

Now the node reference will look for a example_change_node_reference() function which will return an array of options.

function example_change_node_reference($element) {
      $element['nid']['nid']['#options'] = array($node->;nid => $node->title);
  return $element;
 
}

Make sure you pass the $element variable into the function. More info: http://drupal.org/node/339730.

Version: 

How to load a theme region within code:

print theme('blocks', 'example_node');
Version: 

Use the following code to load the comment anywhere:

   if (function_exists('comment_render') && $node->comment) {
       print comment_render($node, $node->cid);
       $node->comment = NULL;
    }
Version: 

Example of how to load just the exposed views filter:

$view = views_get_view('example_views');
      if($view){
        $view->set_display('page_1');
        $view->init_handlers();
        $form_state = array(
          'view' => $view,
          'display' =>; $view->display_handler->display,
          'method' => 'get',
          'rerender' => TRUE,
          'no_redirect' => TRUE,
        );
        $output = drupal_build_form('views_exposed_form', $form_state);
      }else{
        $output = ""; // error messages or something...
      }
 
      print $output;
Version: 

Example of how to embed a view using views:

print views_embed_view('example_views', 'block_1', $arg)
Version: 

How to use imagecache in templates:

theme('imagecache', $preset, $image, $alt);
Version: 

Example of using hook_theme.

/**
 * Implementation of hook_theme().
 */
function example_theme() {
  return array(
    'example_taxonomy' => array(
      'template' => 'example-taxonomy',
      'arguments' => array('node' => NULL, 'options' => NULL),
    ),
    'example_taxonomy_terms' => array(
      'arguments' => array('voc' => NULL, 'node' => NULL, 'options' => NULL),
    ),
    'example_front_page' => array(
      'template' => 'example-front-page',
      'arguments' => array(),
    ),
  );
}
Version: 

Example of using hook_menu.

First create a empty page with no menu item.

function example_menu() {
  $items['page/page'] = array(
    'page callback' => 'example_page',
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK
    );
  return $items;
}
 
function example_page() {
  return 'example page';
}
Version: 
Subscribe to RSS - Note