Hi everybody,

I need badly an advice about how could I hide/"unpublish" some parts from a node's text. They are personal notes, untranslated parts, etc, simply pieces of text which are not meant for being public (in a published node).

Till now I did that in the most rudimentary form: I enclosed those parts of the text into some /* simple and well hidden text :-) */ tags, and it worked like a charm.

But I need a way to keep these chunks of text invisible for public but making them visible (maybe marked/styled differently) for a certain role (an editor or something).

Any help is wellcome.

Comments

dnewkerk’s picture

This module may be what you are looking for: http://drupal.org/project/hidden_content
It is not ported to Drupal 6, so you may have to request it and wait (or port it yourself if you're able - it's a very small module).

Since the only documentation appears to be within the module itself, here it is for your convenience:

To make a part of your page hidden put it into [hidden] and [/hidden] tags.
You can specify which role is able to see the content by using the attribute role like this:
[hidden role=5]text[/hidden]. This will enable role 5 to see the text.
You can specify that only one user is able to see it with the user parameter:
[hidden user=2]text[/hidden]. This will enable user 2 to see the text.
You may only specify one parameter.
You may specify multiple users OR roles as a ';' seperated list.
[hidden role=2;3]text[/hidden]. This will enable role 2 and 3 to see the text.
If you ommit both parameters only user 1 will be able to see it.
You may insert [hidden]text[/hidden] into your text.

In any case, I'd advise you not to go with the PHP input filter if this is a multi-user site.

dnewkerk’s picture

Following this helpful screencast on porting modules by webchick, I ported this module to Drupal 6 for you (this is a simple module with very little code and no database tables, so it was a good option for my first try at porting modules haha). It was incredibly easy in this case (I'm a PHP newbie)... only a few small changes and the rest were code cleanup to meet Drupal coding standards. I tested it out and it works correctly.

I've submitted a patch which you can apply and the module should then work with Drupal 6 :) (here's info on applying patches)
Patch is here: http://drupal.org/node/278730

Through doing this I noticed a shortcoming in the module (in my opinion)... though you can restrict the visibility of the text to certain roles or users, adding a specific role to the tag seems to "ignore" the admin account, as it does not actually have a role to be specified. I "think" (though have not tried it) that this other patch may help this issue (I'll test it if I have time). You may wish to look further into this or request a feature if needed. If you only have a few people who need to use this module's features, it may just be simpler to specify user IDs rather than roles, and that would bypass this issue.

- David

dnewkerk’s picture

I went ahead and tested out the other patch I mentioned - it would not apply automatically to the current version so I manually added the changes. The patch adds an actual Drupal permissions option to Roles, so you can specify that a given role can always see hidden content (without having to write it within every hidden tag) and also as such solves the issue of the admin no longer seeing hidden content if other roles are specified.

It seems to work great, though I'm sure it needs review by more knowledgeable developers to ensure it is done correctly and securely. In the mean time I will submit a patch against the current dev version for 5.x as well as second patch to be applied after my first patch to add this function to Drupal 6 (you'll be able to find it in the issue queue for Hidden Content).

- David

DVV’s picture

David,

thank you for your help.

GA