I’ve defined a custom content type – news. I also have a menu item – latest news – that links to one of the news nodes. I want it to link to the latest of them. How would I do that?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Common end user approach: Using the Views module, you create a view page (with its own path) that only shows the latest (or n latest) node(s). Then you point your menu item to that page.
Alternate developer approach: If you want to avoid the overhead of the views module, you could also implement
hook_menu()within a custom module. There you’d register a custom callback function for a new path (e.g. ‘/show/latest/news’). The callback function would then determine the latest news node and either render it itself, or redirect to its path usingdrupal_goto(). Your menu item would point to the new path.