Textpattern Forum

You are not logged in. Register | Login | Help

#1 2006-06-08 04:30:32

net-carver
Admin
From: UK
Registered: 2006-03-08
Posts: 1,648

[plugin] [ORPHAN] sed_pcf: Packed Custom Fields.

sed pcf

PCF = Packed Custom Fields
Version: 0.3
Here’s a link to the PCF homepage.

Summary

There has been a bit of talk on the forum recently about custom fields and their various uses for per-article data. So I figured I’d throw this into the arena.

This plugin allows you to pack multiple values into one custom field—and to structure the packed values into “sections” which, for this purpose, are just a named group of packed values. There are tags for use in article forms to allow you to test for the existence of a named value in a section (and to test for equality with a given value) and also to access values by section + name.

If you are a heavy user of custom fields and are starting to run out then this might be useful—no need to resort to hacking TXP to get more fields! (Apparantly it does work with the extra custom field hack too!)

It also includes a tag to allow the output of a TXP email link from part of a packed custom field.

I haven’t included tags for building script sections or linked style sheets for the page header as Bastian covered that with his little plugin.

New To This Version.

  • Added a very flexible new tag sed_pcf_for_each_value which will iterate over a field in CSV format and parse the given form (or the contained contents of the tag) once for each value in the field.
  • This is shamelessly based upon Robert’s wet_for_each_image plugin.

Field Format.

There are now three possible field formats: CSV, simple format and full format.

CSV

  • a,b,c — simple as that! This is only used by the sed_pcf_for_each_value tag.

Simple Format goes like this… nameA=‘valueA’;nameB=‘valueB’;nameC=… etc. It takes up the entire custom field.

Full Format
You can create named “sections” in a custom field and store multiple name=‘value’ pairs within each named section.

In abstract form you do this: section1(nameA='valueA';nameB='valueB')|section2(nameC='valueC')

And a concrete example would be: copyright(owner='King Harold';start='1066')|email(email='king.hhastings.org.uk’;linktext=‘King Harold’)@

You could then test for values in your article/misc forms like this…

<txp:sed_pcf_if_value custom='your_custom_fieldname' section='copyright' variable='owner'>
&copy; <txp:sed_pcf_get_value custom='your_custom_fieldname' section='copyright' variable='owner'/>
<txp:else/>
... your default stuff here.
</txp:sed_pcf_if_value>

Watch out though, custom fields are varchar(255) in the TXP tables so don’t use strings that are too long (unless you use phpMyAdmin or some such tool to change the field format)

I hope you find it useful.

Please feed back with ideas/bugs.

Last edited by net-carver (2008-01-02 08:03:22)


Steve
Textile | My plugins on GitHub | @netcarver

Offline

#2 2006-06-08 11:38:19

kemie
Plugin Author
From: mexico<-->sweden
Registered: 2004-05-20
Posts: 491
Website

Re: [plugin] [ORPHAN] sed_pcf: Packed Custom Fields.

:o sounds awesoooomeee


~~~~~~~~~~~~~| monolinea.com | pixilate.com | istockphoto.com/kemie |~~~~~~~~~~~~~

Offline

#3 2006-06-08 16:14:16

mrdale
Moderator
From: Walla Walla
Registered: 2004-11-19
Posts: 2,051
Website

Re: [plugin] [ORPHAN] sed_pcf: Packed Custom Fields.

net-carver is on fire… Very cool.

Offline

#4 2006-06-10 16:56:50

net-carver
Admin
From: UK
Registered: 2006-03-08
Posts: 1,648

Re: [plugin] [ORPHAN] sed_pcf: Packed Custom Fields.

V0.2 out now…

  • Added value comparison to the if_value tag.
  • Added a tag to test if a named section appears in the packed field.
  • Added tags to output images and thumbnails from packed fields.

Steve
Textile | My plugins on GitHub | @netcarver

Offline

#5 2006-06-12 10:59:12

stdmedia
Member
From: Canada
Registered: 2006-01-05
Posts: 51

Re: [plugin] [ORPHAN] sed_pcf: Packed Custom Fields.

This is exactly what I was looking for! Thank you so very much.

Offline

#6 2006-09-18 17:35:12

marios
Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: [plugin] [ORPHAN] sed_pcf: Packed Custom Fields.

This netcarvers plugin, should be very useful , to make it even more interesting, you could combine it with
this <a href=“http://forum.textpattern.com/viewtopic.php?id=17545”>hack</a> (courtesy Ace of Dubs).

This would allow you to extend your custom fields to text format, as already mentioned above, and have them easily maintainable,
as extra excerpts fields, below your default excerpt field.
(useful, for extra teaser or welcome blurbs, etc…, or any other text content, that you would like to stay attached to an article)

I found it to work on 4.0.4 development versions as well, however my database broke at times, so I ‘m not able to confirm any side-effects.
(Runs stable now)

(CAUTION.: dump your database for backup, before doing this)

regards, marios


⌃ ⇧ < ⌃ ⇧ >

Offline

#7 2006-09-19 03:52:16

net-carver
Admin
From: UK
Registered: 2006-03-08
Posts: 1,648

Re: [plugin] [ORPHAN] sed_pcf: Packed Custom Fields.

Marios,

thanks for the feedback.

Ace’s work extends the custom fields to type ‘text’ from varchar(255) — that will allow you to pack a lot of values into a field!

I don’t think this plugin will have messed up anything on your DB as the plugin is read-only in operation.

FYI: I have prepared a local version with a few changes for 4.0.4 (no new features) but I won’t be releasing it yet. In fact, I’ll be offline for a week (perhaps longer) to move house.


Steve
Textile | My plugins on GitHub | @netcarver

Offline

#8 2006-09-22 00:57:27

rawtext
Member
From: Massachusetts, USA
Registered: 2006-09-13
Posts: 21

Re: [plugin] [ORPHAN] sed_pcf: Packed Custom Fields.

I don’t know if it’s been suggested, but would packs within the body be a good idea? I have a project that doesn’t require data in the body because all I need is the food title, and prices for large and small which will be from customfield input. If I could eliminate using custom fields to begin with it might be easier for the end-user?

I only say this because textpatterns customfield function although very usefull, doesn’t have the organization ability or customization that I would like. I could name a few good reason’s for it not being ready for prime time in end-user world, but I know they’ve been brought up before on the forum. (ex: explaining what not to touch and that they have to work around unrelated options and fields when using customfields) Ah well, just brain-storming.

Offline

#9 2006-12-18 18:47:04

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

Re: [plugin] [ORPHAN] sed_pcf: Packed Custom Fields.

@Steve: What about the availability for 4.0.4?

I love the idea of having a complete dataset in one custom field … just stumbled upon your plugin.


Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML

Offline

#10 2006-12-19 08:03:45

net-carver
Admin
From: UK
Registered: 2006-03-08
Posts: 1,648

Re: [plugin] [ORPHAN] sed_pcf: Packed Custom Fields.

Markus

sorry, my time is being focused on the MLP Pack for Textpattern right now hence the slow (ok, zero) progress here.

However, if you are willing to test the latest version for me then I can mail you a copy. Just drop me a line via the contact page of my website and I’ll post it off to you as soon as I get your details.


Steve
Textile | My plugins on GitHub | @netcarver

Offline

Board footer

Powered by FluxBB