I am creating an event-website. It would be nice if scheduler could be set as a widget for a field. When creating a node, they could choose to publish an event from x to y.
Please advise! Thank you for your time & efforts.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cmseasy’s picture

Version: 7.x-1.x-dev » 7.x-1.0

+++

With a field, admins can rearrange scheduler in the node edit field form.

Now, scheduler is almost the last item in vertical tabs: almost hidden for users.
When you make scheduler required than users have to find it, mostly they dont, and hit the node submit without date settings. They don't understand the error. Placing scheduler in a "understandable" workfow for the nodeform is a great +++.

inforeto’s picture

+1 to this, it was fine back in d5-d6 but as of d7 the node type building has new customization features.
Starting with the vertical tabs, which it'd be great if could be open by default.
Then the weight, but for this it'd be best to make it a full field so you can arrange it in the manager.

zhgenti’s picture

Hello,

Agree with previous commenters, it would be great to have as a field. Not necessary as usual field, but may be extra field like node Title. Whatever is easier to implement.

Thanks

AaronELBorg’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Status: Active » Needs review
FileSize
7.54 KB

I just created a patch to show 'Scheduling Options' apart from Vertical Tabs. This patch will also allow a user to set a weight for 'Scheduling Options' so that they aren't buried at the bottom after removing them from the Vertical Tabs display. (Note: the default is to show things in Vertical Tabs just as things are currently.)

This patch also adds in one more config option: the ability to have a publish-on date that occurs in the past. I'm well aware that this issue didn't include this request but if your end-user is your average-joe-type-non-technical-person and you want them to be able to schedule nodes for publishing and unpublishing as easily as possible, it seems somewhat slicker to have both of those fields filled out rather than explaining to them that they only need to fill out the unpublish-on field with an error message. Also, if these types of users are your bread-and-butter (so to speak), one wants to streamline the node-creation process as much as possible. Throwing a 'Publish-on field must occur in the future' error is a roadblock that I'm not convinced absolutely needs to exist. (I could be swayed otherwise.) Again though, the default is to NOT allow this behaviour so it's business as usual from the get-go.

AaronELBorg’s picture

Oh yeah......since this is my first "big" patch (one that affects more than one file), I wasn't too sure how to go about the db update part of things. So currently, in order for this patch to work, you'll need to disable and uninstall/reinstall scheduler. So obviously, installing this on a live site might not be the best decision. If you're feeling brave, however, (and you're doing this on a test site) you could easily increment the update number from "6101" to "6102" (in scheduler.install) and run the update at /update.php.

Again though, this probably needs testing so please tread lightly.

Eric-Alexander Schaefer’s picture

@AaronElBorg Could you please post separate patches for the different changes (vertical tab option, publishing times in the past)?

jonathan1055’s picture

Yes, the vertical tab vs setting as a field is a new idea, worth investigating.
Publishing time in the past has appeared in many previous posts, and will require a great deal of planning and co-ordination if changed, so they must be separate patches. Just include the tab vs field patch here. Can you also show a couple of screen shots, so we can see more clearly the results.
Thanks

puddyglum’s picture

FileSize
10.91 KB

Here's the vertical tab / separate field patch from #4.

The patch is missing the .js file. I can't seem to figure out how to add the file so I can use diff

jonathan1055’s picture

Hi,
I think your patch has included some unintended changes, maybe you diff'd against an older version than the latest dev? There should be no changes to the lightweight_cron menu call, nor to scheduler_list_access_callback()

Jonathan

puddyglum’s picture

FileSize
5.75 KB

This one should work much better. Has the .js file and is committed against the right branch.

idflood’s picture

The patch in #10 works well but the javascript part is a little wrong. One important thing in d7 is that javascripts should not use the $(document).ready function since it won't work if the settings appear in a modal, or other cases. The recommended way is to use the behaviors: http://drupal.org/node/756722#behaviors

But looking at this, the javascript part is not needed. The form #states api can handle this really easily: http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.ht...

Here is a new patch with only the js removed and the #states added.

gaheinrichs’s picture

Hello,

Is there a way to manage the field. I am using Fieldgroup module to specify a group to each field. I will like to set scheduler inside a group.

Thanks

noslokire’s picture

#11 works for me

ace11’s picture

Is there a way to schedule one field in node?
So that if I have for example 5 different fields in node. And I need to set different publishing schedule for every field. Is it possible?

Pat Redmond’s picture

ace11 and gaheinrichs , you should open a new ticket rather than attaching a different question to another topic.

As far as I am aware, it isn't possible to publish fields. The node is published or unpublished. The fields are attached to the node.
The only way I can think of creating the functionality you mention would make use of the entity reference module to link several nodes to a parent node.

frob’s picture

Status: Needs review » Needs work

I might re-roll this as I would like this functionality.

jonathan1055’s picture

Thanks frog that would be good. Now that we have a new co-maintainer lots of patches have been committed in the last few weeks and we have a new 1.1 release.
When you've done the changes, can you also attached a screen shot so we can see how it might look if using the new layout? thanks.
Jonathan

jonathan1055’s picture

Title: Set scheduler as a field » Options to set Scheduler as a fieldset and change the weight
Status: Needs work » Needs review
FileSize
139.76 KB
143.95 KB
158.98 KB
4.89 KB

I've reviewed the patch in #11.
Here is the Scheduler settings tab with existing patch

  1. I have removed html markup from all strings, especially those inside t()
  2. The settings were placed in the 'publishing' fieldset, but they should have their own separate fieldset as they apply to the node edit page, not publishing or unpublishing
  3. Changed weight from plain text field to a selection entry, -50 to +50. Removes the chance of user input error
  4. Default weight is 35 as per current behaviour
  5. The weight now applies to both types of display - vertical tab and fieldset. Useful to have the vertical tab with a small weight so that it is the first tab, hence always shown open
  6. Changed vertical tabs/fieldset selection from checkbox to radio button, as it is easier to explain with the text for each. Checkboxes are more use for on/off settings but this is an either/or
  7. The default is to display in vertical tab as per current behaviour
  8. Added option to always expand the fieldset. Default is only open if date exists or is required (as per current behaviour)
  9. The 'expand fieldset' choice is only shown when the display option is set to 'fieldset'
  10. The additional lines in .install update_6101 are not required as we can code default values for the variables. Just for reference, even if these variable settings were required, they should not be in an existing update function - always make a new update function

Scheduler settings tab with new patch

Example of Scheduler options displayed as a separate fieldset

New patch against 7.x-1.1+20

Jonathan

pfrenssen’s picture

Assigned: Unassigned » pfrenssen
FileSize
5.87 KB
5.54 KB

Instead of letting the user set a weight to determine the position of the Scheduler options we should allow to position the field by using the drag-and-drop interface from Field UI. We would lose the possibility to set the weight of the vertical tab, but this can be changed easily with a simple form alter, or by using a contrib module that specializes in this (eg Display Suite, Field Group, Renderable Elements, ...). I checked all comments in this issue but nobody requested reordering of the vertical tabs, so I guess it's fine to remove it. I suppose if you want to reorder the tabs, you would want to reorder several of them instead of only the Scheduler tab, and then you end up using one of those contrib modules anyway.

I've updated the patch with the following changes:

  • Replaced the weight with Field UI drag & drop. I also discovered that this was already supported in D6 but was apparently forgotten when the module was ported to D7.
  • Ordered the variables in scheduler_uninstall() alphabetically.
  • Added missing punctuation in a description.
  • Reordered radio buttons so the default option is at the top.
  • Refactored some verbose code to be a bit more compact.

I will assign this to myself for writing tests. I just wanted to get this patch out already to get some feedback.

jonathan1055’s picture

Yes it is better to have the draggable fields. That thought had crossed my mind. It is interesting how each new version of a patch improves on the previous one, and we might not get to the final enhanced version had we not made the intermediate steps. I built on the work done by three previous contributors, made significant changes, and you have done even more.

Interesting that hook_content_extra_fields() had been defined, as I cannot see that function in either the D6 or D7 api documentation. hook_field_extra_fields() was new for D7, so maybe it started out in the initial D7 alpha/beta version as hook_content_extra_fields() but got renamed?

I wanted to use the vertical patch weight, but I can implement that in my sites custom module. I've tested the patch, all works ok. Thanks for the other minor improvements too.

Jonathan

pfrenssen’s picture

Yeah this is the great strength of open source, every small change is potentially looked at by many people, and the end result is much better :)

Probably hook_content_extra_fields() was supplied by the CCK module in Drupal 6, which was reworked to become the Field module in D7.

pfrenssen’s picture

Assigned: pfrenssen » Unassigned
FileSize
7.5 KB

Added a test.

jonathan1055’s picture

For those who would like to alter the position of the scheduler vertical tab, now that this functionality is not in the latest patch, here is an example of how it can be done in your custom hook_form_alter()

  if (!empty($form['#node_edit_form'])) {
    if (isset($form['scheduler_settings']) && variable_get('scheduler_use_vertical_tabs_' . $form['#node']->type, 1)) {
      // Top tab (menu settings) weight is -2. Move scheduler to be the top tab.
      $form['scheduler_settings']['#weight'] = -5;
    }
  }

Jonathan

jonathan1055’s picture

Nice work. This is good and ready to go.

pfrenssen’s picture

Status: Reviewed & tested by the community » Fixed

Awesome! This has been committed: 7dbc925. Thanks everybody!

jonathan1055’s picture

Good team effort.
Now we will see if the Drupal.org D7 upgarde dev packaging and release process works. There have several issues relating to it in the QA list.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.