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

mdekkers’s picture

StatusFileSize
new36.6 KB

the plugins/types patch

mdekkers’s picture

Doh! 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!

agentrickard’s picture

I 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:

-  drupal_set_message(t('Could not find aggregator data'), 'error');
+  drupal_set_message(t('Could not find data'), 'error');

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:

  $temp = $form_values;
  $unset = array('form_id', 'token', 'op', 'submit');
  foreach ($unset as $str) {
    unset($temp[$str]);
  }
  # now process what's left
  foreach ($temp as $key => $value) {
      ....
  }

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.

mdekkers’s picture

hi :)

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

agentrickard’s picture

Version: 5.x-2.11 » master

Yes, 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.

agentrickard’s picture

Status: Needs review » Needs work
tatyana’s picture

StatusFileSize
new40.39 KB

Hello!
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!

mdekkers’s picture

Status: Needs work » Needs review
agentrickard’s picture

@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_' . $type will 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).

agentrickard’s picture

If 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.

agentrickard’s picture

Status: Needs review » Needs work

Looks 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.

mdekkers’s picture

I'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!

agentrickard’s picture

I just committed the linebreak fix to HEAD and 5--2.

tatyana’s picture

StatusFileSize
new4.29 KB

separate patch for mysite.module

tatyana’s picture

StatusFileSize
new15.57 KB

separate patch for types

agentrickard’s picture

Status: Needs work » Needs review

Hope to test this week. Thanks!

agentrickard’s picture

Status: Needs review » Reviewed & tested by the community

I 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 running variable_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.

agentrickard’s picture

Status: Reviewed & tested by the community » Fixed

Now in HEAD.

agentrickard’s picture

StatusFileSize
new2.16 KB

There was a logic bug that caused the Theme configuration options to disappear.

The attached patch has been committed to HEAD.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

agentrickard’s picture

Status: Closed (fixed) » Needs work
agentrickard’s picture

Status: Needs work » Needs review
agentrickard’s picture

Status: Needs review » Closed (fixed)

This has been committed to HEAD.