Jump to content

Inputfield: Repeater Matrix Item Duplicator


David Karich

Recommended Posts

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 multible repeater items 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
  • Configurable dialogs for copy and paste
  • 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

Attention, please note!
Nested repeaters cannot be supported technically. Therefore a check is made to prevent this. However, a nested repeater can only be detected if the field name ends for example with "_repeater1234". For example, if your MatrixRepeater field is named like this: "content_repeater" or "content_repeater123", this field is identified as nested and the module does not load. In version 2.0.1 the identification has been changed so that a field ending with the name repeater is only detected as nested if at least a two-digit number sequence follows. But to avoid this problem completely, make sure that your repeater matrix field does NOT end with the name "repeater".

Changelog

 

2.0.1

  • Bug fix: Thanks to @ngrmm I could discover a bug which causes that the module cannot be loaded if the MatrixRepeater field ends with the name "repeater". The code was adjusted and information about the problem was provided

2.0.0

  • Feature: Copy multiple items at once! The fundament for copying multiple items was created by @Autofahrn - THX!
  • Feature: Optionally you can disable the copy and/or paste dialog
  • Bug fix: A fix suggestion when additional and normal repeater fields are present was contributed by @joshua - THX!

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 (Version 2.0.1)

> Github: https://github.com/FlipZoomMedia/InputfieldRepeaterMatrixDuplicate
> PW module directory: https://modules.processwire.com/modules/inputfield-repeater-matrix-duplicate/

> Old stable version (1.0.4): https://github.com/FlipZoomMedia/InputfieldRepeaterMatrixDuplicate/releases/tag/1.0.4

Edited by David Karich
New version 2.0.1
  • Like 21
  • Thanks 1
Link to comment
Share on other sites

I guess it's just CSS?

a.InputfieldRepeaterAddLink.InputfieldRepeaterMatrixAddLink.InputfieldRepeaterAddLinkInit[data-type="3"] {
	font-size: 0;
	width: 150px;
	height: 100px;
	display: inline-block;
	background-image: url(https://via.placeholder.com/150);
	background-repeat: no-repeat;
}

span.ui-priority-secondary {
	display: none;
}

 

  • Like 10
Link to comment
Share on other sites

44 minutes ago, dragan said:

I guess it's just CSS?


a.InputfieldRepeaterAddLink.InputfieldRepeaterMatrixAddLink.InputfieldRepeaterAddLinkInit[data-type="3"] {
	font-size: 0;
	width: 150px;
	height: 100px;
	display: inline-block;
	background-image: url(https://via.placeholder.com/150);
	background-repeat: no-repeat;
}

span.ui-priority-secondary {
	display: none;
}

 

Exactly. It's just a bit custom CSS. ? It might also be an idea for a matrix update that you can configure labels as images.  Would be more flexible.

  • Like 6
Link to comment
Share on other sites

1 minute ago, David Karich said:

It might also be an idea for a matrix update that you can configure labels as images.  Would be more flexible.

Yep. And add a nice touch to convert automagically label/link-texts to title attributes, so when the author hovers over an image, he knows exactly what kind of matrix item he/she will add.

  • Like 2
Link to comment
Share on other sites

Version Update 1.0.3

The current version 1.0.3 has some minor improvements. Items are inserted at the last position on the target page and set to the status unpublished. Furthermore, the clipboard is synchronized live, so you can jump between browser tabs without reloading the target page, for direct pasting. And the module runs only in the backend in the autoload.

> Grap a copy: https://github.com/FlipZoomMedia/InputfieldRepeaterMatrixDublicate

Edited by David Karich
Version Update 1.0.3
  • Like 4
Link to comment
Share on other sites

Version Update 1.0.4

The current version has got some improvements, bug fixes and new features. Meanwhile a bit further than just a proof of concept. I would call it a beta version. I now submit it to the PW directory.

IMPORTANT for an update from older versions: completely uninstall and delete the old versions! Only then install the new version.

All information and downloads are updated in the first post.

@kongondo Can you please move this topic under "Modules"? I think the module is out of development. Thanks a lot.

  • Like 1
Link to comment
Share on other sites

  • 6 months later...
16 hours ago, ngrmm said:

great module @David Karich, thx!

will there be an option to cross-copy-paste content between two different matrix-repeater-fields with same matrix-repeater-field-types (same configuration)?
is or is this not possible?

Thank you, I'm glad it's useful to you and thank you for your donation. ? 

Unfortunately, cross-copying is not possible because at the point where you initialize the copy, the module does not know the name of the other field. So it can only read the current name of the matrix field and use this name when copying to the target. I'll think about whether you can introduce an option to select the target field before copying. But I think there is a lot of potential for errors when copying.

So first of all, unfortunately not possible at the moment.

BTW, @ryan, the module has been in checking for the module directory for several months now and has not yet been released. Does this module bother you in the context of a free extension for your ProModule?

  • Like 2
Link to comment
Share on other sites

  • 5 months later...

@David Karich I think I may have found a bug.

When I click the copy button I get the popup overlay, which when I click on OK does NOT go away.

I tried on firefox and on chrome, I am on PW 3.0.148 current master

Only way I can move on to next item is when I refresh the page

Question: would it be possible to extend your module with option for multiselect repeater matrix items?

Link to comment
Share on other sites

On 4/25/2020 at 12:05 PM, OllieMackJames said:

@David Karich I think I may have found a bug.

When I click the copy button I get the popup overlay, which when I click on OK does NOT go away.

I tried on firefox and on chrome, I am on PW 3.0.148 current master

Only way I can move on to next item is when I refresh the page

Question: would it be possible to extend your module with option for multiselect repeater matrix items?

Hey @OllieMackJames thank you, also for the donation. I think it came from you? ?

I'm not able to reproduce the problem with the prompt. Does the DeveloperConsole give you any JS Errors?

I had tried to implement the multiselect function before. But I failed on some points because it was not stable and reliable and in the end there were too many dirty JS hacks. Originally, this module was just a proof of concept, with the hope that @ryan would implement this function cleanly into the core of RepeaterMatrix. The needs for this feature are already quite high for the users.

  • Like 2
Link to comment
Share on other sites

2 hours ago, David Karich said:

Hey @OllieMackJames thank you, also for the donation. I think it came from you? ?

I'm not able to reproduce the problem with the prompt. Does the DeveloperConsole give you any JS Errors?

I had tried to implement the multiselect function before. But I failed on some points because it was not stable and reliable and in the end there were too many dirty JS hacks. Originally, this module was just a proof of concept, with the hope that @ryan would implement this function cleanly into the core of RepeaterMatrix. The needs for this feature are already quite high for the users.

Yes, that was me via paypal.

Console says: Empty string passed to getElementById().

The message stays on top and only goes away when I refresh the page.

Link to comment
Share on other sites

  • 1 month later...

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
×
×
  • Create New...