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

How to parse/render custom field data in third-party plug-ins

Development and Programming

Michael Rog's avatar
Michael Rog
179 posts
15 years ago
Michael Rog's avatar Michael Rog

My current process for outputting custom field data in a plug-in is:

  1. Get a list of custom fields assigned to the channel of interest, including field_id and field_name.

  2. Go fetch the field_id_X and field_ft_X data using the list of field_ids.

  3. Assemble the data into a variables array (keying by field_name, adding extra data to format by field_id_X via the Typography class where necessary).

  4. Invoke parse_variables() to replace the tags in the tagdata.

ALAS, this doesn’t work if the custom field data belongs to a Fieldtype that needs extra formatting or does special rendering stuff in its replace_tag() or replace_X() methods.

This shortfall applies to popular add-ons like Matrix, Playa, SafeCracker… and any field that doesn’t use a plug-in or standard Typography option for formatting… and any Fieldtype that allows tag pairs with params or tag modifiers.

When you need to process custom field data outside of the Channel Module, what’s the right/best strategy?

       
Parse19's avatar
Parse19
44 posts
15 years ago
Parse19's avatar Parse19

Michael,

Unfortunately I don’t think there is a standard best practice for this. As you likely are aware of, the logic that controls how this work is buried in different places, and the fields model is just simple crud operations.

For your method, have you tried going to the source and loading/running the replace_tag and other methods?

It would be nice to get an open source API version out there that people can use for modules because I think it is an issue that comes up in module development quite often.

Adam

       

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.