Login!
Lost password?
 

MODx Bug/Feature Tracker and Feature Requests

Welcome to the MODx CMS Tracker. Please choose the appropriate project from the drop down menu and provide as much information as possible regarding your server environment and browser. Thanks!

FS#926 — TV sortorder lost when changing TV

Attached to Project — MODx
Opened by Michel (Mitch) - Sunday, 22 July 2007, 06:57AM
Task Type Bug Report
Category Core Distribution
Status Closed
Assigned To No-one
Operating System All
Severity Low
Priority Normal
Reported Version 0.9.6
Due in Version Undecided
Due Date Undecided
Percent Complete 100%

Details

I noticed that the sortorder of the TV's in a template gets lost when I change a TV. For example I had my TV's sorted for my standard template. Now I change one of the TV's type from "Text" to "Text area (mini)" and now the sortorder is not the same anymore.

See original forum post: http://modxcms.com/forums/index.php/topic,16090.msg103015.html#msg103015
This task depends upon

This task blocks these from closing
Closed by  Ryan Thrash (rthrash)
Tuesday, 23 September 2008, 11:19PM
Reason for closing:  Fixed
Additional comments about closing:  Will be resolved in 0963. If not please reopen a ticket in Jira.
Comment by Paul Bohman (paulb) - Tuesday, 14 August 2007, 11:41AM
I have seen this behavior as well. I can always go and rearrange again, but it would be better to not have to do this.

Comment by Adam Kirk (Crash1hd) - Thursday, 06 March 2008, 03:23PM
I also having the same issue in 0.9.6.1B, I looked into what would be causing this issue is in the save_tmplvars.processor.php in processors file and this happens on anytime you hit save in a template variable edit state. On line 132 it calls saveTemplateAccess() function which removes and then reinserts the id and its template (obviously removing its ranking position and putting it back at the top) not sure why this would be needed on an edit and if this line is removed it resolves this issue (but do so at your own discretion I am not liable :) )

Comment by Paul Bohman (paulb) - Wednesday, 12 March 2008, 10:41AM
Removing that line breaks the ability to link existing template variables with new templates when editing the template variable. You can select the template, but the change won't be saved.

Comment by Adam Kirk (Crash1hd) - Saturday, 15 March 2008, 01:18PM
Ahh makes sense (I wouldn't have ever seen that as I don't have more then 1 template on any site I do). So i looked into it further and did the following (maybe this will solve it :0) )

I undid what I did above (back to the way it was) and then did the following below
in the same file I did all my modifications inside the saveTemplateAccess() function.

1. I added a global call to $modx (could have done it without but I thought why not)

2. added the floowing lines below this line
$tbl = "$dbase.`".$table_prefix."site_tmplvar_templates`";

I added the following
$getRankArrayKey = array();
$getRankArrayValue = array();

$getRank = $modx->db->select("templateid, rank", $tbl, "tmplvarid=$id");

while( $row = $modx->db->getRow( $getRank ) ) {
array_push($getRankArrayKey, $row[templateid]);
array_push($getRankArrayValue, $row[rank]);
}

$getRankArray = array_combine($getRankArrayKey,$getRankArrayValue);

3. I change the for loop to this

for($i=0;$i<count($templates);$i++){
$setRank = ($getRankArray[$templates[$i]])?$getRankArray[$templates[$i]]:0;
mysql_query("INSERT INTO $tbl (tmplvarid,templateid,rank) VALUES($id,".$templates[$i].",$setRank);");
}

seems to have fixed the issue :)

let me know what you think (again this worked for me no promises :)