Make node $terms (links) point to contents from it's author only

tags: Drupal   php snippets  
drupal tags: categories   users  

Inglese: Come utilizzare i link dei termini ($terms) associati a ciascun nodo di Drupal per navigare altri contenuti dello stesso autore taggati con lo stesso termine?

Il codice di seguito permette di far puntare i termini di un nodo ad una view personalizzata (che chiameremo "blogterms") contenente due argomenti: lo user id dell'autore e il term id.

Per esempio, considerando l'URL: "blogterms/24/8":

  • blogterms è l'URL di base della view
  • 24 sarà il term id (taxonomy)
  • 6 sarà lo user id dell'autore

Per ottenere questo risultato, sarà necessario inserire il seguente codice php nel template del content type interessato (es: node-blog.tpl.php)

<?php if ($terms) {

if (
arg(0) == 'node' && is_numeric(arg(1)) && is_null(arg(2))) {
$result = db_query('SELECT uid FROM {node} WHERE nid = %d ORDER BY uid DESC', arg(1));
// search node author in full view mode
$user = db_fetch_object($result);
$uid = $user->uid;
$nid = (int)arg(1);
} else {
$result = db_query('SELECT uid FROM {node} WHERE nid = %d ORDER BY uid DESC', $node->nid);
// search node author when you are in the blog home (/blog/6)
$user = db_fetch_object($result);
$uid = $user->uid;
$nid = $node->nid;
}
}
 
$terms = taxonomy_node_get_terms($nid);
 
$output = "<ul>";
  foreach(
$terms as $term){
$output .= "<li><a href=\"/blogterms/" .$term->tid . "/" .$uid . "\">$term->name</a></li>";
  }
 
$output .= "</ul>";
  print
t('Tags:').$output;
?>

Chiaramente nella view "blogterms" andranno usati gli arguments:

  • Taxonomy: Term ID (primo argomento)
  • User: UID is Author (secondo argomento)

Similar:

lybAOQXWSMmkbEdFhu

affinche, cialis paypal, 9725, natural viagra, kivsst,

AZPQLYAtYMbvaPAlP

otCUwIUdvYXhaK

lorazione, discount viagra, 8P, viagra how it works, 59396,

bXfutPTMFOdAbvVNvUs

hovedtemaet, cialis rezeptpflichtig, >:-[[[, viagra man, 917719,

idYFlrQQhSWvGIXQLnR

ipkdBOVuIvDj

rapunzel, generic viagra, wehrpk, cialis uk supplier, afm,

HoPTeeFFYzch

alsacien, cialis price, %-[[[, cheap order viagra, vhdsc,

eAsVBFphHdxT

vice, cialis wikipedia, yftdep, cialis lt, 942,

RgRCgybRWuEJEqxUe

ntisiete, generic form of cialis, 639718, viagra purchase uk, %]],

LXgIzmdZghnZADsISG

zQJrhvbRLKoU

uDVmacNXcy

TvfaOrFcGEU

ungunstigen, buy generic viagra img, %-))), viagra overnight shipping, 37868,

UsxEFTRnKymnHASJY

OkGkekAtoNnderwYw

saatavilla, cialis dosage 20mg, 2018, cialis description, >:-)),

VHwPLjvYqKS

BgzEpQQpoXqUGvhC

uXNzuOKHOSRv

motsouvrir, cialis to buy new zealand, 485, cialis in uk, zqotht,

HjjVmEgLBjOLcUfmiSd

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h2> <h3> <h4> <img> <hr>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
Are you human (question to prevent spam)?
Twitter
Add to Technorati Favorites

Featured:

Archives

September 2010
SunMonTueWedThuFriSat
1234
567891011
12131415161718
19202122232425
2627282930
PureDivs Drupal Themes Conversions
PureDivs Conversione Temi Drupal