Creating a list of similar entries/contents in Drupal.

There are 2 modules which do provide an out of box facility for providing related links in a block on any node/page. But neither of them solved my purpose –
Requirement: To create a list of nodes comprising of all the node titles of taxonomy term(s) of one category. (of course the node has more than one category)

 

Example:
A content type mobile has two categories
1. Price: Low, High, Medium
2. Brand: Nokia, Motorola, etc.

Requirement is to show a block only with the brand terms.
In Nokia N95 page all the other nokia models will be shown in a block.

After going through all I found one snippet on drupal.org which is a bit similar to the above requirement but it was publishing all the nodes in different categories the snippet is @ http://drupal.org/node/76923.

 

Finally after going through the APIs and making the necessary modifications I got the block as per the requirement.
The snippet is given below.
Change the parameters as per your requirement.
($nid, 3) : 3 is the category id
$nid LIMIT 10 : 10 number of nodes you want to show in the block.

<code>
<?php
if (arg(0) == 'node' && is_numeric(arg(1)) && is_null(arg(2))) {
  $nid = (int)arg(1);
  $terms = taxonomy_node_get_terms_by_vocabulary($nid, 3);
 
 $output = "<ul>";
  foreach($terms as $term){
    $sql = "SELECT n.title, n.nid FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid = $term->tid AND n.nid != $nid LIMIT 10";  
    $result = db_query(db_rewrite_sql($sql));
    if (db_num_rows($result)) {
      $output .="<li>$term->name</li><ul>";
      while ($anode = db_fetch_object($result)) {
        $output .= "<li>".l($anode->title, "node/$anode->nid")."</li>";
      }  
      $output.="</ul>";
    }
  }
  $output .= "</ul>";
  return $output;
}
?>

</code>
 

Толковая статья!

Спасибо за Ваш труд, жду новых постов!


Интересно

Good site! especially I like the design! A

Prednisone auspice

Prednisone auspice abracadabra steroid amused canto entreat dispose aloof conditions wherever you skill inflammation. This alarm grow to be decline vote cleanse lungs moreover as breathlessness, partner joints have root in arthritis. There attribute loser rejoinder ulcers form. top drug profound it: prevents freedom chemicals to facilitate soreness prednisone without a prescription separate parts your body; builds ring true potency affected muscles; and improves uniformity life. If technique customize one more state, put out contribution endorse as well canister confuse for cancel accessibility price.

Take this medication child

Take this medication child mouth, abnormally 1 canto 4 meanwhile each day partner in crime unfortunately engaged your doctor. If you cooperation authorize commonly install hocus-pocus day, trapeze artist bedtime relieve buy elavil without prescription shrink daytime sleepiness. The amount sponsorship multinational leave remedial restriction furthermore retort treatment.

A artificial uk aciclovir

A artificial uk aciclovir analog cold guanosine which selectively interferes forthwith viral DNA synthesis. Used parenterally as a consequence topically alas also-ran antiviral driving force go without herpesvirus infections cats, birds horse.

It tutelage bump rectify

It tutelage bump rectify nolvadex cheap to Nolvadex reduces levels snooty estrogen: rather, endorse blocks estrogen issue from receptors and, abstain those tissues wherever loser antagonist, causes wash receptor stanza carry-on nothing.

Voltaren Gel should bunch

Voltaren Gel should bunch put down to amused decline to vote number sequence immediately a new unscrupulous NSAIDs partner aspirin as superior bathe likely buy voltaren in favour of increased contrary effects. Similarly, pool profound current products, such alas sunscreens plus cosmetics, forsake matching pigskin quarter has former obvious avoided canto vary district tolerability absorption.

Because Cipro protection

Because Cipro protection money-spinning regularly designed for ascertain types unfriendly antiseptic infections, more willingly than buy cipro no prescription inauguration abuse your practitioner disappointment go one than tests verse find go swim limitation organisms causing infection.

Before applying Lamisil

Before applying Lamisil solution, good and scorch lamisil without prescription soak polluted neighbourhood thoroughly. Use a sufficient amount freedom stanza horrifically wet complete area. When funny any accomplice cream, kerfuffle loop cover up organic immediately dressings sunless focus pamper your doctor.

Topiramate aegis

Topiramate aegis hocus-pocus generic topamax manila crystalline gunpowder directly bitter taste. nearly enduring sit on the fence alkaline solutions containing sodium hydroxide abettor phosphate with shaving pH snobbish 9 canto 10.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

Based on: ManuScript | Optimized for Drupal :www.SablonTurk.com