I have a site with a custom content type called Class. We have a file in the theme called node-class.tpl.php.
Now the challenge is that we have need a URL like /featured_class which will search based on a boolean CCK and randomly select any class node which is marked as "Featured" and then display that.
I can do this with SQL and then redirect to the class node, but then the URL changes to that of the node. They want the URL to stay the same, ie. featured_class.
I can't wrap my head around this. I somehow need to get the node-class.tpl.php in there b/c there's a lot of code in there for displaying classes. The only solution I have thus far (that someone else gave me) is to use template_preprocess_page() to select that node template, based on the URL, and then use a custom function to find and load the node in question. I'm not sure it will work, but before I try, is there any other (better) way to do this?
Thanks!
I think I'm following you, but maybe I've missed your point.
Couldn't you just setup a View to display one node of type class, filtered by your CCK field, sorted by random? Use "node view" of that one node in the View, and you'll get one URL that shows whatever random featured node shows up using the node-class.tpl.php template.
Brian
On Wed, Jan 27, 2010 at 6:06 AM, Fred Jones fredthejonester@gmail.comwrote:
I have a site with a custom content type called Class. We have a file in the theme called node-class.tpl.php.
Now the challenge is that we have need a URL like /featured_class which will search based on a boolean CCK and randomly select any class node which is marked as "Featured" and then display that.
I can do this with SQL and then redirect to the class node, but then the URL changes to that of the node. They want the URL to stay the same, ie. featured_class.
I can't wrap my head around this. I somehow need to get the node-class.tpl.php in there b/c there's a lot of code in there for displaying classes. The only solution I have thus far (that someone else gave me) is to use template_preprocess_page() to select that node template, based on the URL, and then use a custom function to find and load the node in question. I'm not sure it will work, but before I try, is there any other (better) way to do this?
Thanks!
[ Drupal support list | http://lists.drupal.org/ ]
Hi,
If I understand you correctly, you just need to get the node object then use node_view() to output it.
The template file should be called in this way.
x.
On Jan 27, 2010, at 9:06 PM, Fred Jones wrote:
I have a site with a custom content type called Class. We have a file in the theme called node-class.tpl.php.
Now the challenge is that we have need a URL like /featured_class which will search based on a boolean CCK and randomly select any class node which is marked as "Featured" and then display that.
I can do this with SQL and then redirect to the class node, but then the URL changes to that of the node. They want the URL to stay the same, ie. featured_class.
I can't wrap my head around this. I somehow need to get the node-class.tpl.php in there b/c there's a lot of code in there for displaying classes. The only solution I have thus far (that someone else gave me) is to use template_preprocess_page() to select that node template, based on the URL, and then use a custom function to find and load the node in question. I'm not sure it will work, but before I try, is there any other (better) way to do this?
Thanks!
[ Drupal support list | http://lists.drupal.org/ ]