Dec 04, 2008, 04:17 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
Search via SMF or Google: modx forums all of modxcms.com web
  MODxCMS.com   Forums   Help Login Register  
News:Read what MODx Developers say: MODx Dev. Blogs
Pages: [1]   Go Down
  Print  
Author Topic: TV sortorder lost when changing TV  (Read 1413 times)
0 Members and 1 Guest are viewing this topic.
Mitch
Full Member
***
Posts: 225


« on: Jun 27, 2007, 11:08 AM »

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 from "Text" to "Text area (mini)" and now the sortorder is not correct anymore.

Is this behaviour expected when I change the TV or should I file a bug report for this?

Seen on 0.9.6
Logged
rthrash
Foundation
*
Posts: 9,577



WWW
« Reply #1 on: Jun 27, 2007, 11:56 AM »

File a bug report please.
Logged

MODx is a framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Community participation and questions are encouraged, especially when you help us help you, read the wiki, and review snippet parameters – even if you have to look at the source. Searching the forums helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.
FuryDE
Full Member
***
Posts: 172



« Reply #2 on: Jul 09, 2007, 10:45 AM »

The same problem exists when I change the input option values (in my given case an @SELECT) of a TV. I just fixed an error and it seems that the TV I edited was set to the first (top) position.

Martin
Logged
Mitch
Full Member
***
Posts: 225


« Reply #3 on: Jul 22, 2007, 06:59 AM »

Reported: FS#926 (sorry for late reaction, been on holiday Wink )
Logged
Crash1hd
Jr. Member
*
Posts: 25


« Reply #4 on: Mar 06, 2008, 03:24 PM »

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 Smiley )

I have added the same above into the bug report

Looks like a quick fix
Logged
Crash1hd
Jr. Member
*
Posts: 25


« Reply #5 on: Mar 15, 2008, 09:40 PM »

OK so I have been informed that by just removing the call to the function removes the ability to properly change templates.  What was I thinking of course nothing is a quick fix lol Smiley ok so I did some more research and came up with the following that restores the ability to change templates without changing the rank of the template variable.

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) admin note: it is needed

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

I added the following
Code:
$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

Code:
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 Smiley

let me know what you think (remember I am not a modx guru by any means and again this worked for me no promises Smiley )
« Last Edit: Apr 20, 2008, 12:15 AM by rthrash » Logged
rthrash
Foundation
*
Posts: 9,577



WWW
« Reply #6 on: Apr 20, 2008, 12:52 AM »

Just to confirm this works great. Thank you. Smiley
Logged

MODx is a framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Community participation and questions are encouraged, especially when you help us help you, read the wiki, and review snippet parameters – even if you have to look at the source. Searching the forums helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.
The Man Can!
Testers
*
Posts: 296



WWW
« Reply #7 on: May 01, 2008, 05:00 AM »

Is it just me, or does this hack kill the ability to remove a TV from a template? ie. Once a TV is assigned to a template, it can't be unassigned when this hack is present?

Or I could have botched the hack. If somebody could let me know it'd be great.
Logged

Need MODx Ecommerce? Try FoxyCart!
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP

Copyright © 2005-2008 MODxCMS, All rights reserved. Contact Us
Styles by ziworks.com

Powered by SMF 1.1.4 | SMF © 2005, Simple Machines LLC

Valid XHTML 1.0! Valid CSS!