We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

LG Data Matrix - New Multi-Text like custom field extension.

Development and Programming

Andy Harris's avatar
Andy Harris
958 posts
16 years ago
Andy Harris's avatar Andy Harris

Has anyone tried getting this to work with Playa? This would be perfect but doesn’t fire:

{related_entries id="pricing"}
    {price_block}
        (lg data matrix code here)
    {/price_block}
{/related_entries}
       
rockthenroll's avatar
rockthenroll
485 posts
16 years ago
rockthenroll's avatar rockthenroll

I’ve found an odd bug when updating a field. It seems all the data wipes from the custom field. I’ve tried ot narrow the issue and found this:

  • Hitting preview wipes data from the custom field, but not from the DB. If you reload the entry page it pops back in because it’s still in the DB table.
  • Clicking update or Quick Save doesn’t not trigger this issue

Anybody else find this?

       
matt romaine's avatar
matt romaine
50 posts
16 years ago
matt romaine's avatar matt romaine

Hi Leevi,

great extension; proving very helpful so far.

just a quick request on localization - the “Add row” text is fixed into the extension file. would be great if this string could be localized too, so that I don’t have to do something like:

$r = “<div class=’lg_multi-text-field’>”.$r.”</div> <a class=’add-row’>追加する</a>”;

I think it’s around line 1060 in the ext.lg_data_matrix_ext.php.

cheers!

       
gridonic's avatar
gridonic
231 posts
16 years ago
gridonic's avatar gridonic
I’ve found an odd bug when updating a field. It seems all the data wipes from the custom field. I’ve tried ot narrow the issue and found this: * Hitting preview wipes data from the custom field, but not from the DB. If you reload the entry page it pops back in because it’s still in the DB table. * Clicking update or Quick Save doesn’t not trigger this issue Anybody else find this?

If you go and change the column short names or titles after you’ve entered data in the fields for some entries, they’re gone when you want to edit them.

So unfortunate, would be a really handy extension but for productive environments, this can be deadly.

       
Nelly's avatar
Nelly
81 posts
16 years ago
Nelly's avatar Nelly

I didn’t see this in the documentation and I had some problems with it, so I thought I’d mention it here: You can use two or more LG Data Matrix fields in the same weblog, but each column short name must be different.

Also, the docs mention a custom field named my_matrix in some instances, and lg_data_matrix in others 😊

Thanks for this extension, it’s very useful!

       
Nirada's avatar
Nirada
24 posts
16 years ago
Nirada's avatar Nirada
Around line 600 of ext.lg_data_matrix.php find:
$_POST['field_id_' . $row['field_id']] = ($rows !== FALSE) ? serialize($rows) : '';
and replace it with:
$_POST['field_id_' . $row['field_id']] = ($rows !== FALSE) ? addslashes(serialize($rows)) : '';
That should do the trick until the next version

Hi Leevi,

I tried modifying this line of code and inserting data with apostrophes now works ok. However, for the output, there are loads of backslashes, which seem to increase each time I edit the entry. I had an entry with the word “teacher’s” in it, and it’s now displaying as “teacher\\\\\\\\\\\\\\\'s”

Apart from that, it’s working great. Thanks for this extension. It’s really great and fits my purposes perfectly!

       
kirkaracha's avatar
kirkaracha
273 posts
16 years ago
kirkaracha's avatar kirkaracha

You could enable PHP in your template and use stripslashes in the meantime.

       
Cameron Corda's avatar
Cameron Corda
31 posts
16 years ago
Cameron Corda's avatar Cameron Corda

Levi, looks great, but when either your Live Look or LG TinyMCE extensions are also enabled for a weblog type, I get a jquery js error, and can’t add rows.

$(".lg_multi-text-field").click(function (e) {if ($(e.target).is(".delete")) {if (!confirm("Are you sure you want to delete this row?")) {return;}self = $(this);if ($(".row", self).length > 1) {$(e.target).parent().remove();$("> div:odd", self).attr("class", "row tableCellTwo");$("> div:even", self).attr("class", "row tableCellOne");}return false;}}).sortable is not a function
       
Nirada's avatar
Nirada
24 posts
16 years ago
Nirada's avatar Nirada

Victor, thanks for taking the time to go through this and post these changes.

However, after following all of the changes, I now get the following PHP error:

Notice: unserialize(): Error at offset 76 of 139 bytes in /home/site/system/extensions/ext.lg_data_matrix_ext.php on line 1048

In addition, all of the content now seems to be lost if there are any apostrophes in there!

Let me know if you need any further information!

       
Mark Terpstra's avatar
Mark Terpstra
205 posts
16 years ago
Mark Terpstra's avatar Mark Terpstra

Levi, thanks for this module - it’s working great.

I have a question about a possible use…

Here’s the current situation… (see screenshot attached) - I’m using Data Matrix along with Mark Huot’s File Extension for a “Photo Sets” weblog - First the user uploads the images using File - all in the same custom field with Multiple Uploads allowed - Then the user uses Data Matrix to order the images and add a title and description

Here’s my questions… - Would it be possible to use EE’s native File Upload feature - and insert the image url into one of the Data Matrix cells?

Thoughts?

       
Nirada's avatar
Nirada
24 posts
16 years ago
Nirada's avatar Nirada

Because our need for this extension is quite urgent, I asked our PHP Developer to take a look over the issue with apostrophes causing issues with this script.

His final fix for this extension only actually involves two changes. However, these changes can only be implemented if a bug he found in EE core is fixed first. I have already logged the bug in the EE bug tracker at https://support.ellislab.com/bugs/detail/6023/ so hopefully someone from the EE team will take a look at it soon as confirm that it should be fixed.

Anyway, assuming you have a patched core.input.php, you can fix ext.lg_data_matrix_ext.php. I’ll post the procedure and explanation below… you’ll have to un-do any other fixes that you’ve taken from this thread (I recommend downloading a fresh copy of the script).

First of all, in ext.lg_data_matrix_ext.php, go to line 569, which should be:

$_POST['field_id_' . $row['field_id']] = ($rows !== FALSE) ? serialize($rows) : '';

A problem we have here is that we are serializing data that has slashes in it. This creates a problem as the serialisation format takes a string such as:

That’s correct!

And turns it into this:

s:15:”That’s correct!”

However what is happening in this case is the string is actually:

That's correct!

and is serialized as:

s:16:”That's correct!”

But then will be written to the database as:

s:16:”That’s correct!”

The length mis-match will cause an unserialize() error, which is what people have been seeing (the line 1048 error). We can fix this by serializing data with no slashes, then adding them again afterwards…

To do this, REPLACE the above line of code with this block:

function user_stripslashes( &$val ){
    if( is_array($val) ){
        array_walk($val, "user_stripslashes");
    }else{
        $val = stripslashes($val);
    }
}
       
array_walk($rows, "user_stripslashes");
       
$_POST['field_id_' . $row['field_id']] = ($rows !== FALSE) ? addslashes(serialize($rows)) : '';

We are basically getting rid of all the slashes in the data that is to be serialized as the serialization will be broken if we don’t (as you saw above), then we use addslashes to make this data database safe after we have serialized it correctly (this was the original fix). I have used a recursive function again here to make this code PHP 4 compatible - array_walk_recursive would make it a lot simpler, however this function is only available in PHP 5!

Now, there is actually a further bug in this extension which doesn’t seem to have been mentioned here yet. When the data is placed back into these fields, it does not appear to be HTML escaped! This means that a value with a ’ in it will be truncated, eg…

<input value='That's correct!' ...

…would give us the value “That”, similarly if we input the text “</textarea>and more text” in the textarea, it would be truncated once again. The (simple) solution to this is the following line of code to escape all of our special characters:

Locate line 1156 of ext.lg_data_matrix_ext.php, which should be as follows:

switch ($col['type'])

BEFORE this line of code, add this:

$value = htmlentities($value, ENT_QUOTES, "UTF-8");

And finally we have a much more stable extension (and core.input if the bug is accepted by the EE team)!

IMPORTANT NOTE: The problems with this extension vary depending on the server setting of magic_quotes_gpc! For this reason, some people may not have experienced all of these problems, although the code is still buggy and ought be be patched in all cases.

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
16 years ago
Lisa Wess's avatar Lisa Wess

Hi, Nirada - thanks for all the help you have supplied here. You did attach, incorrectly, some files which are now removed. Please do be aware of our license.

While distribution is not allowed, you can certainly post in-depth instructions for those wishing to make modifications themselves.

Thank you again for your assistance on this one, and happy EE’ing!

       
Nirada's avatar
Nirada
24 posts
16 years ago
Nirada's avatar Nirada

Sorry about the attachments, Lisa! I guess I just got caught up in the whole flurry of trying to get this fixed and totally forgot about the redistribution policy.

Going back to the bug report… there were a few problems with the initial fix that I posted in there, but it has now been updated. Please see https://support.ellislab.com/bugs/detail/6023/ for further details.

       
Richard Frank's avatar
Richard Frank
200 posts
16 years ago
Richard Frank's avatar Richard Frank

Also looking to use the native file upload functionality for a custom gallery. Would be a great addition.

       
Activeark's avatar
Activeark
2 posts
16 years ago
Activeark's avatar Activeark

Would be great if I could add a file upload field. That would solve a lot of problems I currently have with EE publishing.

       
First 3 4 5 6 7 Last

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.