Jump to content

Output label overridden in the template


LAPS
 Share

Recommended Posts

Hi, I've a multi-language text field which label is overridden in the template to "Label English" and "Label Italian".

I'd like to output the overridden Italian version when accessing the link http://www.website.com/it/. I tried the following without success:

// output a blank value
$page->text_field_name->label;
$page->get('text_field_name')->label;

// get the error: "Error: Call to a member function getLabel() on string"
$page->text_field_name->getLabel();
$page->get('text_field_name')->getLabel();

// output the not overridden, translated value
$page->fields->text_field_name->label;
$page->fields->text_field_name->getLabel();
$page->fields->get('text_field_name')->label;
$page->fields->get('text_field_name')->getLabel();

How can I output the label overridden in the template?

 

Update

I ended up using:

$page->fields->getFieldContext('text_field_name')->getLabel();

Is it the correct way to get the overridden, translated label? Or is there some better?

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...