We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Plugin: Single Field

Development and Programming

Laisvunas's avatar
Laisvunas
879 posts
15 years ago
Laisvunas's avatar Laisvunas

Hi Mark,

Grab the version 1.2.

In it I added 3 new parameters:

1) 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.

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

3) 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”.

So, the code

{exp:single_field field="restock_date" entry_id="{entry_id}" field_is_date="yes" date_format="%D, %F %d, %Y" site="1"}

should output the date formatted.

       
Mark Terpstra's avatar
Mark Terpstra
205 posts
15 years ago
Mark Terpstra's avatar Mark Terpstra

Wow Laisvunas, thanks for your effort here. This is very helpful…as are many of your addons.

       
Danny T.'s avatar
Danny T.
426 posts
15 years ago
Danny T.'s avatar Danny T.

Great plugin Laisvunas! I know I’ve played around with this before, and here I am once again trying to figure it out. I have a right panel which displays more custom fields and tidbits from my entry. Right now, on the weblog entry page, I have two dedicated exp:weblog:entries tags, one for the main content, and the other for a group of custom fields (between 3-5 let’s say).

Given the circumstances, what would be less intensive on the queries?

       
smartpill's avatar
smartpill
456 posts
15 years ago
smartpill's avatar smartpill

IS there a way to set this up so I can strip out LG Replace tags? I have:

<meta name='DC.description' content='{exp:md_eexcerpt if_exceeds="31" stop_after="30" append="…"}
{exp:single_field field="summary" weblog="{my_weblog}" url_title="{segment_3}" site="3" field_format="raw"}
{/exp:md_eexcerpt}' />

I haven’t found anything that could pull the tags – {media_1} – for example, out, so that it is clean text for the meta tag.

       
Danny T.'s avatar
Danny T.
426 posts
15 years ago
Danny T.'s avatar Danny T.

Kyle,

I don’t see your media tag in your code? Am I misunderstanding something? If you want to strip out LG Replace fields, you can use Find and Replace or Find and Replace Plus to strip them out.

       
smartpill's avatar
smartpill
456 posts
15 years ago
smartpill's avatar smartpill
Kyle, I don’t see your media tag in your code? Am I misunderstanding something? If you want to strip out LG Replace fields, you can use Find and Replace or Find and Replace Plus to strip them out.

The {media_1} tags get output in the text. Replace Plus did the trick. Thanks for pointing me in the right direction. For reference:

<meta name='DC.description' content='{exp:md_eexcerpt if_exceeds="31" stop_after="30" append="…"}
{exp:replace_plus find=":LD:media_1:RD:|:LD:media_2:RD:|:LD:media_3:RD:" multiple="yes"}
{exp:single_field field="summary" weblog="{my_weblog}" url_title="{segment_3}" site="3" field_format="raw"}
{/exp:replace_plus}{/exp:md_eexcerpt}' />

This did the trick. There’s probably a cleaner approach, but it worked.

       
GDmac - expocom's avatar
GDmac - expocom
350 posts
15 years ago
GDmac - expocom's avatar GDmac - expocom

I wanted to say, thank you for the nice plugin. On one site i used geevar for this, but this is a nice alternative. Added bonus: This plugin uses core.typography, so if you use a field that has formatting set to markdown, then the plugin will magically display the formatted text for you.

       
Jonathan Schofield's avatar
Jonathan Schofield
175 posts
15 years ago
Jonathan Schofield's avatar Jonathan Schofield

Laisvunas, what a great plug-in. I’m doing something similar with it to Erik_Reagan and it’s almost working like a dream… but not quite! Here’s what I have so far:

{exp:child_categories parent="62" child_categories_sort_direction="asc" entries_sort_by="date" entries_sort_direction="asc" parse="inward"}
  {child_category_start}
    <h2 id="{child_category_url_title}">{if child_category_description}<abbr title="{child_category_description}">{child_category_name}</abbr>{if:else}{child_category_name}{/if}</h2>
  {child_category_end}

  {entries_start}
    <strong>{if title_html}{title_html}{if:else}{title}{/if}</strong>
    {exp:single_field  field="body" weblog="faq" entry_id="{entry_id}" field_format="wysiwyg"}
  {entries_end}
{/exp:child_categories}

The only problem is that the {body} field in question uses LG TinyMCE and so is a field type of WYSIWYG, and my attempt to use WYSIWYG as a field_format doesn’t work.

       
Jonathan Schofield's avatar
Jonathan Schofield
175 posts
15 years ago
Jonathan Schofield's avatar Jonathan Schofield

Duh. Using a field_format of “raw” was all I needed to do…

{exp:single_field  field="body" weblog="faq" entry_id="{entry_id}" field_format="raw"}

Sorted! :-$

       
timkelty's avatar
timkelty
177 posts
15 years ago
timkelty's avatar timkelty

I think a great addition to this plugin would be to have option of grabbing the field_format from the field itself and the params (html_format,auto_links, etc.)from the weblog itself.

       
1 2 3

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.