DigitalFyre Posted March 14, 2013 Share Posted March 14, 2013 On 5.1.3, I had a few custom hooks that utilizes pulling smarty variables via: function foo_bar($vars) { global $smarty; $module = $smarty->get_template_vars('modulename'); } These functions stopped working on 5.2.1, by adding var_dump($smarty); to the code, it returns NULL while it should return proper results. What was changed to cause this? Any alternative? Or is there a fix? This is a rather huge issue; at least to us. 0 Quote Link to comment Share on other sites More sharing options...
gohigher Posted March 14, 2013 Share Posted March 14, 2013 Agreed - if you dig deeper you'll find you may have a 'ca' variable: global $ca; and smarty is hidden in there... but the variables are not accessible yet I'm afraid. http://forum.whmcs.com/showthread.php?69482-5-2-1-feedback&p=300658#post300658 0 Quote Link to comment Share on other sites More sharing options...
gohigher Posted March 14, 2013 Share Posted March 14, 2013 Are you on a client area page? Maybe the hook is executing before the client area page has been initialized? 0 Quote Link to comment Share on other sites More sharing options...
DigitalFyre Posted March 14, 2013 Author Share Posted March 14, 2013 This used to work before. However, here's the response I got for my ticket: Hello The $smarty object has been removed from global as part of some wider ongoing refactoring of the WHMCS core. The proper solution for defining custom variables is and has always been to simply return an array of the variables you want to set from your ClientAreaPage hook simply like this: return array( 'var1' => 'xyz', 'var2' => 'abc', etc... ); Hope this helps. I am very unhappy with this :-/ 0 Quote Link to comment Share on other sites More sharing options...
gohigher Posted March 14, 2013 Share Posted March 14, 2013 ... except when the ClientAreaPage isn't called. "..as part of some wider ongoing..."... sounds like they don't even know why they are doing it. lol I agree they need to refactor the core (along with their update / upgrade processes but I digress) but hiding smarty away isn't very wise imho - it's been exposed and available for at least 5 years and was reliably in place from version to version, even major updates. They also seem to make drastic changes for some unknown reason. For example, they used tinymce in version 5.0, then nicEditor which was very lightweight and usable and friendly in 5.1, now they are back to tinymce in 5.2. This would seem to be a somewhat fundamental item that shouldn't get changed frequently, at least in minor releases as 5.1, 5.2 etc. As a 3pd, I dread the coming 6 week update process... can you imagine having to refactor every product every 6 weeks? I would be looking for another platform I think if that happens 0 Quote Link to comment Share on other sites More sharing options...
DigitalFyre Posted March 14, 2013 Author Share Posted March 14, 2013 I won't disagree. I'm trying to utilize $ca, but no luck so far... Will fiddle with it more later. What is more important now is to iron the crappy bugs in 5.2.1 and hopefully get things working. I am still waiting on them to update the ticket. 0 Quote Link to comment Share on other sites More sharing options...
DigitalFyre Posted March 14, 2013 Author Share Posted March 14, 2013 (edited) Do you know someone who codes for WHMCS with whom I can get in touch? Edited March 14, 2013 by DigitalFyre 0 Quote Link to comment Share on other sites More sharing options...
gohigher Posted March 14, 2013 Share Posted March 14, 2013 I do development on WHMCS, but I'd have to be honest in saying I'm trying to catch up on the changes they made for my products and wouldn't be able to get to anything right away. Did you look at the forum post I had linked to ? It provides a method of pulling the template variables from the smarty object hidden in the global ca variable, but does require PHP 5.3 unfortunately. Hopefully WHMCS will roll out with some methods on their object to be able to retrieve the object variables. 0 Quote Link to comment Share on other sites More sharing options...
DigitalFyre Posted March 14, 2013 Author Share Posted March 14, 2013 Yes, I saw it. But I was unable to incorporate it with my code. This is what I could use help with. I have 2 codes, small and large, if I figure out how to do it with the small, will figure out the large. Here's my small code below: <?php function unblockme_show($vars) { global $smarty; $module = $smarty->get_template_vars('modulename'); $server = $smarty->get_template_vars('server'); $status = $smarty->get_template_vars('status'); $lang_arr = $smarty->get_template_vars('LANG'); $activetxt = $lang_arr['clientareaactive']; if (($module == "cpanel") && ($server) && ($status == $activetxt)) { $isactive = 1; } else { $isactive = 0; } $smarty->assign("unblockme_isactive", $isactive); } add_hook("ClientAreaPage", 1, "unblockme_show"); ?> 0 Quote Link to comment Share on other sites More sharing options...
gohigher Posted March 14, 2013 Share Posted March 14, 2013 Are you sure the clienteareaactive string hasn't changed and that the other variables are still in place? I recall their changelog saying they have a new method for testing the status perhaps they also wiped that variable from being accessible? Also, it looks like you are comparing the status set in the module with a language string, which I wouldn't think would be reliable (though I cannot say for sure what the status variable would hold). The function I wrote and linked you to would pull the variable if you made a call like 'getvar( 'modulename' )' it should come back with the modulename if it is set in smarty or in the ca variable. 0 Quote Link to comment Share on other sites More sharing options...
HawtDogFlvrwtr Posted March 14, 2013 Share Posted March 14, 2013 5.2.2 will be out shortly and will address these issues. Please check the feedback thread on 5.2.1 in the forum a few up.. you'll see the progress. 0 Quote Link to comment Share on other sites More sharing options...
DigitalFyre Posted March 15, 2013 Author Share Posted March 15, 2013 Yep, that fixed it alright! Woohoo! 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.