{"action":"created","issue":{"url":"https://api.github.com/repos/PrestaShop/PrestaShop/issues/4874","repository_url":"https://api.github.com/repos/PrestaShop/PrestaShop","labels_url":"https://api.github.com/repos/PrestaShop/PrestaShop/issues/4874/labels{/name}","comments_url":"https://api.github.com/repos/PrestaShop/PrestaShop/issues/4874/comments","events_url":"https://api.github.com/repos/PrestaShop/PrestaShop/issues/4874/events","html_url":"https://github.com/PrestaShop/PrestaShop/pull/4874","id":131286726,"number":4874,"title":"Starter theme/fix/template override","user":{"login":"julienbourdeau","id":1525636,"avatar_url":"https://avatars.githubusercontent.com/u/1525636?v=3","gravatar_id":"","url":"https://api.github.com/users/julienbourdeau","html_url":"https://github.com/julienbourdeau","followers_url":"https://api.github.com/users/julienbourdeau/followers","following_url":"https://api.github.com/users/julienbourdeau/following{/other_user}","gists_url":"https://api.github.com/users/julienbourdeau/gists{/gist_id}","starred_url":"https://api.github.com/users/julienbourdeau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/julienbourdeau/subscriptions","organizations_url":"https://api.github.com/users/julienbourdeau/orgs","repos_url":"https://api.github.com/users/julienbourdeau/repos","events_url":"https://api.github.com/users/julienbourdeau/events{/privacy}","received_events_url":"https://api.github.com/users/julienbourdeau/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-02-04T09:17:17Z","updated_at":"2016-02-04T10:48:16Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/PrestaShop/PrestaShop/pulls/4874","html_url":"https://github.com/PrestaShop/PrestaShop/pull/4874","diff_url":"https://github.com/PrestaShop/PrestaShop/pull/4874.diff","patch_url":"https://github.com/PrestaShop/PrestaShop/pull/4874.patch"},"body":"## Custom templates\r\n\r\nWe distinguished layout and template:\r\n\r\n* **Layout**: The way the page is arranged (full width, 2 columns, content only, etc)\r\n* **Template**: The actual smarty file loaded: `cms/page.tpl`, `catalog/product.tpl`\r\n\r\nThis seems pretty obvious but the code wasn't exactly working this way.\r\nPrestaShop used to call it _theme overrides_ now there is no `override/` folder anymore, only specific template.\r\n\r\nFrontControllers usually assign template this way:\r\n\r\n```php\r\n$this->setTemplate('catalog/product.tpl');\r\n```\r\nand we load the file found at this exact location in the theme.\r\n\r\nNow `setTemplate()` we look for more specific templates before. As of today (for the `catalog/product.tpl` example):\r\n\r\n1. catalog/product-{id_product}.tpl\r\n1. catalog/product.tpl\r\n\r\n**Do you have any idea for extra rules ?**\r\n\r\n**Note:** _product-{id_product}.tpl_ can extend _product.tpl_ and simply override one smart block.\r\n\r\n## Module Smarty Resource for templates\r\n\r\nThis is some sort of namespace for module template. Instead of loading\r\na file from the given path, Smarty will look for a corresponding template\r\nin multiple locations (following priority order). Thanks to [Smarty Custom Resources](http://www.smarty.net/docs/en/resources.custom.tpl).\r\n\r\nPrestaShop already allow theme to override module templates but if they\r\nwere using `include` statement, you had to override theme all.\r\n\r\nNow module can allow theme to override only one template by using the following\r\nsyntax.\r\n\r\n```smarty\r\n{include file=\"module:module_directory_name/path/to/template/file.tpl\"}\r\n```\r\n\r\n### Example with blockcart module\r\n\r\nIf we want to allow theme to override only the product line template\r\nbut not the main one (and vice versa), you simply need to replace:\r\n\r\n```smarty\r\n<li>{include './blockcart-product-line.tpl' product=$product}</li>\r\n```\r\n\r\nby\r\n\r\n```smarty\r\n<li>{include file=\"module:blockcart/blockcart-product-line.tpl\" product=$product}</li>\r\n```"},"comment":{"url":"https://api.github.com/repos/PrestaShop/PrestaShop/issues/comments/179767293","html_url":"https://github.com/PrestaShop/PrestaShop/pull/4874#issuecomment-179767293","issue_url":"https://api.github.com/repos/PrestaShop/PrestaShop/issues/4874","id":179767293,"user":{"login":"kpodemski","id":2137763,"avatar_url":"https://avatars.githubusercontent.com/u/2137763?v=3","gravatar_id":"","url":"https://api.github.com/users/kpodemski","html_url":"https://github.com/kpodemski","followers_url":"https://api.github.com/users/kpodemski/followers","following_url":"https://api.github.com/users/kpodemski/following{/other_user}","gists_url":"https://api.github.com/users/kpodemski/gists{/gist_id}","starred_url":"https://api.github.com/users/kpodemski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kpodemski/subscriptions","organizations_url":"https://api.github.com/users/kpodemski/orgs","repos_url":"https://api.github.com/users/kpodemski/repos","events_url":"https://api.github.com/users/kpodemski/events{/privacy}","received_events_url":"https://api.github.com/users/kpodemski/received_events","type":"User","site_admin":false},"created_at":"2016-02-04T10:48:16Z","updated_at":"2016-02-04T10:48:16Z","body":":+1: "}}