How to give a content type its own page?
usmanz - December 3, 2008 - 23:11
I have defined multiple content types on my site: http://netsafire.com
I list all the posts of each content in the form of blocks on main page. Now I have realized if those lists grow larger, I'll have to archive them and show only latest posts on front page.
I want to do this by providing a page to each content type just like "blog" content type (http://netsafire.com/blog), where content is organized on the form of a book or archives.
Is this possible in Drupal?

Hi usmanz, that depends. You
Hi usmanz,
that depends. You can use VIEWS module to create your pages and custom views.
Or if you're writing your own module then
<?php
function mymodule_display($node_type){
$types = node_get_types('names');
drupal_set_title($types[$node_type]);
$SQL = "SELECT N.nid, N.sticky, N.created
FROM {node} N
WHERE N.status = 1 AND N.type = '%s'
ORDER BY N.sticky DESC, N.created DESC
";
$result = pager_query($SQL, variable_get('default_nodes_main', 10),0, NULL, $node_type);
$output = '';
$num_rows = FALSE;
while($node = db_fetch_object($result)){
$output .= node_view(node_load($node->nid), 1);
$num_rows = TRUE;
};
if ($num_rows){
$output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
};
return $output;
};
?>
You'll just need to create a menu path and use this function as the callback.
don't forget to pass the node type int he path (i.e http://www.mywebsite.com/display/blog
where "blog" is the node type.
good luck
-----------------------------------------
http://www.netrift.com - Custom modules
Thank you. My website is
Thank you.
My website is based on Drupal 6.4 and the last time I installed Views module (about two months ago), it crashed.
Is there any known issue of D 6.4 with "Views"? Has it been resolved?
You are scaring me by posting that code as I'm not a developer :) Thanks for your time.
A new sapphire on the net - NetSafire.com
Heh, sorry about the code
Heh, sorry about the code thing.
I think views is pretty stable now. Since you're not a developer, I'd recommend installing views or paying someone to write you a quick module. The above code I posted is pretty much the entire module and will do what you want it.
good luck.
-----------------------------------------
http://www.netrift.com - Custom modules
Thanks again, Can you tell
Thanks again,
Can you tell me the specific place where this code should be placed? After or before which tag of which file? or if its a file itself, where to place it?
I will try views again, thanks for your time.
A new sapphire on the net - NetSafire.com