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
| 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 |
|
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.
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.
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 :)