1 of 5
1
LG Data Matrix - New Multi-Text like custom field extension.
Posted: 03 August 2008 10:26 PM   [ Ignore ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1076
Joined  01-24-2006

Hey guys,

I thought I would throw a new extension I have written out into the wild fo you guys to have a play with. It’s still pretty rough but its coming along nicely.

The extension is similar to Mark Huots Multi-Text extension but adds a couple of extra features and has been written from the ground up. Props to Mark for creating the original extension.

So the features:

- Sortable Rows in the publish/edit form
- Text, Textarea and Select field types
- Easy per field configuration

How to use:

- Install the extension and its dependencies (Query 1.2.6 & jQuery UI 1.5 Core + Sortables)
- Activate the extension and check your jquery paths in the extension settings
- Create a new LG Data Matrix custom field

Heres a sample configuration for a custom field. It’s pretty simple so it shouldn’t need much explaining:

short_name = col_1
title
= Column 1
type
= text

short_name
= col_2
title
= Column 2
type
= textarea
rows
= 6
cols
= 10
width
= 50

short_name
= col_3
title
= Column 3
type
= select
options
= One|Two|Three
width
= 20

The short_name is used in the template tags.
The title is the column title.
The width parameter is a percantage *not* pixels.
The options param is only used if your type is a select box. Values must be seperated with a pipe.

So onto the templates:

{exp:weblog:entries}

    
<!--
    
lg_data_matrix is our custom field tag
    limit
= "" limits the number of rows
    flip
= "y" Flips the row order so that the last row shows first
    disable
= "cells|headers|rows" limits the tags that are parsed inside your custom field.
    
I highly recommend using the disable paramter if you are not using the tags in the loop.
    
It will speed up performance
    
-->
    
Example 1: A basic Table
    {lg_data_matrix limit
="2"}
    
<table border="1">
        <
thead>
            <!--
            
Loop over the column headers using the {header} tag
            Two tags are available
:
            
{col_title} - The column title
            {col_short_name}
- The column short name (good for css classes)
            -->
            <
tr>{headers}<td>Column Short Name: {col_short_name} Title: {col_title}</td>{/headers}</tr>
        </
thead>
        <
tbody>
            <!--
            
Loop over each of the rows using the rows tag
            
-->
            
{rows}
            
<tr>
                <!--
                
Loop over each cell in the row
                Three tags are available
:
                
{col_title} - The column title
                {col_short_name}
- The column short name (good for css classes)
                
{col_data} - The cell data
                
-->
                
{cell}<td>{col_short_name} {col_title}: {col_data}</td>{/cell}
            
</tr>
            
{/rows}
        
</tbody>
    </
table>
    
{/lg_data_matrix}

    Example 2
: Simple output of rows
    {lg_data_matrix limit
="2" }
    
<!-- Loop over our rows -->
    
{rows}
    
<ul>
        <!--
Output the data -->
        <
li>Column 1: {col_1}</li>
        <
li>Column 2: {col_2}</li>
        <
li>Column 3: {col_3}</li>
    </
ul>
    
{/rows}
    {
/lg_data_matrix}

{
/exp:weblog:entries}



You can grab the download from here: Download LG Data Matrix

All feedback welcomed and appreciated! smile

Update 0.0.2:
- A couple of bugs have been fixed
- Added flip parameter
- If you only want to retrieve the first row you don’t need to use the {rows} tag anymore:

{lg_data_matrix disable="headers|rows|cells"}
{col_1}
<--- The first row value for col_1
{
/lg_data_matrix}

Update 0.0.3:
- A couple of more small bug fixes including this one and this one.

Update 0.0.4:
- Hopefully fixed blank CP issue by disabling auto update if allow_url_open is not enabled.
- Added conditionals for {row} tags.
- Added {total_count} (number of rows) and {row_count} (current row number) inside of {rows} tag.

Update 0.0.5:
- Fixed issue where cells and headers weren’t being rendered since 0.0.4
- Renamed variables:
  - {short_name} is now {col_short_name}
  - {title} is now {col_title}
  - {data} is now {col_data}
- {total_row_count} is available anywhere as a value or a conditional.

Update 1.0.0:
- MSM Compatibility
- LG Addon Updater Integration
- Documentation

Image Attachments
FirefoxScreenSnapz003.pngFirefoxScreenSnapz004.png
Click thumbnail to see full-size image
 Signature 

VOTE FOR LG Addons in the Mashable Open Web Awards!


Newism - Newcastle Web Design & Development


LG Better Meta now w/ Sitemap Meta & XML Generator | LG Polls | LG .htaccess Generator

Profile
 
 
Posted: 03 August 2008 11:28 PM   [ Ignore ]   [ # 1 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6077
Joined  08-04-2002

Cool!
Any reason the width is limited to percentage Leevi?

Profile
 
 
Posted: 04 August 2008 12:16 AM   [ Ignore ]   [ # 2 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1076
Joined  01-24-2006
PXLated - 03 August 2008 11:28 PM

Cool!
Any reason the width is limited to percentage Leevi?

Yeah there is smile

You can’t drag and drop table rows with javascript very easily so each row is actually a list itme with nested divs. I could have made it pixel width but that may have broken the EE admin as it is not fixed width.

Also you do not need to put a width on every cell… The width of cells without explicit widths will be worked out based on the remaining width available. So if you only have one large field you can make sure that one has an explicit width. The rest should follow…

 Signature 

VOTE FOR LG Addons in the Mashable Open Web Awards!


Newism - Newcastle Web Design & Development


LG Better Meta now w/ Sitemap Meta & XML Generator | LG Polls | LG .htaccess Generator

Profile
 
 
Posted: 04 August 2008 12:22 AM   [ Ignore ]   [ # 3 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6077
Joined  08-04-2002

Ahhh - Cool

Profile
 
 
Posted: 04 August 2008 12:56 AM   [ Ignore ]   [ # 4 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  324
Joined  03-18-2007

Very Cool Leevi! Thanks!

Profile
 
 
Posted: 04 August 2008 01:13 AM   [ Ignore ]   [ # 5 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1076
Joined  01-24-2006

Ok I have found a couple of bugs already smile

I’ll have a new version available soon…

 Signature 

VOTE FOR LG Addons in the Mashable Open Web Awards!


Newism - Newcastle Web Design & Development


LG Better Meta now w/ Sitemap Meta & XML Generator | LG Polls | LG .htaccess Generator

Profile
 
 
Posted: 04 August 2008 04:57 AM   [ Ignore ]   [ # 6 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

Nice… do you ever sleep?

 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 04 August 2008 06:17 AM   [ Ignore ]   [ # 7 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1076
Joined  01-24-2006

Not enough smile

 Signature 

VOTE FOR LG Addons in the Mashable Open Web Awards!


Newism - Newcastle Web Design & Development


LG Better Meta now w/ Sitemap Meta & XML Generator | LG Polls | LG .htaccess Generator

Profile
 
 
Posted: 04 August 2008 09:31 PM   [ Ignore ]   [ # 8 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1076
Joined  01-24-2006

Ok I just updated the download to 0.0.2 and added some notes to the first post. Enjoy

 Signature 

VOTE FOR LG Addons in the Mashable Open Web Awards!


Newism - Newcastle Web Design & Development


LG Better Meta now w/ Sitemap Meta & XML Generator | LG Polls | LG .htaccess Generator

Profile
 
 
Posted: 05 August 2008 01:08 AM   [ Ignore ]   [ # 9 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  276
Joined  06-12-2002

Leevi,

This causes all kinds of weirdness with Masuga’s MarkItUp extension. I can forward you a control panel link if you want.

Profile
 
 
Posted: 05 August 2008 01:40 AM   [ Ignore ]   [ # 10 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1076
Joined  01-24-2006

Sure PM me the details I’ll take a quick look

 Signature 

VOTE FOR LG Addons in the Mashable Open Web Awards!


Newism - Newcastle Web Design & Development


LG Better Meta now w/ Sitemap Meta & XML Generator | LG Polls | LG .htaccess Generator

Profile
 
 
Posted: 05 August 2008 10:40 AM   [ Ignore ]   [ # 11 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  118
Joined  12-29-2004

Leevi, just wanted to say I just tried this out and it is awesome! Thanks so much for all you tirelessly (literally!) do for the EE community.

 Signature 

imagehat studio
the forum user formerly known as lavalamp

Profile
 
 
Posted: 05 August 2008 05:34 PM   [ Ignore ]   [ # 12 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1076
Joined  01-24-2006
alienne - 05 August 2008 01:08 AM

Leevi,

This causes all kinds of weirdness with Masuga’s MarkItUp extension. I can forward you a control panel link if you want.

Ok this turned out to be a very simple fix. The bug you reported will affect all custom field extensions when LG Data Matrix is installed.

Change lines 1044-1047 in ext.lg_data_matrix.php from:

}
  $r
= "<div class='lg_multi-text-field'>".$r."</div> <a class='add-row'>Add row</a>";
  
$SESS->cache['lg'][LG_DM_addon_id]['require_scripts'] = TRUE;
  return
$r;

to

$r = "<div class='lg_multi-text-field'>".$r."</div> <a class='add-row'>Add row</a>";
    
$SESS->cache['lg'][LG_DM_addon_id]['require_scripts'] = TRUE;
}
return $r;

Basically shifting the first two lines inside the previous if statement.

I’ll release a new update soon.

Bobs your fathers brother. smile

 Signature 

VOTE FOR LG Addons in the Mashable Open Web Awards!


Newism - Newcastle Web Design & Development


LG Better Meta now w/ Sitemap Meta & XML Generator | LG Polls | LG .htaccess Generator

Profile
 
 
Posted: 06 August 2008 07:33 AM   [ Ignore ]   [ # 13 ]  
Research Assistant
RankRankRank
Total Posts:  547
Joined  01-05-2005

Leevi, I’m trying this out but in my template the tags aren’t being parsed.

Using the code…

{lg_data_matrix limit="10"}
{rows}
<li><a href="{cf_news_links_url}">{cf_news_links_label}</a></li>
{/rows}
{
/lg_data_matrix}

I get

{lg_data_matrix limit=“10”}{rows}{cf_news_links_label}
{/rows}{/lg_data_matrix}

* {cf_news_links_label} is linked.

 Signature 

Celebrating again soon.

Profile
 
 
Posted: 06 August 2008 08:51 AM   [ Ignore ]   [ # 14 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  276
Joined  06-12-2002

Leevi,

That sort of fixes things, but only sort of. It fixes the fields for any weblog where there’s not a data matrix field actually implemented, but it’s still screwy in weblogs where there is.

Profile
 
 
Posted: 06 August 2008 09:55 AM   [ Ignore ]   [ # 15 ]  
Research Assistant
RankRankRank
Total Posts:  547
Joined  01-05-2005

Another error…

The data matrix field isn’t included in the SAEF but when viewing an entry in the control panel submitted from the SAEF I get the following errors…

Warning: array_keys() [function.array-keys]: The first argument should be an array in /path/to/cp/extensions/ext.lg_data_matrix_ext.php on line 1038

Warning
: Invalid argument supplied for foreach() in /path/to/cp/extensions/ext.lg_data_matrix_ext.php on line 1039

 Signature 

Celebrating again soon.

Profile
 
 
Posted: 06 August 2008 10:11 AM   [ Ignore ]   [ # 16 ]  
Research Assistant
RankRankRank
Total Posts:  547
Joined  01-05-2005

Sorry I should have maybe dug a little deeper first.  Sending the columns as hidden inputs seems to have sorted it.  Might be nice to do it without though.

<input value="" name="field_id_115[cf_news_external_url][]" type="hidden" />
<
input value="" name="field_id_115[cf_news_external_label][]" type="hidden" />

The no parsing in the template is still annoying me though if anyone has any ideas.

 Signature 

Celebrating again soon.

Profile
 
 
Posted: 06 August 2008 04:06 PM   [ Ignore ]   [ # 17 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1076
Joined  01-24-2006
smallbeer - 06 August 2008 07:33 AM

Leevi, I’m trying this out but in my template the tags aren’t being parsed.

Using the code…

{lg_data_matrix limit="10"}
{rows}
<li><a href="{cf_news_links_url}">{cf_news_links_label}</a></li>
{/rows}
{
/lg_data_matrix}

I get

{lg_data_matrix limit=“10”}{rows}{cf_news_links_label}
{/rows}{/lg_data_matrix}

* {cf_news_links_label} is linked.

Hey Smallbeer,

{lg_data_matrix ... should be your custom filed short name. By the looks of things it could be {cf_news_links}?

In the example my custom field was {lg_data_matrix}

Cheers

 Signature 

VOTE FOR LG Addons in the Mashable Open Web Awards!


Newism - Newcastle Web Design & Development


LG Better Meta now w/ Sitemap Meta & XML Generator | LG Polls | LG .htaccess Generator

Profile
 
 
Posted: 06 August 2008 04:19 PM   [ Ignore ]   [ # 18 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1076
Joined  01-24-2006
smallbeer - 06 August 2008 09:55 AM

Another error…

The data matrix field isn’t included in the SAEF but when viewing an entry in the control panel submitted from the SAEF I get the following errors…

Warning: array_keys() [function.array-keys]: The first argument should be an array in /path/to/cp/extensions/ext.lg_data_matrix_ext.php on line 1038

Warning
: Invalid argument supplied for foreach() in /path/to/cp/extensions/ext.lg_data_matrix_ext.php on line 1039

Feel like a bit of hacking? smile

Try change lines 1030 - 1044 (or there abouts) to:

// new entry
            
if(($cols = unserialize($field_data)) === FALSE || empty($field_data) === TRUE)
            
{
                $r
.= $this->_build_row($this->conf['cols']);
            
}
            
// edit
            
else
            
{
                $col_short_names
= array_keys($cols);
                foreach (
$cols[$col_short_names[0]] as $rows)
                
{
                    $r
.= $this->_build_row($this->conf['cols'], $cols);
                
}
            }
            $r
= "<div class='lg_multi-text-field'>".$r."</div> <a class='add-row'>Add row</a>";

This should check if there is actually data to unserialise and build the rows. If there is no record the extension is still storing an empty array. I’ll try and update it so that if there is an empty row it doesn’t get stored.

Cheers

 Signature 

VOTE FOR LG Addons in the Mashable Open Web Awards!


Newism - Newcastle Web Design & Development


LG Better Meta now w/ Sitemap Meta & XML Generator | LG Polls | LG .htaccess Generator

Profile
 
 
   
1 of 5
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64918 Total Logged-in Users: 25
Total Topics: 81871 Total Anonymous Users: 14
Total Replies: 440155 Total Guests: 181
Total Posts: 522026    
Members ( View Memberlist )