Laisvunas - I encountered an undefined index error with your plugin, and figured out why. Basically, if an entry_id was passed that was bad (non-existent), it was still looking for field formatting for the returned row. I fixed it by moving the block starting at IV. Format field value into the
if ($query4->num_rows == 1)
block of code (around line 133), so it only looks for the field formatting if there was indeed a result of the query.
Thanks for the plugin, very useful!
Laisvunas,
I think I tracked down the source of my errors, which we earlier discussed in the Child Categories thread. There are nested quote issues I’m seeing, which appear to relate to using the following type of test with the single field plug in:
{if "{exp:single_field field="field_name" weblog="resources" entry_id="{entry_id}"}"} do something {/if}
There are cases where the single field plugin will render quotes for the tested field, thus leading to quotes inside quotes, and T_STRING errors:
{if "<a hreff="http://site.com">http://site.com</a>"} – quotes inside quotes.
Field format does not appear to affect this.
{if "{exp:single_field field="field_name" weblog="resources" entry_id="{entry_id}" field_format="xhtml"}"} do something {/if}
So I’m wondering if anything can be done about #1.
Marc
Hi Mark,
Try to use single quotes instead of double ones, that is instead of
{if "{exp:single_field field="field_name" weblog="resources" entry_id="{entry_id}"}"} do something {/if}
write
{if '{exp:single_field field="field_name" weblog="resources" entry_id="{entry_id}"}'} do something {/if}
or
{if '{exp:single_field field="field_name" weblog="resources" entry_id="{entry_id}"}' != ''} do something {/if}
I’m having a problem using this when the content contains an email link. The code is being output as
“feedback”
which was originally:
{encode="[email protected]" title="feedback"}
I’m using:
{exp:single_field field="misc_text" entry_id="18" field_format="xhtml"}
Is there a way to make it render properly or is this a bug?
I was having trouble with entries with html in them being espaced, because the Typography class defaults to ‘safe’ HTML allowed only.
I added the following to remedy:
$parse_options = array(
'text_format' => $field_format,
'html_format' => 'all',
'auto_links' => 'n',
'allow_img_url' => 'y',
'parse_images' => 'y',
);
$field_value = $TYPE->parse_type($field_value, $parse_options);
Hi all,
I released version 1.1 of Single Field plugin.
In this release several new parameters were added allowing more control over formatting of the field values: “allow_img_url”, “auto_links”, “encode_email”, “encode_type”, “html_format” and “parse_smileys”.
About using these parameters read in the first post of this thread.
Thanks to timkelty for suggesting this improvement.
When using Single Field with a Date field type - is it possible to control the date format?
Right now the date is output like this: 1265152989 But I’d like to display it like this: February 02, 2010
This is my code:
{exp:single_field field="restock_date" entry_id="{entry_id}" site="1" field_format="none"}
Hi Mark, Single field plugin does not aim at outputting content of such field as {title}, {url_title} or {date}; it aims solely at outputting content of single custom field.
Actually it is a custom field but the field type is “Date” - so it outputs the raw date, but I was wondering if I could do date variable formatting. It’s not a big deal either way.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.