I've managed to find modules and snippets that will put node teasers in another node from one module only though. What I need to do is this;
ie. online magazine has it's own content modules of;
(examples only for explanation)
a. trucks
b. cars
c. vans
I have a node that has the teasers of the most recent truck articles and I have a node that has the most recent car teasers.
but how do I make a node that pulls the most recent node with one teaser from the trucks content, one teaser from the cars content, etc. and vans in a new node called vehicles.
This is what I'm using to do the node teasers for the individual node sections, ie. trucks. But I can't see how to pull in from different nodes for a comprehensive teaser list.
/**
* This php snippet displays content of a specified type, with teasers
*
* To change the type of content listed, change the $content_type.
*
* Works with drupal 4.6
*/
$content_type = 'trucks;
$result1 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = '$content_type' AND n.status = 1 ORDER BY n.created ASC"));
while ($node = db_fetch_object($result1)) {
$output .= node_view(node_load(array('nid' => $node->nid)), 1);
}
print $output;
Thanks,
Lisa
Comments
try something like
try something like this:
OR, if you're going to need to pass in the types:
---
Work: BioRAFT
that worked!
thanks:) That worked perfectly!
A couple of approaches
One you might want to check out the views module as it is real handy for these kind of pages.
As for updating the snippet, change the two lines where you set $content_type and where you perform the query to
views
I wanted to install views as it appears to have a lot of the flexibility I need for various modifications. However once installed it doesn't show up in my admin menu, so I'm not sure how to fix that....
how do I specify a specific node?
If I want to put teasers of 5 specific nodes in a node, what would I change the code to? I tried changing $content_type to $node_url but that doesn't seem to work and I probably have to change more and that gets beyond my level of php.
Thanks,
Lisa
Well, hand-coding the nid
Well, hand-coding the nid values seems a little silly, but easily done as:
where you should replace (33, 34, 35) with you list of desired nid values.
More typically, you'd do a join, ORDER BY, or WHERE based on some other criteron (like taxonomy a term or timestamp)
---
Work: BioRAFT
thanks
that worked. The truth is I really don't understand what most of it means, so I just muddle through and so I have no idea what a join, ORDER BY, etc. would even mean;)
thanks:)
Lisa
To cut down on execution
To cut down on execution time, just call the individual nodes by their nodeId. For example:
oh yes- of course. There's
oh yes- of course. There's certainly no point in selecting the nids if you know the nids...
---
Work: BioRAFT