TWDesign Posted March 9, 2012 Share Posted March 9, 2012 Let's say I have this function which I want to output on my product.tpl template <?php $pageURL = $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; echo "<p>The current url is ".$pageURL."</p>"; ?> Obviously I can't use the php tags directly within Smarty. I tried replacing the php tags with {php}....stuff here...{/php} but that didnt work. Everything below those tags didnt render in the browser. Anyway, it seems like some people say we shouldnt really be using {php} even for simple php snippets such as this? I'm a bit confused about the "proper" way to include a php snippet like this into my product.tpl template. Any help please? Link to comment Share on other sites More sharing options...
bellini13 Posted March 9, 2012 Share Posted March 9, 2012 really what you want to do is have that code within the page controller, and then place the $pageURL variable within the smarty engine. so in your template you would only have {$pageURL} Link to comment Share on other sites More sharing options...
TWDesign Posted March 9, 2012 Author Share Posted March 9, 2012 OK. Thanks. But what do you mean by Page Controller? I know there are different Controller files, but how to find the right one? Link to comment Share on other sites More sharing options...
El Patron Posted March 9, 2012 Share Posted March 9, 2012 working with any cms requires a good way to find things. For example I use Dreamweaver, so I can easily find who calls what, where things are defined etc as well as live view which rocks. I am sure that there are other editor packages that do similar things but I 'really' like dreamweaver, I use version cs5. So, which ever you choose, you can just simply find xxx.tpl and it will show you who calls it. Link to comment Share on other sites More sharing options...
bellini13 Posted March 10, 2012 Share Posted March 10, 2012 OK. Thanks. But what do you mean by Page Controller? I know there are different Controller files, but how to find the right one? you stated in your first post that you are trying to edit the product.tpl. you might try to find a product controller. Link to comment Share on other sites More sharing options...
TWDesign Posted March 10, 2012 Author Share Posted March 10, 2012 I appreciate the intent to help. But could you give some actual practical and specific advice on what I need to do here? Link to comment Share on other sites More sharing options...
TWDesign Posted March 12, 2012 Author Share Posted March 12, 2012 Does anyone have any advise on this because I feel if I can understand this part, I can do a whole lot more with PrestaShop. OK, so in the product.tpl file I would simply add this: <p>{$pageURL}</p> And in the ProductController.php file I would need to add the above PHP code. But where? How? Is there some documentation for this? Any help pls? Link to comment Share on other sites More sharing options...
TWDesign Posted March 12, 2012 Author Share Posted March 12, 2012 For example I created a new file ProductController.php and added this to the /overrides folder. The new file contains this code: <?php class ProductController extends ProductControllerCore { public function myHelloWorld() { $this->smarty->assign('Hello World', $myOutPut); } } then added <p>{$myOutPut}</p> into the product.tpl file. The product page still renders fine BUT 'Hello World' isn't showing up on the page. ....and yes I have set the Performance preferences to "force compile" and refreshed my browser cache. Using PrestaShop vers 1.4.0 fyi Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now