Jump to content

Get a value's fieldname inside a renderField file.


GavJMF
 Share

Recommended Posts

Hi all,

Ive recently been working more with renderfields on a project however im a little stumped with something.
When I want to make a file front end editable, is there a way to get the fieldname from within the render file?

For example:
On this page I have 2 image fields, 'single_image' & 'single_image2' if I was to add a the former to a page I have it set up as below:

<?=$page->renderField('single_image','rectangle');?>

then the code within 'rectangle' is as follows:

<div edit="<?=$page->id;?>.single_image">
    <img alt="<?=$value->alt;?>" src="<?=$value->size(600,400)->url;?>">
</div>

I wanted to know if there is a way to call the fieldName for the renderField value rather than having to either hard code it with different files, or setting up an array within the renderField.
I.e. If I could do something akin to this:

<div edit="<?=$page->id;?>.<?=$value->fieldName;?>">
    <img alt="<?=$value->alt;?>" src="<?=$value->size(600,400)->url;?>">
</div>

Obviously that doesnt work as the value doesn't have the fieldname within it but maybe theres something I've missed?

I can work around this by making changes to the template file where the renderField is called but, if possible, I'd like to avoid that.

 

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...