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

Is there a fluid field "current_field_title" like current_field_name?

How Do I?

ianumeda's avatar
ianumeda
2 posts
3 years ago
ianumeda's avatar ianumeda

Is there a way of getting a fluid field’s Title? You can get the current_field_name which gets the field’s shortname. There’s no mention of anything like this in the EE documentation (https://docs.expressionengine.com/latest/fieldtypes/fluid.html#current_field_name).

       
seavers's avatar
seavers
20 posts
3 years ago
seavers's avatar seavers

It’s stored in the database as ‘field_label’, have you tried ‘current_field_label’?

       
seavers's avatar
seavers
20 posts
3 years ago
seavers's avatar seavers

I’ve just checked the file that would parse this and there’s no field_label available (/system/ee/legacy/libraries/Fluid_field_parser.php).

If I were you I would use the current_field_name and make it human readable with PHP’s str_replace() - replacing underscores with spaces and then making the first letter a capital using ucfirst().

Something like:

<? echo ucfirst(str_replace(‘_’, ’ ‘, ‘{current_field_title}’)); ?>

Hope this helps.

       
Andy McCormick's avatar
Andy McCormick
322 posts
3 years ago
Andy McCormick's avatar Andy McCormick

@ianumeda, can you help us understand the use case here?
Typically when you’re creating the template code for a fluid field, it’s always going to be the same field. In that case, you can just hardcode the field name. I’m thinking this would only change if you feel that the field name might be changed on a regular basis. thanks.

       
ianumeda's avatar
ianumeda
2 posts
3 years ago
ianumeda's avatar ianumeda

Hello @seavers and @andy,

Thanks for your replies. Here’s the situation: I have a collection of Articles compiled by a Issue entry. The Issue has a fluid field with a series of relationship fields that define sections of each Issue.

What I want to do was output the Name the relationship field as a heading for the Article as a reference to the section where the article resides in the Issue. Since all I can access is the field’s short_name I’ve had to employ a solution like @severs suggested which was to modify the field’s short_name with str_replace(). This doesn’t seem like a very robust solution especially because I expect I’ll want to be able to change the Headings in the future without all the disruption caused by changing a field’s short_name. If the field’s Name was accessible to the template I would just have to update the field’s Name to update the heading.

       

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.