This simple and straightforward patch adds the ability to define different types of markers (while retaining the old default behaviour of the new and required markers to look the same). Someone with enough time on his hands might be able to partition the new marker to a real new marker and a changed marker (since node_is_new() returns TRUE even if nodes changed, and not only when they are new). This is the base on which the new patch can be worked though.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dries’s picture

Being able to differentiate between 'updated' and 'new' would be a plus. (Basecamp does it for example, and it has been suggested repeatedly by Kika/Kristjan.)

Stefan Nagtegaal’s picture

First of all, i like the patch..
Another usability improvement wou be to have a little helptext at the bottom of the form which tell you something like:

return t("The fields with a '%marker' are required to fill in.", array('%marker' => theme('mark', 'required')));

Under the tables of tracker, node, comment, and whereever items/users or whatever may be marked as new, i expect:

return t("The fields with a '%marker' are new.", array('%marker' => theme('mark', 'new')));
return t("The fields with a '%marker' are updated.", array('%marker' => theme('mark', 'updated')));

What do ou guys think?

Gábor Hojtsy’s picture

Stefan, markers are not necesserily inline. At one of my sites, we use a right floated block element to indicate that something is new. So this kind of help text will not work... The marker however can contain some help in itself in a title="" attribute, so that those hovering over it with their mouse can get an idea on what it is.

Dries’s picture

Committed to HEAD.

Gábor Hojtsy’s picture

Title: QUICKFEATURE: allow different marker types » Allow different content marker types
FileSize
6.48 KB

Suprise :) In real incremental patching sense, here is a patch to introduce the different new and updated makers. It operates with passing on the info to theme('mark'), and then letting it decide on what to do with it. This also enables people to do 'read' markers, if so desired (displaying different icons for read, uread and updated content).

Renamed the 'new' marker to 'content', so that it is not misleading, and introduced some constants, to help along the way. 'node' might be a better name instead of 'content', but it is just a search and replace in the patch, so Dries can fix it up, if needed. Also introduced the unkown maker for anonymous users. The practice before was that by setting the last view time to time(), markers are always displayed as 'read' for anonymous users. But with the different icons possibility in mind, it is important to distinguish the case when we cannot decide on whether a content is new/updated or not, because we have no data. This is why the unkown marker is introduced.

I admit I have not tested the patch, but it should work well, theoretically. Kept the original interface behaviour, which does not expose much from the power of the markers, but preserves the currently expected output.

Gábor Hojtsy’s picture

Wups, forgot to adjust one usage of node_is_new(). Plus renamed it to node_marker(), since it is not anymore only about checking on whether it is new or not...

Anonymous’s picture

Shouldn't 'MARKER_UNKOWN' be 'MARKER_UNKNOWN'? Why do we need an "unknown" possibility anyway? Wouldn't we just omit markers for anonymous users?

Gábor Hojtsy’s picture

Markers are only important for logged in users, yes. We need to somehow omit the markers. We can check for the user in theme_mark(), but we need to check for the user in node_marker() anyway, since otherwise we would do an unnecessery database lookup for each marker. So we can return MARKER_READ in node_marker() and omit the marker regardless of the $marker if the $type is 'new' and the user is not logged in. So we need to check for the user in the theme function too...

BTW the terminology I introduced seems to be inconsitent: node_marker() vs. theme_mark(). It might be desireable to rename the theme function, or use MARK_ constants and node_mark(). Pick the way.

Gábor Hojtsy’s picture

Since noone hinted on a way to pick, I needed to decide myself :) Gone is the unkown marker, and now it is the theme's task to not display content markers for anonymous users (while still keeping the required marker for them). The contants and functions were renamed to use 'mark' instead of 'marker' in line with the existing theme_mark() function. Still the same functionality, but with less code compared with the previous patch.

andremolnar’s picture

I think it might be helpful if you expanded the phpdocs for the constant definitions to describe when, where, how they are used. Right now the text only says 'Markers used to designate content.'

Gábor Hojtsy’s picture

Updated patch, which links to theme_mark() and node_mark(). Otherwise I think the names of the constants really tell everything.

tangent’s picture

I find the new "content" state to be less meaningful than the old "new" state. The word "new" is an adjective while "content" is a noun which, to me, applies to everything.

Perhaps "unread" would be a more appropriate state since that is the content that the marker identifies.

Gábor Hojtsy’s picture

Updated is not unread. Also there could be 'read' marks. Your email client has marks for read and unread messages doesn't it? Drupal will allow this too. If we rename 'content' to 'unread', then the unread marker would be able to signify that something is changed (while it was already read) and that it was read (which is odd for an unread mark you must admit :).

Dries’s picture

Removing the unknown-marker makes sense to me. Personally, I'd split the function theme_mark() because 'required' and 'content' (read/new/updated) are really two different things now. I'd hard-code the required part in theme_form_element() using proper CSS-classes. IMO, that would simplify the code and make it a tad more readable. (Initially, I couldn't figure out what the 'content' parameter was for.)

Gábor Hojtsy’s picture

OK, Dries is right again :) Updated patch with markers separated. The form required marker has it's own CSS styling now, and only the content markers are printed by theme_mark(). Also changed the comment code a bit to delegate marker display to the theme function. This does add an extra space after the comment subject if a marker is not printed, so it might not be desirable. Note though that there has always been these kind of extra spaces after the node titles in tracker and node modules on the user interface, and after comment titles on the admin interface. So I don't think this is becoming a problem.

I hope this patch is going to be fine. :)

tangent’s picture

Updated is not unread. Also there could be 'read' marks. Your email client has marks for read and unread messages doesn't it? Drupal will allow this too. If we rename 'content' to 'unread', then the unread marker would be able to signify that something is changed (while it was already read) and that it was read (which is odd for an unread mark you must admit :).
Goba

I am not quite following your meaning the way you've worded it.

Here are the different "states" which a node can have, with respect to a specific user, as I understand it. I have attempted list possible labels for each state.

New or Unread
The node has never been viewed by the current authenticated user.
Updated or Modified
The node has been previously viewed by the current authenticated user but has since been modified. This would include having its "body" or "teaser" fields modified (any other fields?) but would not include attached content.
Appended or Extended or
The node has had content (e.g., a comment, a file) appended to it.
Read or Unchanged
The node has been previously viewed by the current authenticated user and has not been modified or had any attachments modified.

Note that we currently lump the modified and appended states together. It may be desirable in some circumstances to differentiate between them.

Gábor Hojtsy’s picture

Tangent, you do suggested 'unread' as a replacement to 'content' above. Or at least I tried to read your comment multiple times, and understood this suggestion. The latest patch has no 'content' in it, so your remarks are not applicable anymore.

If Dries wishes to replace MARK_NEW with MARK_UNREAD, then it is fine with me, it is just a simple search and replace in the patchfile. I think NEW vs. UPDATED is better distinction then UNREAD vs. UPDATED, but the way I originally choose was not what is reflected in the current patcfile, and it changed for the better :)

Tangent, if you now a way to distinguish between the appended/extended state and the updated/modified state, then feel free to work on the patch more. I have no idea on how one would be able to distinguish between these two. If I add a paragraph to a node, is it a change or an extension of the content? If I modify a sentence and add three words in? Is it a modification or an extension?

tangent’s picture

1. I suggested "unread" as opposed to "content" only because you seemed to think that "new" was not meaningful. Either "new" or "unread" convey nearly the same thing to me, though "new" also could be interpreted as being created with a certain time frame (e.g., created within the last 24 hours) which is not it's actual meaning. Unread conveys, to me, only that the current user has never viewed the node.

2. I apologize for not having looked at your latest patch before posting my last comment to see that you had changed the label back to "new".

3. Distinguishing between "modified" and "appended" is not the job of this theme function. However the calling code wants to handle this is a separate issue.

4. Both of your questions about when a mode has been modified are equal according to my definition. If the "body" column of the record has been changed then the node would be considered "modified". Of course revisions throw a curveball at this definition so it would have to be added to the definition. Adding a paragraph or simply respelling an existing word are equal in terms of the definition.

Gábor Hojtsy’s picture

1. Tangent you should interpret new "as being created with a certain time frame" AND also being unread. Once a node becomes too old, it is not marked NEW anymore, regardless of one reading it or not. This behaviour was Drupal's own for quite a long time now.

2. No, I have not changed back the label to 'new'! The 'new' label was always there. You misunderstood something. Dries was also confused :)

3. We are not just modifying a theme function, but also introducing a node function, which does provide the node state. It is the task of that function to decide on state. Please look and the explanation carefully. I have described this earlier and the code for the node function is also in the patch. If you would have looked to the patch, you would have not been confused by the meaning of NEW (see point 1 above).

tangent’s picture

Sorry for all the noise and confusion. The latest patch looks great. I don't think differentiating between "changed" and "appended" is needed enough to belabor at this time.

Dries’s picture

Committed to HEAD.

Anonymous’s picture