hi there, I'm a relative Drupal newbie and I'm having a hard time wrapping my head around how things get done with CCK. We have a node set up where contributors can write article drafts that go into a queue for editing and approval. Once approved the article gets assigned a "published" tag and it is ready to be seen by users who have been set up with a "subscriber" role.

However the one caveat is that some content has the option of being "exclusive" to a specific subscriber group, and as such should only be visible to those subscribers during a specific timeframe. After this timeframe expires the content then becomes available to all subscribers.

I tried utilizing the DATE functions within CCK, however there doesn't appear to be any obvious way of requiring the from and to dates, but only if the author has checked off that it's exclusive.

So the way I envision it is that there would be a checkbox: Is this exlusuve?

If checked then a select menu would appear and the user would have to select one of the predefined clients (user's with roles set to subscriber). Is there any way in CCK to create this dynamic menu or does it need to be hard coded?

If both of these are selected and valid, I'd like then for there to be a required field for FROM and TO date.

So in other words, if the user clicks the checkbox that it's exclusive, then the menu to select a subscriber as well as the FROM and TO dates should be required. (This is currently not the case).

Likewise if a user select that the content is NOT exclusive, then the subscriber and dates should not be required.

Any idea how I might go about doing this? Many thanks in advance!

brian

Comments

niklp’s picture

Hi Brian, I think you're ok with what you're doing with CCK, so far. I would suggest adding a checkbox as you mentioned. Then you can install the Views module, and this will present a list of "whatever" to your users - you can set View visibility by role, so in this way, you can generate two Views: one for your "exclusive" users (filtered by the value of the checkbox) and one for the rest (unfiltered).

To get the date on that, I'm not sure - perhaps you could use Scheduler.module or Archive? I've done nothing with dates. Alternatively, you might be able to add a datefield to your CCK type, and then perform a programmatic check on this value in Views, to ask whether it is older than a certain number of days etc, but again this isn't something I've had a vast amount of experience with.

I suggest you have a fiddle with what I've mentioned above, and then get yourself to the #drupal-support IRC channel to get filled in on any gaps, they're all helpful sorts in there.

Hope that helps.

briantullydelete’s picture

Many thanks for the reply NikLP - I really appreciate it!

What you've shared has been really helpful. However I'm still a little unclear on how, through CCK, to add the checkboxes of specific roles the article should be exclusive to. Not only do they need to specify if it's exclusive, but if is is they have to select which roles it is ecxlusive to as well as the dates of exclusivity. Do you know of any way within CCK to add a field that automatically adds a checkbox for each role (or better yet allow you to specify which roles)? Could the "Computed Field" module be used for this? Or is there a way in CCK to use the PHP Code fields to perform a query and return an array?

dopry’s picture

Status: Active » Closed (fixed)

good luck... not officially supported. hope you figured it out and contributed it to the handbook.