Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Safest method to add extra custom fields
Hi.
I’m one of those people that uses custom fields a little bit too eagerly, and I’ve run out of the default 10. I know about the 2005 old-school method and the related glz_custom_fields plugin, plus I also know from 4.2.0 there was support for additional custom fields in core. My question, and I can’t find anything in the FAQ, is whether there is a best practise or safest way to add/enable extra custom fields in core so (ideally) that when new a new version comes around I don’t have to hack the install to get around the manual changes I made to the core code (per the manual instructions here at Gerhard’s site).
Thank you in advance.
-Pete
Last edited by gaekwad (2011-02-12 09:28:03)
Offline
#2 2011-02-12 18:45:40
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,315
Re: Safest method to add extra custom fields
The plugin is best practise.
Gerhard is the author of both the core hack and glz_cf which he developed after publishing the hack. It’s actively maintained, thus I would avoid hacking the core files.
(Where I as a Txp user can perceive the core support of more than 10 cfs is beyond me, I think it’s easier for plugin authors to develop in 4.2+)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: Safest method to add extra custom fields
Thanks, uli. Regarding the changes made in core, do they just facilitate more fluid use of glz_custom_fields, or was there something more fundamental involved?
Regarding using >10 custom fields, I have a Textpattern project which uses the following named fields:
i) article-meta-description (which populates the meta description in <head>
)
ii) article-target_URL (which is an external link output in 3 places for some articles, and a URL value for iCalendar entries)
iii) article-cmply (a tag for listing the cmp.ly status)
iv) article-licence (a tag for listing the CC licence)
v) article-topbar-right (which populates a 728×90 banner ad)
vi) coupon-tracking-image (affiliate marketing transparent tracking image)
vii) coupon-code (lists a coupon code)
viii) zeroclipboard-text (custom Javascript alert text when ZeroClipboard does it’s thing)
ix) DTSTART (another iCalendar entries tag)
x) DTEND (yet another iCalendar tag)
…which makes ten :) I’m making use of about 6 or so other article-specific tags and elements to populate fields. Clearly I’m an exceptional case, but I suspect if 20 fields were made available as standard, there would be people who could fill them.
Last edited by gaekwad (2011-02-13 08:53:05)
Offline
#4 2011-07-22 09:43:18
- HarryG
- Member
- Registered: 2011-01-12
- Posts: 21
Re: Safest method to add extra custom fields
Gaekwad,
Clearly I’m an exceptional case, but I suspect if 20 fields were made available as standard, there would be people who could fill them.
I don’t think it’s an exceptional case. I’m trying to build an e-commerce bookshop, and need 15 variables. See
http://forum.textpattern.com/viewtopic.php?pid=249600 and trenc’s nice reply.
Offline
Re: Safest method to add extra custom fields
Hello !
I wrote an article on my german blog about this. Anything is done with 3 SQL queries, here is the english version:
First, alter the textpattern table so each article has an column for the custom field:
ALTER TABLE `textpattern` ADD `custom_11`;
Second, update txp_prefs to make the new custom field avaible:
INSERT INTO `txp_prefs` (`prefs_id`, `name`, `val`, `type`, `event`, `html`, `position`, `user_name`) VALUES(1, "custom_11_set", "", 1, "custom", "custom_set", 11, ""); UPDATE `txp_prefs` SET `val`=11 WHERE `name`="max_custom_fields";
Thats it ! You can configure the new field as you are used to.
Optionally, add an txp_lang row:
INSERT INTO `txp_lang` (`lang`, `name`, `event`, `data`) VALUES("en-en", "custom_11_set", "prefs", "Name for my new custom field 11");
Alternatively, there are some plugins1 to store more than one value per custom_field.
1 sed_packed_custom_fields, aam_split_custom_field
Last edited by arkandos (2011-08-13 17:39:11)
Offline