Hi,
I am trying to be able to edit image fields using frontend edit-in-place while in ZP_ALBUM context because I am working on a project that may not need the image.php file. How hard would this be - any tips?
I get the following error when trying to edit an image field in album context:
Fatal error: Call to a member function set() on a non-object in .......\zp-core\functions-controller.php on line 259
So I think I understand the error in that it is trying to set image fields but the object is the current album. Since there are many images in play in album context, would it be even possible to edit in place across multiple images?
Comments
If you looked at the referenced line in functions-controller.php you would discover you are in the function that handles edit in place (the front end editing.) In particular, the `$object` variable is the item that is being complained about.
I'd like to be able to edit tags from album.php. You're right its not an object... $_zp_current_image doesn't appear to be an object in the context of an album. Is there a way to get an image object from a text property? So that we can enable edit in place on the album.php page?
Here's a thread of what's going on, but might be hard to follow.
I've added the following from Image.php to Album.php
<?php printTags('links', gettext('Tags:').' ', 'taglist', ''); ?>
This becomes editable tags when logged in as the admin user and front end editing is enabled.
The PHP prints out the following (which looks the same as the code in Image.php)
<span id="editable_image_5" class="zp_editable zp_editable_image__update_tags" title="(Click to edit...)">No tags...</span>
<script type="text/javascript">editInPlace('editable_image_5', 'image', '_update_tags');</script>
The JS function editInPlace is from jquery.editinplace.js:349 and looks like
function editInPlace( target, context, field )
This eventually reaches
functions-controller.php->editInPlace_handle_request:210
There is a comment on this page which says,
// Cannot edit when context not set in current page (should happen only when editing in place from index.php page)
if ( !in_context(ZP_IMAGE) && !in_context(ZP_ALBUM) && !in_context(ZP_ZENPAGE_PAGE) && !in_context(ZP_ZENPAGE_NEWS_ARTICLE))
die ($orig_value.'<script type="text/javascript">alert("'.gettext('Oops.. Cannot edit from this page').'");</script>');
So, I'm in the Album context but I want an image to be edited. The next few lines will see that the context is passed in correctly as image but $_zp_current_image must be incorrect since I'm on an album page with many many images. I guess the image to be edited needs to be passed down to this function somehow or $_zp_current_image needs to be set by looking at the java script.
The only thing provided for is for editing fields of the object associated with the page.
I should note as well that this is an area we will not be enhancing. The simple reason for this is that this inline editing is vulnearble to Cross Site Reference Forgery attacks. We consider the front-end editing feature not secure and really do discourage its use.