By rajesh_1988 on
Hi All,
I am new in drupal. Actually i want to create a drop down for sorting of content type or block posting like if i selected Article then all article in my page get listed or if i i selected block all block posting get listed. How can i do this ? can any body tell me?
I have created the current_post module block which list currently added items,it has link(more) when i clicked on more it display one page where i have all the post within one week.here i want to create one drop-down which list post on the basis of drop-down item?
how it can be possible?
Comments
Views?
I do not totally understand your question. I do not understand whether by drop down you mean create a drop down menu, or a 'drop down' page.
Drop down menu is easy enough, for example use Superfish module to create a drop down menu. Just make Article a parent menu item with path 'article', and each time you add an Article give it a menu link which is a child of the parent Article link. Clicking on Article will show a drop down with all the links which you have created.
However, if you want a page with all Articles etc. a basic way of assembling all content of a particular type is by using the Views module to assemble the page. It can pull all items of a particular content type onto a page. It takes a bit of time to learn Views but there are lots of tutorials.
Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors
I want to create content type filter using code.
Actually i have created one block using code(referring from http://drupal.org/node/1074360 ).here i created one block which display current post.it has more link.on clicking on more link a list of current post items page get displayed.here on this page i want to create one drop down which have listing of all enabled content type module like article,basic page, blog entry and custom content type.And after selecting any content type all post of related content type get listed.if there are no post for related content type ,a proper message get displayed.
how can i do this ?
taxonomy
One way would be create a taxonomy vocabulary with terms like Article, Blog Post, Page etc. When you create an Article, add the Article tag. When you create a Post add the tag Post. Then Anyone who clicks the tag 'Article' (either from a link or a menu item) will get all the items tagged 'Article'. The fact the content type also happens to be article is coincidental. Understanding and using taxonomy is central to learning Drupal, it is one of the things whcih makes Drupal special!
The other way, giving a bit more control of sorting etc. would be to create a View for all nodes where Content Type = Article, etc. Then display the View in a Node or in a Block. This involves using the Views module, which as I said above takes some patience as it is complicated. However, it gives more built-in flexibility to the way you display the results, compared with the taxonomy method. If the taxonomy method does what you want I would use it, and only use Views if you need more control.
Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors
John, I think he asking about
John, I think he asking about how do it using Code, as he writing a module.
Sharique Ahmed Farooqui
ah!
I see, You are right. On re-reading I see that I slightly missed the point.
Still, everything in the question could be done with existing modules (Views for content types, Rules for the message where there is no data; there are probably other ways too). Writing a custom module sounds to me like the hard way to get the same result...
Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors