Skip to main content

drupal

Drupal Ubercart get add to cart form

Posted in

  1. $output .= drupal_get_form('uc_product_add_to_cart_form_'. $node->nid, $node);

How to change / remove Views2 exposed button from Drupal

Posted in

Add this to your template.php file.

  1. function YOUR_THEME_NAME_preprocess_views_exposed_form(&$vars, $hook) { //this is important
  2.  
  3.   // only alter the required form based on id
  4.   if ($vars['form']['#id'] == 'views-exposed-form-where-to-buy-page-1') {
  5.  
  6.     // Change the text on the submit button
  7.     $vars['form']['submit']['#value'] = t('Search');
  8.  
  9.     // Rebuild the rendered version (submit button, rest remains unchanged)
  10.     unset($vars['form']['submit']['#printed']);
  11.     $vars['button'] = drupal_render($vars['form']['submit']);
  12.   }
  13. }

Drupal 6 Custom content type page theme

If you ever wondered how to change the page.tpl.php for a custom content type you've found out that by default Drupal 6 doesn't know how to do it.

It's "fixed" easily by adding the following code:

  1. /**
  2.  * Override or insert PHPTemplate variables into the templates.
  3.  */
  4. function phptemplate_preprocess_page(&$vars) {
  5.   // Add per content type pages
  6.   if (isset($vars['node'])) {
  7.     // Add template naming suggestion. It should alway use hyphens.
  8.     // If node type is "custom_news", it will pickup "page-custom-news.tpl.php".

Custom Drupal 6 frontend page

Posted in

If you want to customise your frontend page in Drupal 6 copy your existing page.tpl.php into page-front.tpl.php and do the customisations there.

Drupal body value in views template

If you're creating a view and using a custom node type for that view and don't understand why your $body variable doesn't work to display the content of the node it's because the shortcodes aren't loaded in a view template so you must use $node->content['body']['#value']

Drupal block cloning

I'm working on a website built with drupal and I ran into pretty nasty drupal 6 limitation.
You can't clone a module / have multiple instances in a default install, so after some searching I've found this nifty drupal module called MultiBlock that allows you to do exactly that.

If you need more help on the topic feel free to add a comment or create a new post on the Forum

Syndicate content