I have put this code in header.tpl but the div is appearing on all pages
{if cart.php}
<div> This is Cart.PHP </div>
{/if}
I want this div to be appear in the header of cart.php page only.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your comparison as @JaredFarrish says, will always return true since you are asking if the filename (in this case cart.php is true) and not if it’s the current filename as you think you are.
This, however, may not work for includes (like your case) and you may want to use something like this:
Note that if your file is in a subdirectory you’d need to compare it to the full path or extract the filename from the string since
$smarty.server.PHP_SELFreturns the path too.To do this you can use
basenamefunction directly to your variable, so doingbasename($smarty.server.PHP_SELF) eq "cart.php"should be enough.