0
votes

Hi I am looping through a channel in EE2 and I am outputting all of the fields values but how do I output the fields title that I labeled it in the backend?

CODE:

<!-- Loop to out put a field called Location -->

{exp:channel:entries channel="vacancies"  disable="pagination|member_data|categories"}
    <p>{vacancy_location}{title}{/vacancy_location}: {vacancy_location}</p>
{/exp:channel:entries}

DESIRED OUTPUT:

<p>Location: Some Location</p>
3

3 Answers

1
votes

What worked for me was installing SafeCracker module that is shipped with EE2 and using its {label:} tag

http://expressionengine.com/user_guide/modules/safecracker/index.html#label-my-field-name

0
votes

You might be able to accomplish this via the SQL query tag, but generally speaking the labels assigned to fields in the back-end are intended to be for use only within the Entry Publishing/Editing screen. The labels for these fields that are seen by the people entering content into the system may not always necessarily be the same labels you want to expose to visitors to your site on the front end.

Like @stoep mentioned, you may have better luck writing a custom plugin to handle this, if writing SQL query tags in your template won't end up as a viable option.

0
votes

You can't.. The only way to get it is by extracting it from the database. You could write a custom plugin for the task. Another option is to put the field label in the Global Template Variables.

Edit: I quickly created the plugin for you -- you can grab it at https://github.com/Stoep/pi.field_information , place it in third_party/field_information/

Usage:
{exp:field_information channel="news" field_name="news_content" information="field_label"} {exp:field_information channel="news" field_name="news_content" information="field_instructions"}