By darrenlambert on
Hi Guys
I have a number of nodes associated to a vocabulary term.
I want to show the teaser list for the term within a node, such as a page.
In a page I might have a heading of 'Recommened movies' then the term teaser list so users can click on the teaser link.
How do I display the teaser list?
I'm hoping it is a simply tag or php call.
Thanks
Comments
Something like this:
Obviously alter the $taxo_id to your own and the $list_no to how many you want to display - if you just delete the LIMIT part on the end of the sql query then you'll get every result. Else you can select a random selection (which might be good for movie reviews?) by sticking "ORDER BY RAND()" near the end of the query. Like this:
...node.tid = $taxo_id ORDER BY RAND() LIMIT $list_no";Obviously if you leave the $list_no as 5 then it'll return 5 random hits.
Or 'proper' teasers? You can stick a "node.teaser" into the SELECT statement and utilise that as the output:
Sorry about the lack of drawn boxes in that example - I'm afraid I'm just altering about the php snippets from the handbook to get these results. I've absolutely NO IDEA about Drupal API calls. The length of the teaser is determined in your settings someplace, I forget where - but yeah, it's in there somewhere!
Pobster
This is quite cool (albeit messy)
I'm no php or mysql programmer, I only just 'get by' although I understand programming, I used to write basic and z80 assembly stuff years ago... Anyways, this is quite cool - but probably could be written a lot better (hence the excuses!):
It displays a neatly tabled view of the last 5 'entries' of a taxomony (number 75 in my case) with a clickable link to the node itself and a 'Submitted by' line.
Check it out in action here:
http://www.ciclosuno.com/results
Well I say "in action"... That's actually a different script! It's essentially pretty much the same, but it works on flexinodes and it orders the list by a date field entered on the flexinode rather than the 'created' date. Still it looks pretty though :o) And I like the way it handles displaying different years. Yeah erm, I didn't write that bit! ;o)
Pobster
Hi Pobster,Do you happen to
Hi Pobster,
Do you happen to know a phptemplate version of the slash theme used in ciclosuno?
Sorry...
It's literally *just* the slash theme with a few changed colours. I used the theme_editor module to do it. Nothing fancy... Sorry...
Pobster
this could make a useful feature for event module ?
nice one!
I don't like the current 'table' view in event module, this looks like the beginning of something much more useful.
thanks!
Nahhhhhh! ;o)
Nah it's much too badly programmed to actually be included into a module. Still it works and that's good enough for me!
If anyones interested, here's the code for how I have it on my site:
That might be useful to someone... It was to me! I didn't like the way the table view only allows you to sort by the node.created field when one of the 'entries' you can put into a flexinode is a date/time field. This code allows you to do just that... NOTE! Don't think I'm being clever by doing any of this, I am literally just hacking together different parts of other peoples php snippets out of the manual. And I had a LOT of help with this particular piece of code, because well... It didn't work at first! ;o) Still, a *REAL* programmer showed me where I'd gone wrong!
Pobster
PS. Obviously change the $term_id to your own and the $field_id to the date/time field number.
you're too modest
Mr, compared to my hacks, this one's a beaut!
Anyway, drupal is designed to be hacked - that's the whole (very good) idea behind phptemplates, isn't it? I don't think I'm letting the side down by admitting that drupal tutorials (http://drupal.org/node/19854) are a bit thin on the ground, so hacks like this are very educational for code-numpties like me. Please do keep posting them!
:-)