We had the need for the following functionality in our project:
- Be able to change the prefix / suffix to the Item titles. i.e. change the Item title from "News articles" to "News"
- Be able to determine if we wanted a content element to open in the current window/tab (usually for content from the site) or to a new window/tab (usually for external content)
I have attached a patch for mysite.module that enables this functionality to this post, and the next post will have the patch for all the files in the "plugins/types" directory. Please let me know if the patch is ok, or if you would like to see some changes.
Comments
Comment #1
mdekkers commentedthe plugins/types patch
Comment #2
mdekkers commentedDoh! credit where credit is due. This work has been done for us by the lovely Tatyana Dekhnich who works with the great people at DevelopmentMill. All errors are mine, all the good stuff is hers!
Comment #3
agentrickardI like the basic settings approach -- being able to override prefix, suffix, link type in the UI -- but I have a few issues. (Note, this is based on reading the patch, not applying it).
1) The patches are out of date. That is, they are written against older versions of HEAD. They should be refactored against the end of the 5--2 branch. For example:
This reverts a correction that I made recently that makes debugging a lot easier.
2) I like the form_submit piece -- stuffing all the type settings into a single array seems like a good idea. But you will also store the op, token, submit, and form_id values the way it is written now. I typically unset() the values I don't want before processing. Something like:
3) The plugin patch is a little inconsistent. In aggregator, the 'link_target' is coded into the array. In other cases, it is merged from the settings. Consistency here. I would not add 'link_target' to the $type array. Assume that cases other than an empty target are special.
4) Be forewarned that I'm rewriting the menu from scratch for 5.x.3. In order to allow multiple pages, I have to change some of the variable handling to accept an argument allowing for multiple pages per user.
-----
Those points aside, I love the fact that your team wrote and submitted a patch for this behavior. If this module is going to move forward, we need contributors other than me.
Comment #4
mdekkers commentedhi :)
1.) ahem yes. we are on the final leg of delivering the project, and are a bit rushed. This was actually written against an earlier version that we then updated etc. i will get this cleaned up.
2.) cool, looks like a great aproach. I'll get this sorted.
3.) yeah agreed, we'll clean this up. as I said earlier we are in a huge rush to get stuff out of the door, so ...erhm... consistency may have suffered :)
4.) cool. Is this in your devel code, or svn? we need to track your (awesome) module quite closely so this kind of stuff is key for us to feed into
Also, we are currently fixing an issue with locked Items, currently you can move an unlocked item above a locked one, but then the whole page messes up. I'll post the patch when its ready - should be somewhere this week.
We have some more things we are doing around mysite, but due to the contract this is developed under, I have to follow a review process before I can submit the patches. fortunately, my client is very open source friendly and i dont forsee any issues
Comment #5
agentrickardYes, the locked items code is a little flaky and hasn't been stress tested.
And I was wrong before: patch new features against HEAD. I branched 5--2, which means its in bugfix only mode.
So patches for these go to:
Bug fixes to content locking => 5--2.
Settings for prefix/suffix => HEAD
Changes to content locking => HEAD
The current menu changes are simply on my dev machine; I have some serious testing to do before I commit anything. When menu changes hit, they will be committed to HEAD.
Comment #6
agentrickardComment #7
tatyana commentedHello!
Thank you for your comments!
There is new patch. I took HEAD version of module and added all changes again, so now all should be ok.
About settings form submit. I use there filter by key of form value, so don't see why i should use there unset(), only values with key like 'mysite_type_'. $type .'-'.$setting_name will be saved, so we can add other fields on form like hidden field 'type', for example, and we don't need change this function.
Please, let me know if you see there better way.
Thanks!
Comment #8
mdekkers commentedComment #9
agentrickard@tdekhnich, yes, filtering by the $key should work. I haven't tested the patch; I just read it.
Using unset() would just strip the $form_values() that are there by default. Under your method, anything not explictly named
'mysite_type_' . $typewill get removed.Two ways to solve the same problem.
This new feature will be rolled into the 5.x.3 release. I think it's great.
With luck, I'll be able to test this patch next week. I'm about to depart for DrupalCON Barcelona (going to Madrid first).
Comment #10
agentrickardIf we're being really good, then the plugin changes will also be applied to elements in the 'contrib' folder. I can do those if you don't want to alter the patch.
Comment #11
agentrickardLooks like there is a line-break incompatibility in that patch. Look at the section for post.inc.
The files should all be Unix-style line breaks. Looks like your are Windows, so all the returns were transformed to double-returns. As a result, the patch rewrites the entire file in that case.
The original post.inc code from heebiejeebieclub was malformed, and I didn't correct it.
I'll have to reload post.inc into HEAD so you can reroll the patch.
Comment #12
mdekkers commentedI'll reroll the patch tomorrow, do the unix line break thing (I work on Linux mainly, Tatyana is on windows) and split out the contrib stuff from the mysite.module
Have fun in Barcelona! I am still not sure if I'll make it there (need to finish this project) but if i do beer's on me!
Comment #13
agentrickardI just committed the linebreak fix to HEAD and 5--2.
Comment #14
tatyana commentedseparate patch for mysite.module
Comment #15
tatyana commentedseparate patch for types
Comment #16
agentrickardHope to test this week. Thanks!
Comment #17
agentrickardI finally tested the patch and it works great.
I cleaned up a few code style elements, added the routines to the items in the plugins folder, and will commit to HEAD.
Only code error I saw:
You don't need to call
cache_clear_all()after runningvariable_del(). See http://api.drupal.org/api/function/variable_del/5.Thanks to everyone who worked on these patches. This is the first new contributed functionality for the module.
Comment #18
agentrickardNow in HEAD.
Comment #19
agentrickardThere was a logic bug that caused the Theme configuration options to disappear.
The attached patch has been committed to HEAD.
Comment #20
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #21
agentrickardSee http://drupal.org/node/219879
Comment #22
agentrickardSee http://drupal.org/node/219879 for the patch.
Comment #23
agentrickardThis has been committed to HEAD.