Aviationguy Posted November 28, 2015 Share Posted November 28, 2015 I have been reading up on PHP code and wanted to add a hit counter to my page. I found some examples of code so I tried adding it to main.php and nothing happened. I tried others and nothing so I put in this bare bones statement:<?php$counterVal=1501;echo "You are visitor number $counterVal to this site"; ?> Nothing fancy but also nothing on my page. My question is, why can't I add this code and see the result on my page?I appologize if this is not appropriate for this forum. If it is, just delete me. Quote Link to comment Share on other sites More sharing options...
bsmither Posted November 28, 2015 Share Posted November 28, 2015 You have a good understanding of PHP pages. However, CubeCart uses Smarty as a template rendering engine, and the skin templates - although suffixed with .php - never actually gets processed by PHP. Or anything at all, actually, other than Smarty*.Smarty will 'compile' the template and in so doing, will ignore everything that is not tightly enclosed within braces ({ and }). The result is sent directly out. Thus, the web browser, seeing <?php whatever ?> in the HTML code will do nothing with this as this is not a valid HTML markup tag.So, when using Smarty to render templates, one needs to give to Smarty the value of a variable, and code the variable into the template.*One can ask the web server to deliver the template directly (www.mystore.com/skins/foundation/templates/main.php). Since the templates do have the suffix .php, the web server will first send the template file to PHP for processing. In this scenario, the PHP code will be executed. Quote Link to comment Share on other sites More sharing options...
Aviationguy Posted November 29, 2015 Author Share Posted November 29, 2015 Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.