Having a bit of an issue generating channel fields based on a variable. Below is my attempt at a PHP solution:
{related_entries id="image_gallery"}
<?php for ($i = 1; $i <= 15; $i++) { ?>
{image_<?php echo $i; ?>}
<?php } ?>
{/related_entries}
Unfortunately ExpresssionEngine doesn’t render these tags and just outputs them as:
{image_1} {image_2} {image_3}… etc.
I’ve tried some other looping plugins with no luck either, but I assume there is a plugin or method out there to help me.
Bonus question: Ideally, I will need a method that I can also check to see if the channel field actually has any data like: {if image_x}{image_x}{/if}
Make sure you have set PHP to parse on input in your template preferences. That should do the trick.