After searching for articles regarding template rewrites, I've done a successful one written on the article here.
However, as stated in the article, one would have to copy the contents from the original .phtml file to your custom .phtml file. This is where the problem lies -- since we're a team handling different modules at a time, it may come to a point where they would need to overwrite the .phtml file I've written and do the same process -- copying the contents from the original (Which in this case, should be my custom .phtml) to their custom .phtml, which isn't upgrade safe at all because any future changes that I make on my module will not reflect on the template as my colleague has already rewritten it.
Would there be another approach for this? Or would the only way around this is to merge our code into a single custom .phtml file?
One possible solution is to modify HTML via Magneto event core_block_abstract_to_html_before.
So that multiple modules can add modifications upgrade safe.
Downside is using regular expressions or xml changes in the code, not in the templates.
Related
Is there a way to rename a Variable or Variable Group without breaking the references it already have in Tibco Business Works 5.x. Thanks.
A way you could do this is by editing the complete source code that is in XML. After taking a proper backup.
You could identify the variable or variable group XML tags to be renamed and rename them by using an advanced text editor with Regular expressions if is the case.
Once you rename everything you would have to open TIBCO Designer and go to the root location of the project and validate All. Validate the complete project.
A manual cleanup and re-built, testing would be required.
Avoiding changes in a massive scale is advised. Less Risk.
I am working on an web built in PrestaShop that needs some re-design. I have made a copy of their theme and I am working there. Now I need to add some javascript files and they need to be included in all my theme pages.
I have read similar questions here and looked for info and basically I have found two solutions proposed:
1) Add the file directly into your HEAD.tpl using something like {$base_dir}
(explained here: Prestashop root directory)
2) Add the files in the FrontController.php (overrides/classes) with a new setMedia() function
(explained here: http://tinyurl.com/cxucwq7)
The second solution seems the most recommended one but when I open the FrontController.php I see the following warning:
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer versions in the future.
So I'm a bit confused now. Is it safe to edit this file? How about future upgrades, will they overwrite any changes made there? Isn't it safer to add them to your themes header.tpl and not affect the core of the cms?
(This is my first question here, I tried to follow the guides but I would appreciate any comments on how can I improve it, thank-you!)
It is totally safe to use the override file, and that's why they exist. I have used them in every Prestashop I made and they've never had been replaced in an update. The text they put is for the license, they probably just copy/paste it everywhere.
I wouldn't recommend manually adding the files to the header.tpl. It will work, but the advantage of adding it with the Tools::addJs() method is that the script will be concatenated with all the other scripts.
I have heard a lot of people in the Magento community mention the benefits of using a local.xml for Magento theme development
I can understand the benefits and I actually can't think of any cases where its use could be detrimental.
Are there specific situations where local.xml is a bad choice? If there are, then what would those be?
MagePsycho's points are all correct, so I'll offer the following adding onto them.
local.xml layout file is only appropriate for the end-implementer, of course - makers of distributed modules should ensure that their modules configure & use a new layout update file. This may or may not be assumed in the original question, but it bears mentioning.
Also, in the case of a multisite installation, if several site themes share a common set of layout updates, but one or more site requires further updates, then it is ideal to create a custom module which configures a layout file to collect the common local layout changes. This allows for theme-specific local.xml files which do not contain duplicated layout updates.
The local.xml file of your theme's layout is always loaded last. Therefore, you can override the existing layout node and customize your layout according to your project's requirements.
Also, using local.xml is upgrade-proof in the sense that a single layout xml contains only necessary xml layout updates.
It may take you some time to adjust the design via local.xml because you can't comment an unnecessary block's nodes; you must remove the block via xml remove nodes. Also, you have to take care while sorting the block positions.
However, once you are done with one theme using local.xml then you can easily reuse the same concept (with some modification) for other themes.
Overall, using local.xml:
Makes your system more upgrade-proof
Saves time for future projects
Fewer number of files = less overhead :)
Hope this makes some sense :)
Cheers!
I am minimizing my javascript files in my magento build to optimize page load time. I already minimized the skin/frontend/THEME/default/js files that were large, and next on my list are the varien javascript files.
My question is: Is it harmful to minimize the varien javascript files since they are technically part of Magento's core? I will obviously save backups of uncompressed files.
Thanks!
Minimizing the CSS and JS should have no side effects, that being said I have seen it screw up some of my style sheets before. Best approach is to enable each one by one in an testing environment and make sure everything looks and functions properly and look for any JS errors. Fooman speedster does the same thing that is built-in now with Magento.
If you encounter any issues disable the merging, your original files (JS/CSS) will be retained and are not modified, they are simply processed and combined into a new single file, so to answer your question it will not harm any core files by enabling such feature.
When creating a module to extend magento its great to be able to package everything up in a self contained, well, module, and simple add it to a site by dragging it in to the root directory.
I have one problem though, what happens when you create a module and need to add something to output in an existing template file say catalog/product/view.phtml for example.
This is fine when you are in full control of the code and have easy access to it, you simply use a layout update in your modules config file, add the necessary code the your modules layout file and then call getChildHtml in the desired template.
But, I am creating a module that collegues will be using, now and in the future and it would be good to have a way where they dont have that final step of having to manually edit the template file.
How do you get around this instead of completely replacing the template file as part of your module?
David,
Though I haven't tried it yet myself, Inchoo is a fantastic resource, and they posted this article earlier this year and it looks quite intriguing and could potentially do what you want to do without needing any template files: http://inchoo.net/ecommerce/magento/how-you-could-build-your-magento-extensions-without-view-files/
Otherwise, there's no really nice way to do it (that I know about at least). You need to do as you said and create your own layout xml file, and override the template with your own.