Jump to content

question about creating a new module


Recommended Posts

Hi guys. New to php and prestashop. Ok so I've worked through the tutorial on creating a new module. Long story short the controller (display.php) calls a template named display.tpl ( I think that was what it's called ) but I get an error that said something like template not found. Then through some debugging I changed the excepetion message to show the path, and it was looking for the template in the classic theme directory. When I copy the template file to that directory it didplays a whole new page with nothing except the template contents. I thought the template needs to be in /views/templates/front folder (if I remember correctly, I'm not in front of my pc at the moment , sending post from my cellphone) of the module. So my question is should the file be in the classic template folder or in the module views... folder ? The tutorial doesn't specify where exactly. There is something else that didn't work exactly like the tut says, but I'll leave that for now. If you guys need someone to update the docs I can do it if you guys want me to:) Let me know

Link to comment
Share on other sites

Hi ndiaga. Thanks for your reply. I've tried that however it's still not working. 

 

This is my directory tree:

 

├── config.xml
├── controllers
│   └── front
│       ├── display.php
│       └── display.tpl
├── css
│   └── mymodule.css
├── display.php
├── display.tpl
├── error
├── mymodule.php
├── override
│   └── display.tpl
└── views
    └── templates
        ├── front
        │   └── display.tpl
        └── hook
            ├── display.tpl
            └── mymodule.tpl
 
I've placed display.tpl in many places. I've modified TemplateFinder a bit to show me the directory it's looking for: 
 
throw new PrestaShopException('No template found for '.$template . " Directory: [" .  $this->directories[0] . "]");
 
Actual Error when clicking on "Click Here":
[PrestaShopException]

No template found for display.tpl Directory: [/home/user/Documents/prestashop/project/themes/classic/templates/]
at line 71 in file classes/Smarty/TemplateFinder.php

66. return $tpl;
67. }
68. }
69. }
70.
71. throw new PrestaShopException('No template found for '.$template . " Directory: [" . $this->directories[0] . "]");
72. }
73.
74. private function getTemplateHierarchy($template, $entity, $id)
75. {
76. $entity = basename($entity);

Any idea what the problem could be?

Link to comment
Share on other sites

I've installed Prestashop 1.6 and copied the module folder to version 1.6 and it works in version 1.6. Now when I click on "Click me" it shows the contents of the template: "Welcome to my shop!". So I think it could be that the docs is not updated. How do I fix it though ? What has changed in version 1.7?

Edited by me_von_south (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...