Variable override in smarty fails (jtl plugin). Is there smarty caching? - smarty

this is kind of a specific question but I am wondering if someone of you came across the same problem before.
What I am trying to do:
I am working on a jtl plugin.
To start off, the plugin should just run over the payments (the specific hook is active an works) and rename the description. Since I need to add more functionality later, all the stuff has to happen in the plugin (even though jquery would be easier for the former case).
In the shop system, the payments are set like this:
$smarty->assign('Zahlarten', $zahlarten);
In the plugin, I get all the payments like this:
$tmpPayments = $smarty->get_template_vars('Zahlarten');
I then loop over the array, doing specific changes. In the end, I want to add the payments back like:
$smarty->assign('Zahlarten', $tmpPayments');
And this is, what does not work. When I change the description and watch the variables in the phpstorm debugger, they are updated accordingly.
But after the page is loaded completely, the changes are not visible.
I know professional plugins that do it the exact way, and it works.
Changing the original array also does not help.
Also, deactivation caching does not work. Like this:
$smarty->assign('Zahlarten', $tmpPayments', true);
What works is:
$smarty->assign('Zahlarten_tmp', $tmpPayments');
But thats obviously not what I want, since I would have to change the template for that.
To wrap it up, it seams to me that there is some kind of caching going on which I can not figure out.
Does anyone has an idea or can point me to sources that might help?
Thanks in advance!

I finally came across the answer (hours later :P).
Root of the problem:
Some system source code far away from my actual context made its own calculations, leading to another
$smarty->assign('Zahlarten', $farAwayCalcs);
,thus overriding my changes.
Never underestimate stepping through the code with your favorite debugger. ;)
Cheers!

Related

Need to 'gatsby clean' with essentially every code change

So, our team are working on a Gatsby website, and it's working correctly for most of us.
One developer, however, needs to run gatsby clean on essentially every single code change.
Doesn't matter if it's an error, changing a text value or adding markup.
I realise this is a fairly vague question, but I'm not sure where to start troubleshooting this.
Has anyone encountered this before?

How/where is room template used

I'm playing with the rocket.chat ui, and taking the room template out of context breaks it. It's a global template therefore nothing imports it. I'm trying to use it exclusively within D.M. channels if its relevant.
I think the issue might be the fact that the room must be opened by app/lib/lib/direct.js although I can't believe that can affect the layout quite so much that like nothing really works.

How to modify com_mailto to fit out needs

I'm developing a site for my company and I also need to modify the native component "mailto" to fit our needs.
I'm working with a joomla 2.5
I was wondering if future updates occur, what will happen to the lines I've added, for example, in "\components\com_mailto\controller.php"...
I haven't find answers on the net.
Also, for the same reason, I've modified the default layout of an article. Should I rename it? and if yes, how, because I couldn't do it (when I've tried the article did not display).
Thanks for your help
Before starting to edit core Joomla components, should should always have a look at the options you have. I don't believe in editing core file as it simply causes problems for updates when released, therefore in my opinion, you have 2 options:
I always make a note of all my requirements and start looking for a 3rd party extension that caters for my requirements.
If I cannot find a 3rd party extension and don't particularly want to start digging into it's code, I would go with developing a plugin. Plugins are used to manipulate the behavior or something and therefore come in extremely handy for when you would require core editing.
Editing the layout of an extension view is completely fine, but it's strongly recommended you make a Template Override so that if the extension does ever get updated, your changes won't get overridden.
So to answer you initial question, any line you have added to the controller.php file will get overridden when you decide to update the extension.
Hope this helps
While the answer from Lodder is totally valid, as a last resource you can also consider forking the com_mailto as a separate component.
This has some disadvantages:
you need to rename all the files involved (controllers, models, views)
you need to maintain it and keep in in sync with future updates (consider than you are now on 2.5.x and in a year you might want to upgrade to 3.x).

Does a Magento Module Validator Exists?

I'm writing a module and for the life of me I can't get it to work. I've made several modules in the past so I'm guessing I have some stupid mistake somewhere. Does anyone know if there's a Magento module validator out there to point out problems with a modules structure and format?
The closest thing is the configuration lint system I built a while back. While far from a full fledged validator, it checks for common configuration errors and allows you to write you own test.
The first unofficial steps of manual validation involve checking the "Disable Module Output" section of the magento admin to see if your module is loading. If it doesn't show up in there, that means there's a problem with your
etc/module/*.xml
file. (maybe code pool?)
There isn't any validators that I'm aware of. Sometimes the best thing to do is to start a new module and slowly re-build it. Keep adding very small pieces of functionality or configuration at a time. You'll eventually find out what doesn't work.
With Magento, there are so many places it can go wrong, even down to improper capitalization of words in your config.xml file. I can't tell you how many times I've made dumb mistakes that I spent hours trying to figure out, and it was a misspelling or something silly.
Good luck. I hope you can figure it out soon!

Error : Not all products are available in the requested quantity !! what does this mean?

i get this error when trying to submit the order in the shopping cart :
Not all products are available in the requested quantity
I have set the quantity to 1000 and made it in stock ... I have just installed magento and some other extensions , , so what i did wrong ,,
OK, I thought I'd better add a new answer so that I can add links and format code, etc. Apologies for the duplicate.
Well, learning to debug your code is definitely a big step up, but one that will provide a huge amount of insight into what the code is actually doing rather than relying on echo and print_r! :) Particularly for complex and genuinely object-oriented code where you jump around between objects all the time.
Firstly, make sure you're using a proper IDE. Again, I recommend Netbeans, but Eclipse will work. All links from here on will assume Netbeans.
There's a great tutorial on what debugging is with an example here on the Netbeans wiki. There are also setup guides for OSX, Windows and Ubuntu, so choose your poison!
The reason why I suggested the CartController.php and updatePostAction is because you can read from Magento's URL structure what module, controller and action are being called. So, if you inspect the form in the cart page (/checkout/cart), you'll see that the form submits to /checkout/cart/updatePost/, which means Mage_Checkout is the module, CartController is the controller and updatePostAction is the method. So when the user hits the "Update Shopping Cart" button, control (and the contents of the cart) will be passed to that method, hitting your breakpoint. You could also choose addAction in the same class to catch it as it is added from the product page.
Once you're in the active debugging session, inspect the variables and add watches (if necessary) to observe what's going on. Use your F8 key to move through and F7 to dive to interesting calls.
Debugging will definitely take you at least a day to get your head around the process, but the investment is definitely worthwhile, it will make you a much better developer.
Good luck!
JD
I'd be thinking what Will suggested and you obviously checked.
Unfortunately, this is probably one of those situations where you'll need to debug the core code to find out what's going on. Setup your local dev environment with xdebug (there are some good tutorials on how to do this depending on your OS, IDE and webserver but I find that Netbeans and apache2.2 work beautifully together) and then set a breakpoint in CartController.php inside updatePostAction() and trace it through.
Feel free to post back what you find, it might be useful to others.
Cheers,
JD

Resources