Jump to content
DarsVaeda

[solved] frontend edit on repeater fields

Recommended Posts

Hi,

how do I enable frontend editing for repeater fields?

It partially works with 

foreach($page->repeater_field as $item) {
>?
<li><edit list_item><?= $item->list_item ?></edit></li>
<?php
}

But if I click a frontend item the text disappears. I'm not sure if this is a bug or because it does not know which text it should reference.
I tried with:

foreach($page->repeater_field as $item) {
>?
<li><edit list_item_repeater<?= $item->id ?>><?= $item->list_item ?></edit></li>
<?php
}

But that results in an exception.

Share this post


Link to post
Share on other sites

Hi,

could this be related to permissions?

We currently encounter problems with frontend editing of repeater fields, too: in our case it's simply not possible to frontend-edit repeater fields for users with a specific role, although these users are able to edit the respective repeater fields in the regular backend page editor. Superusers are able to frontend-edit repeater fields as expected.

@DarsVaeda this is an example of how we included frontend-editing which works (apart from the problem described above):

<?php 
/** @var RepeaterPageArray $attributes */
foreach ($attributes as $attribute): ?>
  <div class="attribute">
    <?php $image = $attribute->get('image'); ?>
    <div class="attribute__image" edit="<?php echo $attribute->id; ?>.image">
      <img src="<?php echo $image->url; ?>" alt="<?php echo $image->description; ?>">
    </div>
    <div class="attribute__body">
      <?php echo $attribute->edit('body'); ?>
    </div>
  </div>
<?php endforeach; ?>

 

Cheers, Alex

Share this post


Link to post
Share on other sites

Hmm maybe, I need to try but I only have one user currently who is admin.
But now after updating I have the problem that all fields get "deleted" when starting to edit.
I'm not sure if it's my implementation or a bug. Need to dig into this.

Share this post


Link to post
Share on other sites
On 23/01/2017 at 8:14 PM, DarsVaeda said:

I tried with:


foreach($page->repeater_field as $item) {
>?
<li><edit list_item_repeater<?= $item->id ?>><?= $item->list_item ?></edit></li>
<?php
}

 

This is the actual problem. It doesn't work with this implementation.
If I use this:

foreach($page->repeater_field as $item) {
>?
<li><?= $item->edit('list_item') ?></li>
<?php
}

Then frontend editing works.

Thanks @design-a-point!

Share this post


Link to post
Share on other sites

I had the same issues you both mentioned. When logged in with some other role then superuser and try to edit a page, either the text disappeared or I wasn't even able to edit the text, at all.

The problem comes up, if you want to use option B (explained here: https://processwire.com/api/modules/front-end-editing/ ) for front end editing. 
I chose it above the other options, because of its direct "inline access" (compared to the dialog box with option C and D). Because repeater fields are stored as child of the admin page in the backend, other user roles don't have access to them by default, which leads to the afore mentioned issues, I guess. 
My solution was to give those user roles access to the admin page template and its children.

It took me some time to discover it, so if other users have problems with this, as well, maybe it's worth mentioning it in the module docs somewhere?

Share this post


Link to post
Share on other sites
23 minutes ago, Christoph said:

It took me some time to discover it, so if other users have problems with this, as well, maybe it's worth mentioning it in the module docs somewhere?

Did you check the front-end editing documentation when investigating your problem? It specifically advises against using option B for Repeaters:

Quote

But not worthwhile for things like Files/Images, PageTables, Repeaters or any field that you iterate to output or access object properties from. For those you will want to use <edit> tags or edit attributes, per options C and D.

 

  • Like 1

Share this post


Link to post
Share on other sites

Yes, I read it. 

As I had no problems using option B with repeaters as a superuser, I just wanted to make it work for other user roles, too. Option C/D is just no real front end editing any more, at least regarding how my clients understand it. In my current client's context, the front end editing is just needed to correct typos and the likes.

But you are right, as there is a strong advice to not use option B in a repeater context, the docs don't need to provide a solution on how make it work :).

Share this post


Link to post
Share on other sites
1 hour ago, Christoph said:

Option C/D is just no real front end editing any more, at least regarding how my clients understand it.

It is only option D that forces the modal dialog editor. Option C allows inline editing - you just have to place edit tags around the individual fields in your repeater rather than around the whole repeater foreach(). For example:

<?php foreach($page->my_repeater as $item): ?>
    <h3><edit <?= $item->id ?>.title><?= $item->title ?></edit></h3>
<?php endforeach; ?>

You're right that there does seem to be some sort of permissions issue for non-superusers, but rather than change access for the admin template (which non-superusers shouldn't have access to) I suggest you give edit access to your repeater template (select the "Show system templates" option to see repeater templates).

  • Like 3

Share this post


Link to post
Share on other sites
On 08/02/2017 at 10:00 AM, Robin S said:

Did you check the front-end editing documentation when investigating your problem? It specifically advises against using option B for Repeaters:

 

Is that documentation up to date? It doesn't work for me with option C. I get a popup which is not usable. Would need to dig into what is wrong with the html/css.
But option B works for me without any problem (despite the need to set the permission on the system template as you suggested).

Share this post


Link to post
Share on other sites

@DarsVaeda Had the same issue with unusable popup on option C/D. My solution was to change the jQuery version to the one processwire is using.

@Robin S Thanks for your help! Will try your solution with option C later today. You're right, instead of changing the admin template, it is enough to allow access for the repeater_content template

Share this post


Link to post
Share on other sites
9 hours ago, DarsVaeda said:

But option B works for me without any problem

5 hours ago, Christoph said:

where's the difference to option B in this case?

Re-reading the docs, I'm not sure why Ryan advises against using option B with Repeaters or PageTables (for Files/Images fields it makes sense). Maybe he means if you are wanting to make the entire Repeater/PageTable field editable rather than the individual fields inside the items, because it does seem to work fine for the latter case (once the access bug is worked around).

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Robin S
      Repeater Images
      Adds options to modify Repeater fields to make them convenient for "page-per-image" usage. Using a page-per-image approach allows for additional fields to be associated with each image, to record things such as photographer, date, license, links, etc.
      When Repeater Images is enabled for a Repeater field the module changes the appearance of the Repeater inputfield to be similar (but not identical) to an Images field. The collapsed view shows a thumbnail for each Repeater item, and items can be expanded for field editing.
      Screencast

      Installation
      Install the Repeater Images module.
      Setup
      Create an image field to use in the Repeater field. Recommended settings for the image field are "Maximum files allowed" set to 1 and "Formatted value" set to "Single item (null if empty)". Create a Repeater field. Add the image field to the Repeater. If you want additional fields in the Repeater create and add these also. Repeater Images configuration
      Tick the "Activate Repeater Images for this Repeater field" checkbox. In the "Image field within Repeater" dropdown select the single image field. You must save the Repeater field settings to see any newly added Image fields in the dropdown. Adjust the image thumbnail height if you want (unlike the core Images field there is no slider to change thumbnail height within Page Edit). Note: the depth option for Repeater fields is not compatible with the Repeater Images module.
      Image uploads feature
      There is a checkbox to activate image uploads. This feature allows users to quickly and easily add images to the Repeater Images field by uploading them to an adjacent "upload" field.
      To use this feature you must add the image field selected in the Repeater Images config to the template of the page containing the Repeater Images field - immediately above or below the Repeater Images field would be a good position.
      It's recommended to set the label for this field in template context to "Upload images" or similar, and set the visibility of the field to "Closed" so that it takes up less room when it's not being used. Note that when you drag images to a closed Images field it will automatically open. You don't need to worry about the "Maximum files allowed" setting because the Repeater Images module overrides this for the upload field.
      New Repeater items will be created from the images uploaded to the upload field when the page is saved. The user can add descriptions and tags to the images while they are still in the upload field and these will be retained in the Repeater items. Images are automatically deleted from the upload field when the page is saved.
      Tips
      The "Use accordion mode?" option in the Repeater field settings is useful for keeping the inputfield compact, with only one image item open for editing at a time. The "Repeater item labels" setting determines what is shown in the thumbnail overlay on hover. Example for an image field named "image": {image.basename} ({image.width}x{image.height})  
      https://github.com/Toutouwai/RepeaterImages
      https://modules.processwire.com/modules/repeater-images/
    • By Orkun
      Hi Guys
      I have a problem with a repeater field. Some weeks ago I had exported a repeater field from a dev installation and then imported it to a live installation. All just had worked fine as I remember (the field was created etc...). But today I got an email from the developer of our customer that he has a problem with two repeater fields. When he had changed the fields of another repeater it has also changed it in the other repeater field (which I had imported some weeks ago). I investigated this further and found out that exporting/importing of repeater fields doesn't work for my version of processwire (we are using 2.7.3) (see https://github.com/processwire/processwire-issues/issues/416). 
      So I decided to remove the repeater field and create it again manually on the live enviroment. I could remove the repeater field from the template but I can't delete the repeater field because it is referring to a false repeater template. How can I fix this issue so that I can delete the repeater field?
       
      The "event_dates" repeater field is referring to the "repeater_speciality_adresses" template which is wrong.

      When I try to delete the field I get this error:

       
      Do I need to manually remove the field from the db? What do I exactly need to do?
      Kind Regards
      Orkun
    • By AndZyk
      Hello,
      this maybe a simple question, but it bothers me for a while now:
      There used to be a warning, if two or more user try to edit the same page. But ever since AdminThemeUIkit I haven't seen it any more.
      Is this a bug or are there special circumstances under which the warning will be displayed?
      If I am logged-in in the same browser with one default and one privat window, I don't see this warning. But also different browsers on different machines in the same network don't see this warning.
      I was looking for the blog post on which this feature was announced, but couldn't find it anymore.
      We had the case, that two people were writing a text for the same page, but after person A saved the page first, the text of the person B was lost. I know we could have used ProDrafts for this case, but it shouldn't happen in the first place.
      I would appreciate some feedback. 😀
      Regards, Andreas
    • By NorbertH
      When saving a page with the "order" template in the backend  IftRunner is nice to me and sends the order via page action into my accounting software. 
      When saving "order" in a frontend page it does nothing.   So i certainly missing something . Any ideas? 
       
    • By David Karich
      ProcessWire InputfieldRepeaterMatrixDuplicate
      Thanks to the great ProModule "RepeaterMatrix" I have the possibility to create complex repeater items. With it I have created a quite powerful page builder. Many different content modules, with many more possible design options. The RepeaterMatrix module supports the cloning of items, but only within the same page. Now I often have the case that very design-intensive pages and items are created. If you want to use a content module on a different page (e.g. in the same design), you have to rebuild each item manually every time.
      This module extends the commercial ProModule "RepeaterMatrix" by the function to duplicate repeater items from one page to another page. The condition is that the target field is the same matrix field from which the item is duplicated. This module is currently understood as proof of concept. There are a few limitations that need to be considered. The intention of the module is that this functionality is integrated into the core of RepeaterMatrix and does not require an extra module.
      Check out the screencast
      What the module can do
      Duplicate a repeater item from one page to another No matter how complex the item is Full support for file and image fields Multilingual support Support of Min and Max settings Live synchronization of clipboard between multiple browser tabs. Copy an item and simply switch the browser tab to the target page and you will immediately see the past button Support of multiple RepeaterMatrix fields on one page Configurable which roles and fields are excluded Duplicated items are automatically pasted to the end of the target field and set to hidden status so that changes are not directly published Automatic clipboard update when other items are picked Automatically removes old clipboard data if it is not pasted within 6 hours Delete clipboard itself by clicking the selected item again Benefit: unbelievably fast workflow and content replication What the module can't do
      Before an item can be duplicated in its current version, the source page must be saved. This means that if you make changes to an item and copy this, the old saved state will be duplicated Dynamic loading is currently not possible. Means no AJAX. When pasting, the target page is saved completely No support for nested repeater items. Currently only first level items can be duplicated. Means a repeater field in a repeater field cannot be duplicated. Workaround: simply duplicate the parent item Dynamic reloading and adding of repeater items cannot be registered. Several interfaces and events from the core are missing. The initialization occurs only once after the page load event Changelog
      1.0.4
      Bug fix: Various bug fixes and improvements in live synchronization Bug fix: Items are no longer inserted when the normal save button is clicked. Only when the past button is explicitly clicked Feature: Support of multiple repeater fields in one page Feature: Support of repeater Min/Max settings Feature: Configurable roles and fields Enhancement: Improved clipboard management Enhancement: Documentation improvement Enhancement: Corrected few typos #1 1.0.3
      Feature: Live synchronization Enhancement: Load the module only in the backend Enhancement: Documentation improvement 1.0.2
      Bug fix: Various bug fixes and improvements in JS functions Enhancement: Documentation improvement Enhancement: Corrected few typos 1.0.1
      Bug fix: Various bug fixes and improvements in the duplication process 1.0.0
      Initial release Support this module
      If this module is useful for you, I am very thankful for your small donation: Donate 5,- Euro (via PayPal – or an amount of your choice. Thank you!)
      Download this module
      > Github: https://github.com/FlipZoomMedia/InputfieldRepeaterMatrixDuplicate
      > PW module directory: – soon –
×
×
  • Create New...