how to change weight of event repeat ?
BobLouis - March 28, 2007 - 18:32
| Project: | Event Repeat |
| Version: | 5.x-1.0 |
| Component: | User interface |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | patch (code needs review) |
Description
Hi all,
I've installed the great event repeat module.
The problem is it weights " -10 " by default, and so it is displayed above all the other fields when someone wants to create a new event.
Do you know how to change the event repeat weight?
Contrary to the other fields, it is not possible to change it from "Content Management / Content Type".
Thank you for your help!

#1
Is it correct to assume you are talking about the weight of the event repeat field set in the node form? As I see it, the field set is just under event module's form elements. Please let me know what configuration you have where it is in the wrong place. It sounds like the issue is that you different weights on some CCK elements, but because eventrepeat is a nodeapi element, it does not have the option to change the weight?
You can always change the weight of that element in the theme, if that would help.
#2
Sean,
Thank you for your answer.
Yes, I am talking about the weight of the event repeat field set in the node form (I actually created a new content type, and gave it event "properties"). The field was indeed just under event module's form elements, before I managed to change the weight of these. So now the event repeat field set stands above all the other fields, in the submit form used to create content.
My config is Drupal 5.1, with event, event repeat, content template modules installed.
So you're saying that I can "change the weight of that element in the theme" : how do I do that? It seems that changing it in the theme will only work for displaying the node once it is submitted. I just need to change the weight of the event repeat field set within the submit form for that event.
Your help is appreciated !
#3
You can check out http://api.drupal.org/api/4.7/file/developer/topics/forms_api.html for more information about theming a form page. Scroll down to the "Theming Forms" heading near the bottom of the page and look at point 2.
Your theme override function in template.php would probably look something like this:
<?phpfunction phptemplate_whateveryournodetypeis_node_form($form) {
$form['eventrepeat']['#weight'] = whateveryouwantittobe;
$output .= form_render($form);
return $output;
}
?>
I haven't tested this, so you might have to play with it.
You should be able to also create a phptemplate_eventrepeat_form function, but I'm not sure that this will stay a theme_ function as opposed to an internal (non-theme) function. You probably shouldn't use that.
Otherwise, if this should be a feature of the module, let me know.
#4
Thank you very much Sean: it works just fine now!
I used the following code:
function phptemplate_mycontenttype_node_form($form) {$form['eventrepeat']['#weight'] = -2;
$output .= drupal_render($form);
return $output;
}
Just for information, I replaced the 'form_render' function (which was not recognized) by 'drupal_render' function, as explained in the theming API documentation you mentioned.
To answer your question, I think it would be useful to include it as a feature in the module, especially for non-programmers like me! However, it's true that it's been pretty easy to "hack".
Thank you again very much for your support !
#5
No problem. I'll leave this open for the time being, while we discuss the next steps for eventrepeat. At the very least, a simple "weight" setting seems like it will be useful.
And sorry about that form_render call. It was from 4.7 and was replace with drupal_render.
Finally, just to be precise, the "$output .=" might give you a php warning if you did not declare $output beforehand.
Cheers!
#6
I'm having a bit of difficulty with this.
I have a template.php file that I'm using to declare additional regions.
So I added this to the file:
function phptemplate_event_node_form($form) {$form['eventrepeat']['#weight'] = -2;
$output .= drupal_render($form);
return $output;
}
But obviously I'm doing something wrong, as the weight has not changed.
Any ideas?
I'm running 5.1 with events and event repeat. I'm using the basic event module to create my events.
Thanks!
#7
jsimonis,
I added a "This was themed" message in there and that worked. then I changed the weight to 20, and it moved the fieldset down. Looking at the surrounding elements, event start and event end have a weight of -15 and -14, and title has a weight of -5. You might not be noticing a big difference between -2 and -12. Consider putting a print_r($form); in your phptemplate_event_node_form function to see what it is doing.
Let me know if it works for you.
#8
Hello,
I've installed the last version of the eventrepeat module.
And now again in the forms, event repeat stands above the other fields, like it did before applying the following code into template.php (cf. above posts):
function phptemplate_concert_node_form($form) {$form['eventrepeat']['#weight'] = 4;
$form['event_start']['#weight'] = 2;
$form['event_end']['#weight'] = 3;
$output .= drupal_render($form);
return $output;
}
So now even with this code, event repeat is still above all the other fields.
Any idea of the problem?
#9
This patch will set the eventrepeat fields to be one "unit" heavier than the weight of the "event" unit, so it will presumably appear directly below the event field.
#10
check http://drupal.org/node/145529 for a way to set the weight of the entire event module as well.
#11
Anonymous5190 thank you for your patch. But it doesn't work for me:
I have the following error message:
patch eventrepeat.module < eventrepeat.module.weight.patchpatching file eventrepeat.module
patch unexpectedly ends in middle of line
Hunk #1 FAILED at 992.
1 out of 1 hunk FAILED -- saving rejects to file eventrepeat.module.rej
Saved "rejects" are:
***************
*** 992,998 ****
'#tree' => FALSE,
'#collapsible' => TRUE,
'#collapsed' => $collapsed,
- '#weight' => -12,
);
--- 992,998 ----
'#tree' => FALSE,
'#collapsible' => TRUE,
'#collapsed' => $collapsed,
+ '#weight' => variable_get('event_weight',-15)+1,
);
Since I'm not a programmer, could you explain what to do next?
#12
It's possible that you have a different version of the module than me, so the patch may not be applicable at all. If you want to try anyway, probably the simplest thing to do is to back up eventrepeat.module and then edit it. Find the line that says
'#weight' => -12,
and change it to say
'#weight' => variable_get('event_weight',-15)+1,
I'm actually not using eventrepeat anymore (I switched to the date/time cck field combined with calendar module) so I can't really support this patch beyond that.
#13
Thank you. I actually solved my problem by editing the line directly, as you mentioned.
#14
I might be missing something obvious here, but I can't seem to find the event_weight variable setting in either the 5.x-1.0 or HEAD (which I believe is 5.x-2.x) versions of the event module. I'm obviously missing something obvious. Any hints are welcome.
As an alternative, would everyone prefer a simple option in the settings page to set the weight?
#15
This whole patch is based off another patch I made to enable configurable weight for the event module - the event_weight variable is defined and customizable there, so you need that applied to the event module to take advantage of this patch to the event_repeat module.
Really, they should be combined into one, but since they affect different modules I listed this patch separately.
#16
Would a configurable weight for eventrepeat be a good way to go?
#17
Yeah, but this patch combined with the one I previously linked should accomplish that, or at least allow the entire "block" of event-related fields to be custom-weighted. Are you trying to do something different that this doesn't work for?