0

Given any Channel, is it possible to loop through all the entries and output the following:

  • field name
  • field type
  • field value

Assume that the Channel is unknown and can be any Channel. This means that I don't know ahead of time what fields there are in the Channel.

For the field values, I assume that I would need extra logic to display its corresponding values (e.g. a grid might need to have a nested loop, etc.).

1
1

Whilst not available for front end, this is a must for all installs: http://devot-ee.com/add-ons/template-variables

0

Just a quick answer but exp:query could handle most of this - certainly listing channel fields and types would be easy...I do something similar to help build stash models for channels, like this:


{exp:query sql="SELECT field_name FROM exp_channel_fields WHERE group_id = '47' "}
       {exp:stash:set name="{field_name}"}{{field_name}}{/exp:stash:set}
{/exp:query}

exp_channel_fields has the type as well.

The content will be harder, I'd look to one of the APIs lie RSANs DEEP or maybe OpenAPI to do that maybe?

2
  • I thought I recall seeing something in the EE documentation that showed some code looping -- and doing field type checks, then outputting values. I thought it was exp:channel:entries, but I guess not. I doubt it was exp:query, though. Does that ring a bell at all? – ExpressionEngineNewbie Jun 19 '14 at 2:54
  • Obviously with entries you can can output the field types and values if you know the names, but without the names...of course you can get the names using the above and stash them, for example. Sorry, my answer is not complete but I'm a bit bust, jsut trying to get you started.. – Jeremy Daalder Jun 19 '14 at 4:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.