How might I do this?
I have created a content type specifically for our "Letters from the President" of our organization. We would like to have an address, say: domain.org/letter that always displays the newest letter (as a full node with comments visible). This is so that we can publish this address in our printed newsletter.
The method that I tried was to create a view that showed the one most recent letter as a "full node" but the problem is that this method doesn't display the comments (and unfortunately, it doesn't even display a "number of comments" link... just "add comment").
Any ideas about how to accomplish this without having to manually edit the alias to the newest post each time one is published?
Thanks very much for considering it...
PS: One other idea was to use this method: http://drupal.org/node/255456 to display the comments as a view on the node, but I'm not quite following it. I don't see "comments" as an option when adding the viewfield to the content type...
Comments
Still looking for a suggestion about this.
Hi... This is kind of a "bump"... Still looking for a suggestion about how to handle this... Any ideas? Thanks.
Developper point of view
You can write a simple module to do this for you (I can help if you like)
Here is a module to get it done
I made a simple module for you
You can edit the file and change the path, alias, node type and descriptions
What it does:
when you go to www.yoursite.com/letter
The module will search the newest node of a given node-type
set an alias for it (i.e. 'letter-from-the-president')
and redirect the page to this page
* I cannot attach files here so here is the code, if you like I can send you the files by e-mail
last_letter.info
last_letter.module
Can this be parameterized?
Can this module be made to accept content type as an argument and then redirect user automatically to the latest published node that is in the given content type?
Say we have a content type called 'letter' and another content type called 'envelope'
if user visits: /content/letter, he is redirected to the latest letter node
and if user visits /content/envelope, then he/she is redirected to the latest envelope node.
How can this be accomplished?
arg(1) from request_uri? All types pre-defined? How? Any ideas?
Thanks.
Sure it can
There are few different ways to do this and each way requires different amount of coding
The generic way requires to add parameter handling, admin page to select the desired content types and a menu to the admin page
While this is not too complicated it requires some work
If you know exactly the content types you wish to use you can simply define hard coded handling for arguments
While this is not a generic solution it is very easy to do
Here is an example of the 2nd (easier way)
If it's not enough let me know and I'll try to help you
* I didn't test it, but is should be something like
latest_content.info
latest_content.module
Can you make this for drupal
Can you make this for drupal 7
thanks
Hi,
Sorry for late response,
I strongly recommend using views module instead, it is very simple to configure such view
Unless you have a reason not using views this is the best way
Nice module - great idea
Hi there,
Do you have a D6 port for this module? It's a great idea and just what Im looking for!
Many thanks for yout time to write this module, Joe
D6 port
Here is a D6 port,
Example how to use:
www.yoursite.com/latest/story - display the latest node of type story
www.yoursite.com/latest/letter - display the latest node of type letter
You can edit the value of $allowed_types if you need
latest_content.info
latest_content.module
b.t.w
If you are using views module in your site, you can achive this functionality without the need for a custom module
Thanks very much
Thanks very much Optalgin,
I'll give this a go tomorrow - should be excellent for what i need. I am using Views yes, but I want it to re-direct to the actual node rather than a view display that node on a separate page because I have other views on the same page referencing the node ID.
Will post back here as how I get on,
Many thanks, Joe
Good luck and let me know how
Good luck and let me know how it go
nearly works!
Unfortunately it only works first time - when I go to latest/blog it goes to the latest blog, but when I create a new blog entry and do the same it goes to the previous blog. I think this is because path alias creates an alias for the first blog (at content/blog), which then is redirected the second time i go to 'latest/blog'.
When I delete the created alias and try again it works as expected - im just not sure how to stop path alias from creating an alias (although I've tried removing the automatic creation)
Can you think of any way to get around this problem and simply redirect to the latest blog?
Many thanks for your help,
Joe
Redirect without alias
you have two paths
This path should not be used by "user", not so elegant.. I admit :-)
If you want to skip the aliasing and redirect to the node itself (i.e. node/123)
replace the lines
with
_
Another way to do this if you have views installed, and many sites do, is just setup a page view-- set the items to 1 and sort by date posted descending.
thanks Optalgin - just got
thanks Optalgin - just got round to testing this and it works great!
I use views yes, but wasnt sure if it was possible to redirect to the actual page, rather than display a view of the latest page...I have other views on the same page referencing the node ID (EG a nice little post-it style view for displaying the blog post date)
The module works great - thanks again!
Joe
My pleasure :-)
My pleasure :-)