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! ![]()
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
