This post is a continuation of the overly long and messy discussion at http://drupal.org/node/32069.
In this thread are posted two different patches for flexinode that allow aministrators to take advantage of new functionality in Drupal 4.7 which allows custom title labels for content types.
The first patch, attached to this post, is much cleaner code-wise. The second patch, posted immediately below, is messier but perhaps slightly more user-friendly (or maybe not?) . I'm looking for feedback and comments on which method is preferred.
Note: Database update required!
The first patch requires you modify the database: you need to add a new varchar(255) field to the flexinode_type table in the database. The name of the field is "title_label". The second patch requires a a new int(1) field to be added to the flexinode_field table. The field's name is 'is_title'.
| Comment | File | Size | Author |
|---|---|---|---|
| #44 | timsetamp.jpg | 26.54 KB | bomarmonk |
| #30 | flexinode_titles_7.patch.txt | 9 KB | gnat |
| #28 | flexinode_titles_6.patch | 13.58 KB | gnat |
| #21 | field_timestamp_0.patch | 421 bytes | gnat |
| #20 | field_textfield.patch | 273 bytes | gnat |
Comments
Comment #1
Steve Dondley commentedSee post immediately above for an explanation of the patch attached here. Don't forget to make the change to the database (see above also).
Comment #2
bryan kennedy commented+1 for flexinode_titles_1.patch
Works great on my site now. I tried the other and it didn't seem to be any more "user-friendly" IMO.
Comment #3
bryan kennedy commentedOkay, I do notice one problem. My Path alias form feild is now showing up above the title for the flexinode. Ideally this should fit underneath the title.
Comment #4
scroogie commentedWhy dont you just make the node title a new field type? Then the user wont need no database update (and by the way it seems to be more in the flexinode style).
Comment #5
Steve Dondley commentedscroogie,
because the title field is so tightly integrated with the rest of Drupal, what you suggest won't work.
Comment #6
Steve Dondley commentedbryan,
This problem will have to wait until after the flexinode module gets converted to the new forms API.
Comment #7
scroogie commentedCan you tell me why it would not work? You could just copy the textfield type and change the save function to update the right entry in the nodes table.
Comment #8
Bèr Kessels commentedHaving no title is not an option in Drupal. Blocks, lists, and nearly al of the node administration will break. So if we need a title anyway, its best to just provide it, not? :)
Comment #9
scroogie commentedOkay, got that. Then Patch 1 gets my vote.
Comment #10
drummThis patch no longer applies to HEAD.
Comment #11
gnat commentedthis patch, which is written against the current cvs version, adds a checkbox to the flexinode field create/edit screen of text fields for flexinode content types called "Use as Title" which will set the input of that field as the the title in the node table. the option is checked in form validation to ensure that only one field per ctype is allowed to be a title. this requires an update to the database, which is provided with this patch.
in the create/edit content screens for those ctypes there is no 'Title' field in the form. instead the flexinode field appears as it would were it any other text field. i thought it advantageous to do it this way, since it gives a more complete control to the presentation of the form in terms of weight. though i realize others may disagree about this.
there are a few things that either need to be fixed, or would be cool features if they were added, but i wanted to submit what i had, to see if people liked the direction this patch is headed before spending more time on it.
those are:
Comment #12
gnat commentedhere's the mysql patch.
Comment #13
gnat commentedand the pgsql patch.
Comment #14
bomarmonk commentedA definite + on the concantenated fields option. This would be very useful for flexinodes where you wanted the node title to reflect a first and last name--- something I would definitely like to accomplish!
Comment #15
gnat commentedThis patch is an addition to my previous patch, which does a few of the things that I was hoping it would do, namely:
Adding in a second field requires another database change (new db structures below). It has also remade my to-do list on this change. As it stands it is:
Comment #16
gnat commentedmysql structure.
Comment #17
gnat commentedpgsql structure.
Comment #18
Bèr Kessels commentedGreat work so far, but IMO a tiny bit crufty still:
I think it is best when you not prompt an error "more then two are chosen" but rather insert the active title field and set the current one.
We should IMO not hardcode what can be titles and what not. Why not add a very simple hook call to he incs that allows any .inc to be candidate for a title:
fieldname_can_be_title() if returns TRUE, that field will be candidate for a title
Watch your coding style, quite often you forget indentations.
Please choose your functionnames carefully, not flexinode_uat_check_fields but rather flexinode_check_title_usage
Bèr
Comment #19
gnat commentedthis is another update to my patch, here's what's done in this iteration.
Comment #20
gnat commentedpatch for field_textfield.inc
Comment #21
gnat commentedpatch for field_timestamp.inc
Comment #22
Bèr Kessels commentedLooks a lot better. Thanks.
Can someone else have a look at this too? I am not confident to call my quick patching and checking actually is reviewing. Flexinode is rather comlpex :)
Some very very minor things: gnat, please check your editor for it adds a lot of spaces like }_____ And also, in some future, rather just commit your changes as one patch, instead of a patch per file. That is a lot easier for all of us to review.
Comment #23
rlbravo commentedDoes this patch works in version 4.6.3. Thanks Steve.
Comment #24
Steve Dondley commentedComment #25
Steve Dondley commentedrlbravo: do not change the title
Comment #26
gnat commentedalso, don't change version, compnent, and category.
Comment #27
Bèr Kessels commentedgnat: I want to get this feature in the 4.7 branch soon.
Can you
* Provide a SINGLE patch. Tracking amd reviewing four patches (for each file one) is very hard.
* Provide an updated patch?
Bèr
Comment #28
gnat commentedThis is a single unified patch that encompasses the five edited files for this feature (field_textfield.inc, field_timestamp.inc, flexinode.module, flexinode.mysql, flexinode.pgsql). There are no significant changes to what I have done in the code, though I did clean up the stray spaces. The flexinode module in the diff is done against the latest cvs file: flexinode.module?rev=1.66.
I would still like to add functionality for the 'delimeter', but was not sure exactly where to put that. Is this something that should be part of the ctype information? I would like some feedback on where such a thing should go. Bottom line having a hard coded ' - ' to deliminate the two elements of a title should not be the way it is done. So somewhere a select box needs to be added so that it can be more tailored to the user's needs, some of the other things I can think of are ' ' (one space), ' ' (two spaces), ',' (comma/comma space), etc. I'm just not sure where it should be added and what table in the DB it should be a part of. So if anyone has thoughts on that, and helps come up with a good strategy, I would be more than happy to write the code. :)
Comment #29
Patrick Nelson commentedFirstly, works superbly - thanks for the patches and the efforts of all involved.
Secondly, in light of the removal of node_validate, are there any changes to be made to these patches? There are changes that need to be made to code in the CVS version of flexinode but some of the code that needs to be changed has already been modified by these patches?
Comment #30
gnat commentedThis patch removes the use of node_validate_title() from my patch.
Comment #31
Patrick Nelson commentedThanks gnat,
That works for me.
Comment #32
Patrick Nelson commentedOK, I lied.
I'm getting an error now when viewing any flexinode content that seems to be related to this latest patch.
The error reads:
Warning: Illegal offset type in /var/www/modules/flexinode/flexinode.module on line 451Where line 451 is as below:
The reason I say "seems to" is because I have also updated to flexinode 1.68.
If this error is not related to this patch, I'll open a new issue, but I could do with some help figuring out why it's occuring in the first place.
Many thanks
Comment #33
Patrick Nelson commentedThe "...." tags are not in my module - that's just me trying to emphasise that line in this post.
Comment #34
Steve Dondley commentedI can't view the mysql patches. Acess is forbidden.
Comment #35
Steve Dondley commentedOK, was able to figure out what db fields to add by looking at the patch.
If I understand the patch correctly, it seems like it should concatenate two fields together if there is more than one field marked as "use as title". This feature does not seem to work.
Comment #36
Steve Dondley commentedOK, not sure what just happened but I disabled one of the title fields and then re-enabled it. And now that field says "second part of title".
So the module works, but it seems you have to enable the two title fields a certain way. I consider that a bug.
Comment #37
bomarmonk commentedDoes this new custom title work for the 4.7 version of flexinode? Is it working well enough to run on a live site? Thanks for any information. Tempted to try...
Comment #38
bomarmonk commentedCan anyone tell me how to apply the database changes for this patch? I think I have all the files properly patched, but I'm not sure how to run the sql updates included here. I would really like to have this feature. Thank you for any help!
Comment #39
Steve Dondley commentedAdd the following fields to the flexinode_data table
Comment #40
Steve Dondley commentedDamn, sorry! That last post should say change the flexinode_field table (not flexinode_data).
Comment #41
bomarmonk commentedThis patch works! Very nice! I can confirm the odd behavior with the second field being combined with the title. Disable the second field, reenable it, and magically the text appears: "make second part of title." A minor bug.
Also, since I converted existing flexinodes (with preexisting titles), the old title stayed around. After getting those fields to set properly to title, I had to edit each flexinode and resubmite (changing nothing), in order for the new fields to display properly as title. Could the module change for the preexisting titles and disable them somehow, without having to resubmit all the flexinodes with the new title setting?
One more minor quirk: I had a flexinode with a first name field (one of the title fields) and one of these names included a nickname in quotes. It seemed as though this new patch didn't know how to deal with the quotes-- they broke and became something like "e;
Finally, would it be easy to have an option to change the delimineter between the fields in the title? I have a first and last name, so a comma seems most logical. Right now, I get a dash.
This is awesome, though. Thanks for your work on this patch. I hope it gets into the 4.7 version of flexinode. For now, its been worth the patching.
Comment #42
bomarmonk commentedOne more thing: the earlier functionality of having a different label for the title goes hand-in-hand with this latest patch. I hope someone can carry that over and combine it into a unified patch... or a seperate one, since I have already applied the use_as_title patch.
Comment #43
bomarmonk commentedSorry, I noticed that the author of this patch already discussed the delimineter, so my earlier comment is redundant. I was thinking about how to include a dilemeter: you would want it on a per-content type basis, so that all content types can concatenate the fields with a different seperator. So maybe this should be a seperate textfield for flexinode, where the user can put in anything he or she wants? Or a drop-down of deliminiters that becomes available after two fields have been enabled as the title? The values for the dropdown could be stored in a list within the general flexinode settings page (that sounds a bit tricky, but that might be nice). By default, if the delimiter is not chosen, we get the dash.... just my two cents.
Comment #44
bomarmonk commentedWell, I have this working with two textfields, but when I try to use the timestamp/date as the title (only this, no other field), the title just doesn't show itself. The option is there: make this a title. I enable this and the edit-form excludes the traditional title field-- so far so good. Then, when looking at the node in the content area, or in a list, the title does not appear (you can see the date if you look at the full node).
Please have a look at this and see if it can be replicated. Thanks. I am attaching a image of the problem (see how the blotter entry looks)
Comment #45
adamrice commentedDoes anyone have this working on the latest release of Flexinode? This patch would be useful to me, but naturally I'd rather mess with the final release of the module for 4.7 than some unreliable pre-release version <g>