pager problem with drupal and taxonomy

Posted by andersandersson666 on Stack Overflow See other posts from Stack Overflow or by andersandersson666
Published on 2010-04-09T09:31:44Z Indexed on 2010/04/09 9:43 UTC
Read the original article Hit count: 386

Filed under:
|
|
|

Ok, so this is probably a silly question, but i thought i'd put it out there anyway:
I know it's a strange solution to a simple problem, but i needed to control the listing of the nodes in the taxonomy pages, which i didn't feel i got the traditional way. So i went ahead and created a module that fetches the nodes based on taxonomy (taxonomy_select_nodes()), and i wanted a pager to go along with that.

Here's the code:
function theModule_recipeList(){ $path = drupal_get_path_alias($_GET['q']); $args = explode("/",$path); $themePath = drupal_get_path("theme", "theTheme");

$term = taxonomy_get_term_by_name($args[1]);
$tid = $term[0]->tid;
$nodes = taxonomy_select_nodes(array($tid));

$output = "<div id='recipeListWrapper'>";
while($row = db_fetch_object($nodes)){
    $node = node_load($row->nid);

    if($node->uid != 1){
        $userClass="user";
    }
    else{
        $userClass="admin";
    }
    $output .= "
        <div class='receptThumbnailWrapper'>
            <div class='wrapper'>
                <img src='".base_path().$themePath."/graphics/recept-default-small.png' />
                <h3><a href='".base_path() . $node->path."'>".$node->title."</a></h3>
                <div class='recipeType $userClass'></div>
            </div>
        </div>
    ";
}
$output .= "</div>";

return $output;

}

Now, the module works as i planned and all (even though it is a duct tape sort of solution, i know), and the pager prints and works. The problem is that the pager prints before anything else.

I suspect that it is because i call taxonomy_select_nodes before $output is returned, but i need it to get the nodes i want.

Please, any suggestions is greatly appreciated.

/Anders

© Stack Overflow or respective owner

Related posts about drupal

Related posts about taxonomy