Hi,
I’ve put together a quite simple cell type for a FF Matrix, basically it outputs a plain text {whatever-x} within your matrix row, where ‘x’ is the row count, and ‘whatever’ is whatever you want…
See the screenshot attached of what it does, and if you’re wondering why you’d need such a thing… its for accompanying the most excellent LG Replace plugin where you can insert the contents from fields dynamically within other fields. (See this screen-cast too for more information on using LG Replace).
Instructions are included in the zip file but are here also:
Version 1.1.0 (Updated to include Brandon’s tips below)
INSTALLATION:
Drop the ‘iain_copee_pastee’ folder into your /system/extensions/fieldtypes/ folder.
Enable the Field Type in your ‘Utilities -> FieldTypes Manager’
USAGE:
Create a new cell in your Matrix and assign it to be a “Iain Copee Pastee” field type. Use the lower ‘label’ to select what text you’d like to be displayed to the publisher. Your text will be prefixed with “{" and appended with "x}” where x is the row count.
I am a noob with php, and jQuery and just starting out with EE dev so if any devs out there see room for improvement, please sing out.
Download is available from Jam Digital
EDITS: 17 August 2009: Just re-uploaded v1.1.0 - Forgot to update the version number in the file. 17 December 2009: Removed forum hosted version, placed on Jam Digital
Hi Iain,
Nice work! But, there’s no need for these FF Matrix modifications.
If you place your iain_copee_pastee.js file within your own fieldtype’s folder, you can include it yourself by adding this to your display_cell method:
$this->include_js('iain_copee_pastee.js');Within that JS file, wrap your code with the following:
$.fn.ffMatrix.onDisplayCell.iain_copee_pastee = function(cell, FFM) {
// cell initialization code here.
// `cell` is the table cell containing your celltype
// `FFM` is the FF Matrix object
};Cool, implemented this. 😊 Thanks Iain.
The only thing that would make it even UBER awesome is if the client skips the need to click, highlight, press CTRL+C… don’t know how to add the functionality, but if the client can just click on this area and the text is automatically COPIED, then the only thing they have to do is paste it where they want.
Cool, implemented this. 😊 Thanks Iain. The only thing that would make it even UBER awesome is if the client skips the need to click, highlight, press CTRL+C… don’t know how to add the functionality, but if the client can just click on this area and the text is automatically COPIED, then the only thing they have to do is paste it where they want.
I went down this route for some time, mainly with zeroclipboard. Getting it to click to copy was quite straight forward but as I started using it in production it was evident there were some issues.
The main problem is that zeroclipboard uses a flash file to overlay the element you want copied, and it does this via absolute positioning. So, when you hide/show a field above Copee Pastee, the target click area moves away from its original element, this combined with a couple of other niggles had me pull the plug.
Lots of Jquery versions of that functionality.. would be a cinch to add. Iain if you don’t, I’ll give it a stab.
Go for it, if you find something reliable and cross browser I’d love to see it integrated.
Looks handy. My big question though… what extension are you using to get WYSIWYM editor for your field?
You can grab the extension from my Google code repository
It can be used as a field, or a matrix cell type. If you’re using it as a cell, it does have an issue where the editors start ‘doubling’ when you add more than one row at a time between saves. I’ll look at a fix when I have time. The lessons learnt here will apply 😊
EDIT: Sorry, link to google code was broken, just updated it…
I managed to get it to copy the value when you click on it by using ZeroClipboard (http://code.google.com/p/zeroclipboard/downloads/list). I attached the updated iain_copee_pastee.js file.
One question for the FieldFrame elite out there: Is there a better way to point to the ZeroClipboard.swf file?
Two questions for @iain: Why is there a copee_functions.js file and a iain_copee_pastee.js file? Could you put this on GitHub so i can fork it?
I managed to get it to copy the value when you click on it by using ZeroClipboard (http://code.google.com/p/zeroclipboard/downloads/list). I attached the updated iain_copee_pastee.js file.
Hi Wes, yeah you got to where I got, if you add the following lines into copee_style.css, and see where the flash overlays are appearing, it all looks a bit hacky to me…
embed {border: 1px solid red;}Check the two screenshots below, first (on_load.png) is ok, looks like the flash files are going where they should be,
then if you start changing the pages layout, by collapsing/opening any of the fields above, see the second screenshot below.
Not ideal, and exactly the reason I didn’t bundle in the release…
Two questions for @iain: Why is there a copee_functions.js file and a iain_copee_pastee.js file? Could you put this on GitHub so i can fork it?
There are two files because the first release had a seperate js file to place within ff_matrix folder. With some quick advice from Brandon he explained how it could be done better. I updated the files as quickly as I could so that’s why there are two… Next version won’t, and some updates from Brandon in 3.1 has meant some other minor improvements to this fieldtype also.
Regarding GitHub, I haven’t used it yet but I have been reading up and watching some screencasts, I’ll let you know when I create an account and start hosting my code over there.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.