One of the keys to a digg.com type of site is that nodes first start out in a queue and then are promoted to the frontpage after they receive enough votes. Nodes on the frontpage have to be sorted by the time they were promoted, and not by the node creation time.
This poses a problem because currently, nodes are only timestamped with their creation time and changed time. I have thought alot how to solve this problem, and I think I would need to create a new module and database table to store promotion timestamp information.
Here's how Merlinofchaos described this module to me:
"write a small nodeapi module that has a small table (nid, promote_date) that watches in hook_nodeapi for ops 'insert' and 'update', checks to see if $node->promote has changed, and if so, write that date to the db."
Yes, that sounds like the perfect solution, but alas, my programming skills stink.
Is this a difficult module to create? Would someone be willing to help me with the code?
Thanks in advance for your advice.
Comments
bump
Here are some other ideas I had:
I could turn on revisions, and then have the voting actions module change the creation time to the current time upon promotion and also do a node save to create a new revision. I could then limit the frontpage to nodes that have been promoted, sorted by creation time. Then, I could use the timestamp on origonal version of the node (as stored in node_revisions.module) to represent the origonal publishing time.
OR
Just create a new table called "node_promotion", and then have voting actions module save the nid and timestamp when it promotes the node.
The problem with both of these solutions arrises when I manually promote a node to the frontpage, because the new timestamp relies on voting actions doing the promotion.
The solution in the origonal post appears more complete, but more difficult to do. Will either of two methods I just described work for my situation? Can you help me understand how to accomplish this?
Thanks again.
Progress
Hi guys,
I made some progress trying to make my first module, appropriately called promote.module.
My table has two rows, nid and promote_date.
Like merlin suggested I am using hook_nodeapi. Here is my code so far:
I had trouble finding documentation that shows what code I need to analyze if the node is changing from unpromoted to promoted, and then if so, how do I write this to my table?
Any progress on adding a
Any progress on adding a timestamp to nodes when promotion is changed?
-------------------------------------
Petafoo
I use sticky for this...
In hook_nodeapi/presave:
That looks like the ticket
tomamic's response look like the ticket. I've adapted his code to allow editors with sticky privs to order front page items by toggling the node's sticky attribute: