Drupal: .htaccess Access Deny
August 21, 2014 – 7:59 am | No Comment

In this article I will tell how to forbid access to certain resources for some clients. The instructions will include descriptions of different directives.

Read the full story »
CSS Templates

Contain reviews and news about CSS Templates.

Freebies

Contain freebies such as icons, graphics, headers and images for your websites.

Fun Stuff

Contains other fun stuff for entertainment or interesting site showcase.

How-To

Contain technical elaborations on some specific workarounds or common tweak.

Joomla Templates

Contains reviews and news about Joomla templates.

Home » How-To

Drupal: How to Show Nodes with the Same Tag

Submitted by on October 25, 2010 – 5:44 amNo Comment

It is necessary to show titles of articles with the same tags as in current document in the block.

Solutions

  • Use snippet
  • Use Taxonomy Quick Find module
  • Use Related Nodes

Use snippet

This is an approximate code which should be adjusted for a specified case:

<?php
//v.5
/*
Links are opened in a new window
If there is only 1 advertisement, 1 advertisement is shown (instead of the same advertisement shown 3 times)
*/
unset ($output);
$nmbr_adv=3;//Number of advertisement messages
if (arg(0) == ‘node’ && is_numeric(arg(1)) && ! arg(2) ) {
$node = node_load(arg(1));
$sql_cond=”;
foreach($node->taxonomy as $term_id=>$term_info) {
$sql_cond.= (($sql_cond) ? ‘ OR tn.tid =’.$term_id.’ ‘ : ‘ tn.tid =’.$term_id.’ ‘);
}
//eliminate duplicated nodes in the list
//check if the required number of advertising links are shown (if terms are specified)
$sql=”SELECT n.title, n.nid FROM {node} AS n INNER JOIN {term_node} AS tn ON n.nid=tn.nid WHERE n.status=1 “;
if ($sql_cond) $sql.=”AND (“.$sql_cond.”) “;
$sql.=”AND n.type=’adv’ GROUP BY n.nid LIMIT “.$nmbr_adv;
$result = db_query($sql);
while ($anode = db_fetch_object($result)) {
$output[] = l($related->title, ‘node/’.$related->nid);
}
return $output;
}
?>

Use Taxonomy Quick Find module

The module uses AJAX and provides interactive selection of articles by tags.

Use Related Nodes

Here is the official module’s page: http://drupal.org/project/related_nodes
This version is available for Drupal 5 only.

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.