Posted by Anonymous on April 6, 2011 at 10:33pm
Hi all!
I was looking for a possibility to display nodes created by spieciffied user (uid) in speciffied category (taxonomy term(s)). I know about Views.module, track.module and "search.modules", but I prefer something simple and small... Finally, I decided to add a little piece of code to the taxonomy.module. Now it looks like:
<?php
if(isset($_GET['u']) && (int)$_GET['u'] == $_GET['u'])
$nuid = (int)$_GET['u'];
if(!isset($nuid)){
$sql = 'SELECT DISTINCT(n.nid), n.sticky, n.title, n.created FROM {node} n '. $joins .' WHERE n.status = 1 '. $wheres .' ORDER BY '. $order;
$sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n '. $joins .' WHERE n.status = 1 '. $wheres;
}else{
$sql = 'SELECT DISTINCT(n.nid), n.sticky, n.title, n.uid, n.created FROM {node} n '. $joins .' WHERE n.status = 1 AND n.uid = '.$nuid.' '. $wheres .' ORDER BY '. $order;
$sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n '. $joins .' WHERE n.status = 1 AND n.uid = '.$nuid.' '. $wheres;
}
?>instead of:
<?php
$sql = 'SELECT DISTINCT(n.nid), n.sticky, n.title, n.created FROM {node} n '. $joins .' WHERE n.status = 1 '. $wheres .' ORDER BY '. $order;
$sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n '. $joins .' WHERE n.status = 1 '. $wheres;
?>I'm happy now, because I'm able to use quite nice URLs, i.e.: taxonomy/term/TIDs&u=UID
But... I would be grateful if anyone could tell me how to do it in better way :)
Comments
Just use views
You can just use the views module to get what you're after. You can create a view that takes in two arguments (term & user).
-
@foggyperspectiv | foggyperspective.com (blog)