Checking if content field is empty in node template

Here is a little Bolean logic fun

empty function

http://php.net/manual/en/function.empty.php

If the variable is empty it returns FALSE

means you have to think backwards

<?php if (empty($content['field_test'])): ?>

This field is empty

<?php endif; ?>

<?php if (!empty($content['field_test'])): ?>

This filed is not empty

<?php endif; ?>

<?php if (!empty($content['field_test'])): ?>

Theming Views Slideshow

Slideshows are common on websites today

Drupal use Views Slideshow

/modules/views_slideshow/theme

find the theme files in

here you can theme the pages , controls or slideshow itslef

we will be using

views-slideshow.tpl.php


<?php

/**
* @file
* Views Slideshow: Single Frame template file.
*/
?>

">
<?php if (isset($top_widget_rendered)): ?>

<?php print $top_widget_rendered; ?>

<?php endif; ?>

Drupal Development: Adding No Index Meta Tags for Node Comments

Problem: Drupal displays duplicate content for nodes when there are comments on the page.

Based on the urls, I first investigated Drupal arguments to see if the string comment was present.

print arg(0);
print arg(1);

Where is your website really hosted?

I was helping an associate pick a VPS managed hosting company and decided to do some checking. I, of course always recommend Hostgator but wanted to be thorough. I am aware that reselling hosting packages is a legitimate business and ofter can provide a layer of service beyond what managed hosting provides. I am also fully aware dedicated servers can be leased from larger companies and full service managed hosting can be sold from this. After all every site is hosted by someone. I am not knocking great companies like liquid Web and Media Temple.

Creating a Related Content Block based on Single Taxonomy Term

1. First create a block view with at least the Content Title field. This is the default in Views. Add more fields if necessary.

2. Configure basic Filter Criteria like Content: Published and Content: Type.

3. Click the Advanced link to bring up Advanced configuration options for views.

4. Add a Contextual Filter. These used to be called arguments in views. This is how we will related the current content with other content on the site.

5. Choose contextual filter: Content: Has taxonomy term ID

Creating a Related Content Block based on Node Title and Search module.

Having a related or similar content block can greatly enhance user experience on a website. It can increase a visitors time on site, page views and decrease bounce rates. There are several modules already released that attempt to tackle this but I wanted to roll my own using Views . I will walk you through an example and then share views contextual filter arguments for customization.

Redirecting User by Role on Login

Even though there is a module to redirect users on login, the configuration is confusing at best, and I have found a simple helper module to be much easier.

In Drupal 6, I used this code to redirect the forum moderators at MyChemistryTutor.com to a dashboard page and everyone else to the forum page.

embedding views

views_embed_view($name, $display_id = 'default')

<?php
$block = module_invoke('block', 'block_view', 26);
print render($block);
?>

$block = block_load('views', 'block_name');
$output = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));
print $output;

For Drupal 7 :

$block = module_invoke('block', 'block_view', 30);

@arg 1 : module name
@arg 2 : hook name like block_view, block_info
@arg 3 : id or delta of the block e.g 30, map-block_1

Theming nodes in Drupal 7

Since I have upgraded my sites to Drupal 7 I need to make sure I know how to theme my nodes. You will notice a good many Drupal 7 themes do not include the node.tpl.php file. There apparantly is a default in Drupal 7. You can find it in the Drupal api ( http://api.drupal.org/api/drupal/modules--node--node.tpl.php/7/source ) Here is the code if you need it.

Basically to customize the default node theme you make a php file in your favorite editor and save it as node.tpl.php.

Pages