Hello all,

I have been trying to find a way to perform "minor edits": doing negligible changes to a node, that do not affect the last updated time of the node.

The site I am working on encourages the users towards the most recently posted/updated content, and when updates happen to earlier nodes, they tend to be substantial and are promoted based on the time of the last update. However, I sometimes need to correct the odd typo, which instantly promotes a node as it's just been updated. What I'd ideally like would be a "Minor edit" button next to the Save and Cancel ones on the node edit form, that saves everything else but the updated time.

I imagine other wiki-style projects have similar needs, and I spent a few days googling about it... but I am lost in a sea of unrelated results (the terms are indeed too generic).

Anyone care to suggest some advice? Is there a module out there that does this, or how would I go about hacking it together?

Comments

WorldFallz’s picture

How are node promoted to "most recently/updated content"? You should just be able to change the criteria or alter the date? Worst case scenario you could add a checkbox to the form for "minor update" and use that to exclude nodes you don't want listed. It all depends on what tools your using to list and promote nodes...

skourak’s picture

The nodes are promoted using a view that shows the "active content" (created or updated) of the last week. I filter my nodes by "last updated time > -7 days".

I thought of workarounds to the minor edit but there is nothing... elegant. Indeed I could add a date field to all my cck content, use this for showing new content, and then remember to update it every non-minor edit and teach all my users to do so... but it's lots of work and not that user-friendly.

Basically all I want is to store the updated date at every edit, and once the node is saved, enter the old datestamp into the database.

WorldFallz’s picture

Ah ok-- yeah I would do this with a simple checkbox, but you can code it to do what you say: replace the current updated date with the previous, but even then you'd need some way to indicate when you do that and when you don't. For me, the checkbox is just simpler.

cgrant3d’s picture

I have a similar problem. My content is sorted by recent updates / comments so anytime one of my users update their content it pops to the top and anytime someone comments on their content it pops up to the top too. I do that in order to provide an organic, ever changing page to expose new content to new users.

My problem is sometimes I need to fix a broken link, change taxonomy, fix some html formatting in a user posted node, etc but I don't want it to pop up to the top of the view artificially. I wish I as the admin could just edit a node w/o touching the timestamp. I've actually gone into the drupal db tables a few times and copied the node timestamp, edited the node w/drupal then pasted the original timestamp back directly in the db... Really ugly and it's not something I want to do regularly.

I think the best workflow for me would be if the authoring section (where it has the node created date) had a checkbox to not update the node modified timestamp... Unfortunately I'm pretty sure that'd require I write a module and I try not to write code that I'll have to keep maintaining - any other ideas or alternative workflows that might solve our problem?

skourak’s picture

I spent some time today on this issue trying to set up a module to do just that, but as my drupal knowledge is basic, it may take some more time... At least it's a good way to practice by doing :) I'd be glad to publish the completed module once it's done, it's something so small that I doubt it would need any sort of maintenance.

I am tinkering with it, and I'd like the opinion of the wiser coders in here.

I figured the best is to start with hook_nodeapi().

When a node add/edit form is created, ('op' == 'prepare') I can retrieve the $node->changed and store it onto another node variable (minor_edit_changed). Then, at the time after the data has been committed to the db ('op' == 'update'), put back into the db the old changed value.

This should only be done when the user clicks on "Minor Edit" (a new button next to the Save/Preview/Delete), or alternatively when the user has ticked the "Do not alter timestamp" checkbox. I managed to get another button on the edit form using hook_form_alter().

But so far I don't understand how to connect those two hooks... how can I know in the nodeapi update whether the user selected the 'minor edit' option in the form? It sounds quite basic, but so far I haven't had any luck...

Suggestions / pointers / tips?

WorldFallz’s picture

I'm not sure why you need a module-- just add a cck checkbox for "minor edit" and change the views to filter out items with "minor edit" checked. No modules, no code.

cgrant3d’s picture

Thanks for your continued suggestions WorldFallz. Part of the problem is the nature of my site - I don't control all the content, most is user submitted.

If I use the CCK checkbox method then my users will have to know to uncheck "minor edit" when they do subsequent edits *after* I've gone in and edited their node. It's common for a user to edit their own node dozens of times over the course of time and I can't expect them to know they need to uncheck a checkbox that I checked...

Hmm. Just had an idea. Tell me if its too clunky - what about forcing any node edits to uncheck the "minor edit" checkbox? That way if I set the minor edit flag, and a user edited the node the following week - it would then uncheck minor edit for them automatically... Does that seem like a good idea to you or does it break with best practices / good coding with drupal?

skourak’s picture

Indeed by using a cck checkbox I could imitate the desired functionality, more or less. These are the reasons I prefer the module way though:

- I want to restrict this functionality to the "superadmin", noone else should be able to make minor edits. I could restrict access to the new cck field to a role, but what happens if the superadmin makes a minor edit, and then a regular user makes a non-minor edit? The flag would still be set and the content would not appear in the recently modified list. I'd still need to intercept a regular user save operation and reset the flag by code. By using a module, I could create a new permission if need be that could be easily assignable to any user role.

- coding a module is an excellent learning experience, for me as a drupal programming newbie. If I can write exactly my desired functionality, why should I resort to a workaround? With a couple of hints from the community, it should be fun to write!

- the described functionality is clear, concrete, and self-contained, with a variety of different applications - a perfect candidate for a module. I can see clear uses in collaborative work environments where people need to know what others are recently working on, but ideally they should be only informed about meaningful (vs minor) updates. In fact, the idea of this functionality stems from experience I had with some wiki software a few years ago, where we found it very useful. Why not pack it up into a lightweight module for everyone else to use?