Page 1 of 1
[SOLVED] Problem with UDT upgrading from 1.9.4.3 to 1.11.4
Posted: Sun Jan 13, 2013 11:32 pm
by dbuenzli
Hello,
I have the blank editing page/cannot save template problem. It seems it is due to the following UDT:
Code: Select all
$gCms = cmsms ();
// Sets the smarty variable $wsite_lang
// The root of the hierarchy path of the current page defines the language.
$lang = explode ("/", $gCms->variables['content_obj']->HierarchyPath(), 2);
$gCms->GetSmarty ()->assign('wsite_lang', $lang[0]);
I tried to replace the $lang line with the seemingly more reliable:
Code: Select all
$lang = explode("/", cms_utils::get_current_content()->HierarchyPath(), 2);
But it still doesn't work (it does work if I set $lang to a static string). Any hints of what I'm doing wrong ?
Thanks for your answers.
Re: Problem with UDT upgrading from 1.9.4.3 to 1.11.4
Posted: Mon Jan 14, 2013 7:32 am
by TheLastLegion
1. Make sure menu is not cachable in menu manager
2. Update site template, to see what you need to update, create new template and default code will be generated for you, integrate the missing parts from the template into your site template
3. Read similar threads, lots of people with upgrade problem from your version to 1.11.4 all had their problem solved. Please use search
Re: Problem with UDT upgrading from 1.9.4.3 to 1.11.4
Posted: Mon Jan 14, 2013 7:59 am
by dbuenzli
Thanks but that doesn't really help, I already mostly did that.
The problem lies in this UDT. If I remove the call to it in the template I can edit my pages.
Re: Problem with UDT upgrading from 1.9.4.3 to 1.11.4
Posted: Mon Jan 14, 2013 8:33 am
by Rolf
$gCms = cmsms_();
$gCms = cmsms();
Re: Problem with UDT upgrading from 1.9.4.3 to 1.11.4
Posted: Mon Jan 14, 2013 8:42 am
by dbuenzli
Thanks Rolf but removing these spaces don't change anything. As I said in my first post the problem specifically lies on the $lang line. If I change it to a constant string everything works fine.
Re: Problem with UDT upgrading from 1.9.4.3 to 1.11.4
Posted: Mon Jan 14, 2013 9:12 am
by dbuenzli
Not sure exactly why (I'll gladly take an explanation) but replacing the $lang line with the following solves the blank editing page/inability to save template problem.
Code: Select all
$c = cms_utils::get_current_content();
if (isset($c)) { $lang = explode('/', $c->HierarchyPath(), 2); }
Cannot check right now if the code still works since I have other template compilation problems. Will report later.
[SOLVED] Re: Problem with UDT upgrading from 1.9.4.3 to 1.11
Posted: Mon Jan 14, 2013 4:50 pm
by dbuenzli
The fix works, I got the hint from
here. I'm still taking any better explanation on why this is needed, somehow I don't fully grasp what's written there ("smarty cannot properly trap (?) a template"). Thanks.
Re: [SOLVED] Problem with UDT upgrading from 1.9.4.3 to 1.11
Posted: Mon Jan 14, 2013 5:17 pm
by calguy1000
because $gCms->variables is internal data, not for public use, deprecated and subject to change. And it probably has changed.
Re: [SOLVED] Problem with UDT upgrading from 1.9.4.3 to 1.11
Posted: Mon Jan 14, 2013 6:26 pm
by dbuenzli
But it didn't work even when I did not use
$gCms->variables. That is:
Code: Select all
$lang = explode("/", cms_utils::get_current_content()->HierarchyPath(), 2);
didn't work either. It only worked when I added the
isset condition to test the result of
cms_utils::get_current_content().
My (wild) guess is that when you try to save a template it tries to compile it in an incomplete context compared to when it is invoked with data and that may fail, preventing you from saving the the template.
Re: [SOLVED] Problem with UDT upgrading from 1.9.4.3 to 1.11
Posted: Mon Jan 14, 2013 6:28 pm
by calguy1000
correct.... and you should prolly use is_object instead of isset().
There is no 'current frontend page' when editing content or editing templates from the admin.
Re: [SOLVED] Problem with UDT upgrading from 1.9.4.3 to 1.11
Posted: Mon Jan 14, 2013 6:59 pm
by dbuenzli
Ok, thanks for the tip.