Juergen Posted November 30, 2014 Share Posted November 30, 2014 Hello at all I have overwritten the label of the body field in various templates, but if I try to output it in the site template I always get the initially label name. The output code: <?php echo $page->fields->get('body')->label;?> The initially label of my body field is "maintext" and this will be outputed. In my teammember template I have overwritten "maintext" with "About me" but I always get "maintext" as the label and not "About me". Can someone point me into the right direction of outputting the overwritten label? Link to comment Share on other sites More sharing options...
adrian Posted November 30, 2014 Share Posted November 30, 2014 This gets you the label in the context of the entered template. $templates->get("template_name")->fieldgroup->getField('body', true)->label; You could also do this to get for the template of the current page: $templates->get($page->template->name)->fieldgroup->getField('body', true)->label; 7 Link to comment Share on other sites More sharing options...
Juergen Posted November 30, 2014 Author Share Posted November 30, 2014 Thanx for the ultra fast response. Works quite well 1 Link to comment Share on other sites More sharing options...
Can Posted January 25, 2016 Share Posted January 25, 2016 Thank you Adrian, and thanks Juergen for asking, so I just got an answer already haha By the way, when you got languages enabled it could be interesting to use $field->getLabel() instead. It'll always gives you the label in the current language or you can pass the desired language as parameter like e.g. $field->getLabel($languages->get("de")) @Ryan, maybe it could be nice to have a second parameter here like true/false to get the default label or the context label? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now