1 of 3
1
Plugin: Single Field
Posted: 12 March 2009 06:14 PM   [ Ignore ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1156
Joined  02-02-2007

The attached add-on files may be out of date.  Please visit Devot-ee for the latest versions.

This plugin allows you to output the value of single custom field of certain entry without using exp:weblog:entries. It can be seen as a replacement of EntryData plugin which was available at www.trulyee.com

PARAMETERS

1) field - Required. Allows you to specify field name.

2) entry_id - Optional. Allows you to specify entry id number.

3) weblog - Optional. Allows you to specify weblog short name.

4) url_title - Optional. Allows you to specify url_title.

Either “entry_id” or “weblog” and “url_title” parameters must be defined.

5) field_format - Optional. Allows you to specify how field data should be
formatted. Possible values: “html”, “br”, “none”, “lite”, “raw”. In case this parameter is left undefined, format info
will be retrieved from database. In case parameter’s value is “raw”,
data will be outputted without any format applied.

6) site - Optional. Allows you to specify site id number. Default is “1”.

7) invalid_input - Optional. Accepts two values: “alert” and “silence”.
Default value is “silence”. If the value is “alert”, then in cases when
the plugin has some problem with parameters,  PHP alert is being shown;
if the value is “silence”, then in cases when the plugin has
some problem with parameters, it finishes its work without any alert being shown.
Set this parameter to “alert” for development, and to “silence” - for deployment.

8) allow_img_url - Optional. Allow inline images? Possible values: “yes” and “no”. Default is “no”.

9) auto_links - Optional. Auto-link URLs and email addresses? Possible values: “yes” and “no”. Default is “yes”.
(Note that auto-linking does not ever occur if parameter “html_format” is set to “none”)

10) encode_email - Optional. Whether or not email addresses are encoded. Possible values: “yes” and “no”. Default is “yes”.

11) encode_type - Optional. Type of encoding applied to email addresses
if email address encoding is enabled. Possible values: “javascript ” and “noscript”.
“noscript” renders in a human readable format (e.g. “name at example dot com)”,
suitable for use where JavaScript is inappropriate, such as in a feed.

12) html_format - Optional. Controls how HTML is handled in text. Possible values: “safe”, “all”, “none”.
Default is “safe”.

13) parse_smileys - Optional. Replace text smileys with smiley images? Possible values: “yes” and “no”. Default is “yes”.

14) field_is_date - Optional. Accepts two values: “yes” and “no”.
Default value is “no”. Set this parameter to “yes” in case custom field contains date.

15) date_format - Optional. Used in case “field_is_date” parameter is set to “yes”. Allows to specify ExpressionEngine’s
date format.

16) date_localize - Optional. Used in case “field_is_date” parameter is set to “yes”. Allows you to specify if the date
should be localized. Accepts two values: “yes” and “no”. Default value is “no”.

EXAMPLE OF USAGE

With “entry_id” parameter defined:

{exp:single_field  field="my_custom_field" entry_id="251" site="1" field_format="xhtml"

With “weblog” and “url_title” parameters defined:

{exp:single_field  field="my_custom_field" weblog="my_weblog" url_title="my_blog_title" site="1" field_format="raw"
 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

Profile
 
 
Posted: 16 March 2009 01:45 PM   [ Ignore ]   [ # 1 ]  
Grad Student
Rank
Total Posts:  39
Joined  11-03-2008

Thanks for putting this plugin together! I tried using it today in the following context:

{exp:child_categories parent="{category_id}" weblog="menus" child_categories_sort_by="custom" show_empty="yes" child_categories_sort_direction="asc"}
   {child_category_start}
    {if 
"{child_category_image}"!=""}
     
<img src="{child_category_image}" alt="{child_category_name}" />
   
{if:else}
     
<h2>{child_category_name}</h2>
   
{/if}
    {child_category_end}

   {entries_start} 
   
<h3>{title}</h3>
   <
p>{exp:single_field field="item-description" entry_id="{entry_id}"}</p>
   
{entries_end}
{
/exp:child_categories} 

I received this error:

NoticeUndefined indexfield_ft_15 in /home/nancysre/public_html/manage/plugins/pi.single_field.php on line 143 

If I manually put in an entry id (“5” for example) the data is pulled from the database. If I remove the quotes from “{entry_id}” then there is no PHP notice but no data appears. If I just have {entry_id} in that paragraph tag as opposed to the exp:single_field…. then the entry ID is displayed.

Am I approaching this incorrectly? Thanks!

Profile
 
 
Posted: 16 March 2009 02:41 PM   [ Ignore ]   [ # 2 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1156
Joined  02-02-2007

Hi,

Add

parse="inward" 

parameter to exp:child_categories tag.

 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

Profile
 
 
Posted: 16 March 2009 02:49 PM   [ Ignore ]   [ # 3 ]  
Grad Student
Rank
Total Posts:  39
Joined  11-03-2008

Ah sorry I missed that. I had that in a previous usage of child categories plugin but didn’t need it initially in this case. Thanks smile

Profile
 
 
Posted: 06 April 2009 10:49 PM   [ Ignore ]   [ # 4 ]  
Grad Student
Rank
Total Posts:  76
Joined  10-16-2007

I’m wondering if this plugin is compatible with 1.6.7.

I’ve installed it, but it is not showing in my plugin list nor is it working.

Thanks!

Profile
 
 
Posted: 06 April 2009 10:54 PM   [ Ignore ]   [ # 5 ]  
Grad Student
Rank
Total Posts:  39
Joined  11-03-2008

I’m running it on 1.6.7 just fine. Are you sure you didn’t drop it in the wrong folder? Your extensions folder perhaps?

Profile
 
 
Posted: 06 April 2009 11:07 PM   [ Ignore ]   [ # 6 ]  
Grad Student
Rank
Total Posts:  76
Joined  10-16-2007

It’s in the right place. Just not showing as loaded, or as an available plug in.

Not sure why.

Profile
 
 
Posted: 06 April 2009 11:15 PM   [ Ignore ]   [ # 7 ]  
Grad Student
Rank
Total Posts:  76
Joined  10-16-2007

Ugh. User error. I was working between 2 sites and installed it in the one I wasn’t testing.

Profile
 
 
Posted: 07 April 2009 12:14 PM   [ Ignore ]   [ # 8 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  555
Joined  04-23-2008

Laisvunas,

Thanks again for another great add-on! You certainly make some amazing stuff! It’s funny I come across this, because I was literally just asking Mark Bowen about EntryData the other day.

Profile
 
 
Posted: 07 April 2009 11:37 PM   [ Ignore ]   [ # 9 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1642
Joined  01-05-2007

I want to use the filesizer plugin - http://expressionengine.com/forums/viewreply/129059/ - with this plugin but it is currently impossible.

Any chance of making this possible?

 Signature 

Steven Hambleton | Hambo Development

WE SPECIALISE IN WORKING WITH AGENCIES AND BUILDING LONG TERM DEVELOPMENT PARTNERSHIPS 
Profile
 
 
Posted: 08 April 2009 01:02 PM   [ Ignore ]   [ # 10 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1156
Joined  02-02-2007

Hi stinhambo,

Can you provide more details about how you would like to use Single Field plugin together with Filesizer plugin?

 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

Profile
 
 
Posted: 08 April 2009 02:36 PM   [ Ignore ]   [ # 11 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1642
Joined  01-05-2007

Basically I want to use Single Field within Child Categories to get at a custom field. That custom field is used to store a file so I also want to use Filesizer to show the filetype and size.

I used parse=“inward” for Filesizer but no joy.

 Signature 

Steven Hambleton | Hambo Development

WE SPECIALISE IN WORKING WITH AGENCIES AND BUILDING LONG TERM DEVELOPMENT PARTNERSHIPS 
Profile
 
 
Posted: 08 April 2009 04:56 PM   [ Ignore ]   [ # 12 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  555
Joined  04-23-2008

Laisvunas,

I was wondering how this compares to the Reeposition plugin by Mr. Wilson?

By description, they seem to do almost the same thing? I’ve noticed you’ve also tried Mr. Wilson’s plugin yourself. Was wondering if you had some views on them both.

Thanks again for your wonderful contributions!

Profile
 
 
Posted: 09 April 2009 08:31 AM   [ Ignore ]   [ # 13 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1156
Joined  02-02-2007

@stinhambo Can you provide an example of your code?

@Danny Single Field plugin and Reeposition plugin have nothing in common: Reeposition has the purpose to move piece of content from one place in the page to other(s); Single field has the purpose to output contents of one custom field of certain entry.

 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

Profile
 
 
Posted: 09 April 2009 02:03 PM   [ Ignore ]   [ # 14 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  308
Joined  07-04-2007

Hi Laisvunas,

Are there any advantages of using your plugin beyond writing less code than a weblog:entries tag pair? (fewer sql queries etc?)

j

 Signature 

james | @_jamessmith

Handy ExpressionEngine URL Schematic

Happy to recommend Clook for ExpressionEngine hosting in the UK and US.

Profile
 
 
Posted: 10 April 2009 05:26 AM   [ Ignore ]   [ # 15 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1156
Joined  02-02-2007

Hi,

Single Field is used most often together with other plugins when you need to output content of some field but there is no need for powerful machinery of exp:weblog:entries. Single Field also uses less PHP memory and SQL calls than exp:weblog:entries.

 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

Profile
 
 
Posted: 13 April 2009 05:36 PM   [ Ignore ]   [ # 16 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  297
Joined  10-05-2007

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!

 Signature 

Amphibian Design | @devot:ee | GitHub | Twitter | EE Pro Network

Profile
 
 
Posted: 15 April 2009 01:00 PM   [ Ignore ]   [ # 17 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1156
Joined  02-02-2007

Hi D-Rock,

Thanks for your bug report and correct suggestion concerning fix.

I also found and fixed analogous bug - nonexistent custom field name resulting into MySQL error message being shown.

Now both fixes are incorporated into 1.0.1 version of Single Field plugin.

 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

Profile
 
 
Posted: 17 April 2009 04:02 PM   [ Ignore ]   [ # 18 ]  
Grad Student
Rank
Total Posts:  76
Joined  10-16-2007

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:

1. If the data being tested is an http address or contains an http address (e.g. http://site.com), then it is auto-converted like so (Despite if the weblog prefs are set to NOT auto-convert URLs/emails):

{if “<a hreff=“http://site.com”>http://site.com</a>”}—quotes inside quotes.

Field format does not appear to affect this.

2. If the data being tested contains quotes itself, then you will get the same problem. This can be overcome by setting the field format to xhtml in the test condition:

{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

Profile
 
 
   
1 of 3
1
 
‹‹ Plugin: Loop Plus      Plugin: Field Value ››