Is there a way to list either by category or by selection of a few product on specified content pages. So if you have a content page of red tshirt, at the bottom of it will display red tshirts from the catalog...
Listing certain products on specific content pages
|
|
Yes you can.. although I believe you need to use custom php to achieve this.
Take this code for example:
//get node IDs from a particular category
function getNodesTerm($term) {
$obj = taxonomy_get_term_by_name($term);
$res = db_query("SELECT * FROM term_node WHERE tid='".$obj[0]->tid."'");
$count = db_num_rows($res);
for ($i=0; $i<$count; $i++) {
$out = db_fetch_object($res);
$nodes[] = $out->nid;
}
return $nodes;
}Usage:
Theoretically, you can use it like this..
//load all red shirts
$node_arr = getNodesTerm("red shirts");
for($i=0; $i<count($node_arr); $i++) {
print node_view(node_load($node_arr[$i])); # print each product.
}As this code's comment says, it fetches all the nids of nodes classified by a specific category. And from there, you can use the nids for your own purpose. I used the taxonomy module's function taxonomy_get_term_by_name() to get the object containing the term Id (tid), and use it to fetch the node IDs that fall under that category.
I think "Views" can help you here.
With "Views" you can create custom tables or lists or grids of particular nodes (for instance to list all nodes with the term "red"). Or you can let views create a block which will list all red t-shits. And this block you could set to be visible only on certain nodes.
Also the module "viewfield" would enable you to insert views into nodes, if not as a block.
|
|




Joined: 01/31/2008