Prestashop 1.7 overriding .tpl files using module - prestashop-1.7

I am trying to create a module in prestashop 1.7.* . I have got into a situation which needs me to edit cart.tpl file located in themes/classic/templates/checkout folder. In documentation I came across /themes/[theme_name]/modules which has the description as "Sub-folder for overriding .tpl files and languages files, if necessary." . Unable to find proper explanation I tried creating "MyModule/themes/classic/templates/checkout/cart.tpl" and unfortunately the changes are not reflected in the site. I have no clue what should be done.
P.S When I tried creating a hook and placing it by altering the themes/classic/templates/checkout/cart.tpl file it was successful. I am planning to place my hook in my module's overriding cart.tpl file.

Related

How is classes.php written when developing a plugin

I'm developing an October CMS plugin, say author.pluginname, on a windows platform.
The file storage/framework/classes.php is meant to be auto-generated with the links of my classes, correct?
I'm not sure if that is always the case and I don't know if I need to or how to force it happen. The two cases were : 1) I just created a new class, 2) I rsynced my plugin to another test (linux server).
For example, I just copied my plugin to a new October CMS installation but and after installing the plugin with plugin:refresh, it doesn't appear in the classes.php file.
I visit a page where a component is being used and I get a class not found error:
"Class 'author\plugin\Models\modelx' not found" on line 653 of /pathtowww/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php
when I grep my author, it finds some classes but not all:
grep -i author storage/framework/classes.php
I had to add it manually to make it work but I assume this is not what we should be doing. So is there something I ought to be writing in the Class file or 'registering' in the Plugin.php folder?
Note this plugin is not in the Marketplace (obviously as it's not developed).
Also, when I create a new class with the Builder plugin, it does appear in the classes.php. When I create it with my text editor, it often does not. Apologies if that is obvious but I'm quite confused....!
I have found the issues' solution(s), in case anyone runs into these problems.
1) If using Windows + another operating system, make sure the folder/file names are in the correct case. Windows is case insensitive so a typo will not result in an error until you migrate to Linux / OSX
2) Classes.php is generated automatically ONLY if the namespace matches the directory structure of your file. So if you move the file (or have the wrong namespace), classes.php will not be generated and you will get a class not found.

How to delete a cached file template in Intellij

I'm trying to work on a Ruby project in Intellij. I tried creating a new file using the Ruby Class Template file type. However, for some reason when I open the file it opens the file with the application that is associated with the .rb extension in my OS config, instead of opening it in Intellij.
EDIT:
Although I still have the issue described below I figured it was worth mentioning that I was able to get Ruby Class Template types working by creating a new empty Ruby project first then importing
my Ruby project as a new module in the Project Settings. See Importing a
module and configuring a separate SDK for it ~
source
END OF EDIT
I figured out that if I just create a file using the basic File type in Intellij and name it with the .rb extension then I can open it in Intellij.
So after I figured this out I tried deleting the original file I created with the Ruby Class Template type. This time I created it as a plain File type and gave it the .rb extension. But, Intellij still doesn't associate this as a Ruby file (it still has a ? mark symbol next to the file). I tried creating multiple variations of *.rb file names and they all work, which confirms the issue is only with this one particular file name.
So I can only think that Intellij has some cached reference of the file name and it's template file type.
I tried searching by %project_name% and deleting any results under
source SYSTEM DRIVE>\Users\<USER ACCOUNT NAME>\.<PRODUCT><VERSION>
But that didn't work. I also renamed the cache folder and restarted Intellij, to no avail.
Aside from a complete reinstall does anyone have any advice on if I'm going in the right direction, and if so, where I might find this hidden cache reference?
For those not able to access the link to the solution posted as a comment by #y.bedrov
The provided solution was to check the following
In Settings(Preferences) | Editor | File Types check all the
registered patterns for Files Opened in Associated Applications:
As I accessed this screen and scrolled to the bottom I found my file. I removed the file from the list and now my issue is solved. I can now create this file and have it open in Intellij!

joomla-extracting a component as installable?

I am writing a joomla componenet but it has many folders and sql tables. I don't prefere to make the package manually. Is there any know extension to make me able to extract my component as a zip file to make it installable.
I'm so confused. Why would you need an extension to compile your component? By the sounds of thing, you have simply started editing a pre-made component.
You should have started with the folder and file stricture when you first started building the component.
Create 2 folders:
admin
site
Put all backend end related folder inside the admin folder, and all frontend related folders inside the site folder.
Then edit your XML file accordingly to it points to the correct folders
There is a third-party component: http://joomlatoys.com/index.php/toys/jtbuilder which can package the selected extensions and generate an installable archive for you.

How to add files to a PrestaShop theme without "hacking" the core

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.

Magento - adding getChildHtml() to existing template as part of module

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.

Resources