I checked this thread to see if this question has been covered but nothing yet…
I have been asked to quote on a site that includes time sheet uploading where clients log in and create a new time sheet with details of their staff including hours worked and their IDs.
Multi-Text looks like a winner except they need to be able to output each Multi-Text entry as a comma delimited file to import into MYOB accounts. Is that possible with this extension?
If it is possible but not yet implemented then I would love to have a $ cost so I can quote appropriately.
Like ira42’s post above says, I too would like to sort the results on the template by one of the columns. I can think of two ways this could be done (totally riffing here, so I might be crazy):
In the entry in the control panel by dragging the rows up and down (yay asynchronous Javascript) which I’m sure would be a significant rewrite.
On the template level - maybe with the query module, or adding a new output parameter like:
<ul>
{members col_1="available" sortcol="col_2" sortorder="desc"}
<li><strong>{col_1}</strong>: {col_2}</li>
{/members}
</ul>
I’d then assume that the above would grab every line where {col_1} equals “available” and then sort them by {col_2}, descending.
I guess a significant problem would arise if one was trying to sort by numbers (in my real-life working-on-it-right-now case that would be square footage). I’m not sure how these fields are stored in the database but it’s some form of text I would guess.
I’d almost prefer the “drag to sort” method in the Control Panel, myself.
Any tips or tricks welcome, and I’ll post something here if I figure out anything interesting!
Yes, you can do that sort of thing. I actually have the very template open right now on which I’m doing that. What a coincidence! Note that to get it to work you might have to do it like this:
{if "{col_9}" != "" }
Actually - I don’t think you can keep any fields blank with this extension. I made it very clear to my client that they need to put a hyphen in any field for which they have no info - so I test against a hyphen.
I keep getting stuck with this extension, it doesn’t seem to record empty rows or empty text fields.
Is it possible if I change the extension file to make it pre-populate each text field with a single letter such as “x” so that when the table is displayed I know what fields are empty.
What would I need to change?
I’d appreciate any help.
It works correctly on a new entry, but not on an edited entry. It adds another dash in the fields for edited entries… at least it’s doing that on my end.
Gotcha.
I did a bit of work on it with clear and blur fields and I got it to work.
I also got rid of it adding an extra row.
All the corrections I made are in the Publish function. I have to post these corrections in multiple messages because the character length requirements for this forum.
This is replacing the js starting on line 253
<code>function newMultiTextRow(reference, field) { if(!document.getElementById) return false; if(!document.getElementById("field_id_"+field+"_table")) return false; var table = document.getElementById("field_id_"+field+"_table").getElementsByTagName('tbody').item(0); var trs = table.getElementsByTagName("tr"); var row_count = reference.getAttribute("numRows"); // trs.length - 1; var cells = trs.item(1).getElementsByTagName("td"); var cell_count = cells.length; var new_tr = document.createElement("tr"); for(i=0; i<cell_count-1; i++) { td = document.createElement("td"); input = document.createElement("input"); input.name = "field_id_"+field+"_"+row_count+"_"+i; input.style.width = "100%"; input.value = "X"; input.onclick = "clickclear(this, 'X')"; input.onblur = "clickrecall(this,'X')"; td.appendChild(input); new_tr.appendChild(td); } var del_td = document.createElement("td"); del_td[removed] = "<a href=\"#\" title=\"Remove Row\" onclick=\"removeMultiTextRow(this); return false;\">(delete)</a>"; new_tr.appendChild(del_td); table.appendChild(new_tr); reference.setAttribute("numRows", Number(row_count)+1); } function removeMultiTextRow(anchor) { if(!document.getElementById) return false; if(!confirm("Are you sure you want to remove this row?")) return false; var table = anchor[removed][removed][removed]; var row = anchor[removed][removed]; if(table.getElementsByTagName("tr").length == 2) { inputs = row.getElementsByTagName("input"); for(var i=0; i<inputs.length; i++) { inputs.value = ""; } } else { table.removeChild(row); } } function clickclear(thisfield) { if (thisfield.value == "X") { thisfield.value = ""; } } function clickrecall(thisfield) { if (thisfield.value == "") { thisfield.value = "X"; } }</code>
And I changed this chunk around line 387 (with the new js):
for($row_count=0;$row_count<=count($data)-1;$row_count++)
{
$row_data = array();
if(isset($data[$row_count]))
{
$row_data = preg_split("/[\r\n]/", $data[$row_count]);
}
$r .= "<tr>";
for($i=0; $i<$columns; $i++)
{ $r .= "<td >";
$r .= "<input name=\"field_id_".$row['field_id']."_".$row_count."_".$i."\" value=\"";
if(isset($row_data[$i])) {
$r .= $row_data[$i];
if($row_data[$i]==''){
$r .='X';
}
}
else {
$r .='X';
}
$r .= "\" onclick=\"clickclear(this, 'X')\" onblur=\"clickrecall(this,'X')\" type=\"text\" style=\"width:100%;\" />";
$r .= "</td>";
}
$r .= "<td><a href=\"#\" title=\"Remove Row\" onclick=\"removeMultiTextRow(this); return false;\">(delete)</a></td>";
$r .= "</tr>";
}
Anyway it now works for what I need it to do.
Thanks for getting me started.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.