Links on this page…

Plugins! feed.feed icon

TXP Plugins! is powered by Textpattern and most happily hosted by DreamHost.

PCF/Packed Custom Fields

This plugin allows you to pack multiple values into one custom field—and to structure the packed values.

If you are a heavy user of custom fields this might be useful for you.

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

Download

The current version and previous versions will be listed here.

PCF Manual

sed_pcf plugin, v0.2 (June 11th, 2006)

This little plugin allows you to use an article’s custom fields to store multiple, named, values. The packing must follow a specific format. The tag list includes tags to test for a value in the field and to access a value from a field.

Tag Directory

Tag Description
code>sed_pcf_get_value Returns the named value from the named section of the named custom field.
code>sed_pcf_if_value Tests for the existence of a named value in a named section of a custom field.
code>sed_pcf_if_field_section Tests for the existence of a named section of a custom field.
code>sed_pcf_email Uses the values in a named section of a custom field to call the TXP email tag.
code>sed_pcf_image Uses the values in a named section of a custom field to call the TXP image tag.
code>sed_pcf_thumbnail Uses the values in a named section of a custom field to call the TXP thumbnail tag.
sed_pcf_for_each_value Uses the values in a named section of a custom field to call the TXP thumbnail tag.

The get_value tag

This tag can take the following attributes…

Attribute Default Value Status Description
‘custom’ ‘’ Needed Name of the custom field to access.
‘section’ ‘’ Needed Name of the section within the field to access.
If you are using the simple packing format then set this to ‘none’.
‘variable’ ‘’ Needed Name of the variable within the section.
‘default’ NULL Optional The value to return if the access fails.

Emphasized items have been added or changed since the last release.
Struck out items have been removed since the last release.

The if_value tag

Attribute Default Value Status Description
‘custom’ ‘’ Needed Name of the custom field to access.
‘section’ ‘’ Needed Name of the section within the field to access.
If you are using the simple packing format then set this to ‘none’.
‘variable’ ‘’ Needed Name of the variable within the section.
‘val’ NULL Optional If specified, this value will be checked against the named variable from the named section of the named custom field.

If the value is present and equal to a suppled val then the contents of the contained tag will be evaluated. If there is an else section then that will be evaluated if the value is not present or if it is present and fails to match the val attribute.

The if_field_section tag

Attribute Default Value Status Description
‘custom’ ‘’ Needed Name of the custom field to access.
‘section’ ‘’ Needed Name of the section of the packed field to test for.

If the named section exists within the named custom field then the enclosed part of the tag is parsed.

The email tag

Attribute Default Value Status Description
‘custom’ ‘’ Needed Name of the custom field to access.
‘section’ ‘email’ Optional Name of the section within the field to grab the values to pass to the TXP email tag.
If you are using the simple packing format then set this to ‘none’.
‘default’ NULL Optional The value to return if the access fails.
‘parse’ false Optional Set this to true to force a the contents of the packed field to be parsed before being used to call the TXP email function. This means that it is possible to use attributeless tags (such as <txp:s/> as arguments to the email call.

Allows you to setup email links on a per-article basis. You need to setup the custom field you are going to stash the email values in. Then add this to the article body or article form <txp:sed_pcf_email custom='my_field_name'/>. Replace the ‘my_field_name’ as needed.

Next, in the custom field itself, make sure you have email(email='ab.c’;linktext=‘foo’;title=‘bar’)@. Replacing the values as you need.

The image tag

Attribute Default Value Status Description
‘custom’ ‘’ Needed Name of the custom field to access.
‘section’ ‘image’ Optional Name of the section within the field to grab the values to pass to the TXP image tag.
If you are using the simple packing format then set this to ‘none’.
‘default’ NULL Optional The value to return if the access fails.

Allows you to display an image based upon the contents of a section of a packed custom field. If you want to use a second layer of tags then that is possible providing they are attributeless tags such as <txp:author/> or <txp:s/>.

The thumbnail tag

Attribute Default Value Status Description
‘custom’ ‘’ Needed Name of the custom field to access.
‘section’ ‘thumbnail’ Optional Name of the section within the field to grab the values to pass to the TXP thumbnail tag.
If you are using the simple packing format then set this to ‘none’.
‘default’ NULL Optional The value to return if the access fails.

As for images, so with thumbnails!

The for_each_value tag

This can be used as an enclosing tag, or with a form, or as a single tag. It was inspired by the wet_foreach_image plugin and works in a very similar manner.

Attribute Default Value Status Description
‘name’ ‘custom1’ Needed Name of the custom field to access.
‘debug’ 0 Optional Set to 1 to output extra debug info
‘form’ ‘’ Optional Form to use to format output
‘label’ ‘’ Optional Label text for the output
‘labeltag’ ‘’ Optional tag for the label
‘wraptag’ ‘ul’ Optional Tag to wrap the whole output in — you might want to set this to ‘’ if using a form.
‘break’ ‘li’ Optional Tag to wrap each individual value’s output in — again, you may want to set this to ‘’ if your form wraps the output.
‘class’ ‘custom1’ Optional Class to apply to the wrapped output

This tag can be used in three ways…

  1. As a single tag with default layout… <txp:sed_pcf_for_each_value />
  2. As a single tag using a form for layout… <txp:sed_pcf_for_each_value form="your_form" />
  3. As an enclosing tag… <txp:sed_pcf_for_each_value>... your stuff here...<txp:sed_pcf_for_each_value />

The enclosed section, default or supplied form will get parsed once per value in the custom field’s list.

On each parse, the string '{value}' will be replaced by the corresponding value from the custom field.

The default layout, used in the absence of a form or contained section, is ‘{value}’.

Field Formats

There are three formats you can use in your custom fields.

ForEach Format.

This format can only be used by the sed_pcf_for_each_value() tag. It’s a simple comma seperated list of values…

Simple Format

This is a list of name=‘value’ pairs, separated with ‘;’ characters. Some examples of valid formats would be…

If you want to use the simple format then set the section name to ‘none’ when you call the tags.

Normal Format

This allows you to pack mutliple sets of the simple-format lists into one field. Each list is called a section and sections can be named, and separated with the ‘|’ character.

Some examples of valid fields…

Version History.

v0.2 Implemented the following features…

v0.1 Implemented the following features…