Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP Smartys and CSS Include File Issues

How do I tell smartys to ignore the {} in my css include file?



2:36 pm on Sep 22, 2008 (gmt 0)

5+ Year Member


I am working with VTigerCRM. It uses smartys to work with its files. I am modifying the header.tpl file.

I have multiple files to include in order to place my custom header and footer around the VTigerCRM application so it seemlessly integrates within my website.

For those answering that do not work with smartys please understand that the include("/css.php"); function does not work with smartys. It outputs it as regular text.

I am using the {include file='../../../css.php'} for one of my includes. The problem comes in when smartys sees the following code. As soon as it sees the {}, it crashes:

<style type="text/css" media="all">
/* media="all" hides styles from NS4.x only
- so we'll put styles we want to hide from NS4.x here */
div.Article { background: url(/images/custom_corners_topleft.gif) top left no-repeat;}
div.Article h3 {
background: url(/images/custom_corners_topright.gif) top right no-repeat;
div.ArticleBody {
background: url(/images/custom_corners_rightborder.gif) top right repeat-y;
div.ArticleFooter {
background: url(/images/custom_corners_bottomleft.gif) bottom left no-repeat;
div.ArticleFooter p {
background: url(/images/custom_corners_bottomright.gif) bottom right no-repeat;

Please keep in mind that multiple applications utilize this CSS file. Without modifying the actual CSS file with anything that will prevent the other applications from working properly, is there a way to get smartys to ignore the {} it is finding?




6:11 pm on Sep 22, 2008 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member

You'd have to put {literal} blocks in the css file to do it that way. How about figuring out whether you want to include it in php, then
{if $netscape}
<link rel="stylesheet" href="../../../css.php" type="text/css">


2:16 am on Sep 23, 2008 (gmt 0)

5+ Year Member

Will the smartys blocks interrupt any of the other applications that I am working on or will it be seemless?




6:41 am on Sep 23, 2008 (gmt 0)

5+ Year Member


I have tested this with the {literal}{/literal} there and it works however it puts that directly on the pages that are not smarty which is what I was afraid of.

Here is my dilemma.
Obviously I cannot have those on my pages.
The script that is calling the js.php file is in the root/vtigercrm/smarty/templates directory while the js file is in the root directory.

I wrote a php script to detect the phrase vtigercrm from the directory and if it did to display the {literal}. This did not work because the js file is in the root directory. I cannot include the javascript code that is in the js file in a .js file because then it doesn't function (I have no clue why that would be). So if I cannot detect that the vtigercrm directory is calling the script how do I enter the {literal} in there only if it is vtigercrm calling the script without creating a completely different file specifically for vtigercrm?

Unless I separate out the code and create a different include file for js and just include that in every page that already has all of the includes. This way I can use the literal statements around the include for the vtigercrm.

Is there a better idea?


6:58 am on Sep 23, 2008 (gmt 0)

5+ Year Member

{literal}css content{/literal}

you can do it too!


3:31 pm on Sep 23, 2008 (gmt 0)

5+ Year Member

Thanks chinawolfs. I already have the CSS issue resolved. I took my extra CSS content that I had in css.php and put it in a different .css file and included it with media="all".

However, my next bit is my JavaScript that I am working on. Here is what I have inside of the file.

Please keep in mind the following points. I have massive amounts of applications utilizing these same include files that do not use smartys. VTigerCRM uses smartys. If I put the {literal}{/literal} diretly into the JS file then it shows up on webpages for the rest of the website that does not use smartys.

Smartys does not mind the .js files. However I cannot put the open <script></script> into another .js file. I have already attempted this and it breaks the functionality of the code. I don't know what the difference is. I even tried taking the js script code, placing it into a different js2.php file and then in every file just use another include('js2.php'); The theory was that was I could use the {literal}{include file='../../../js2.php'}{/literal} within theactual smarty code. Unless I was too tired and I screwed it up somehow. This did not work. It broke the functionality of the code.

I also have other include files as well however I believe that I can utilize the {literal}{include file='../../../innercode.php'}{/literal} for those. However I cannot get to that point until I resolve the javascript js.php file issue.

<script type='text/javascript' src='/js/quickmenu.js'></script>
<script type='text/javascript' src='/js/imageres.js'></script>
<script type='text/javascript' src='/js/popups.js'></script>
<script type="text/javascript">
/* <![CDATA[ */
function makepage(src)
// We break the closing script tag in half to prevent
// the HTML parser from seeing it as a part of
// the *main* page.

return "<html>\n" +
"<head>\n" +
"<title>Temporary Printing Window</title>\n" +
"<script>\n" +
"function step1() {\n" +
" setTimeout('step2()', 10);\n" +
"}\n" +
"function step2() {\n" +
" window.print();\n" +
" window.close();\n" +
"}\n" +
"</scr" + "ipt>\n" +
"</head>\n" +
"<body onLoad='step1()'>\n" +
"<img src='" + src + "'/>\n" +
"</body>\n" +

function printme(evt)
if (!evt) {
// Old IE
evt = window.event;
var image = evt.target;
if (!image) {
// Old IE
image = window.event.srcElement;
src = image.src;
link = "about:blank";
var pw = window.open(link, "_new");

/* ]]> */
<script language="javascript" type="text/javascript">
function resize() {
// Variables to be sent to PHP. The PHP variables to be sent are in "" (ie width=, imgpath=)
var width = "width=" + screen.width; // Set variable width to users screen width
var path = "imgpath=images/&"; // Set the path to the image
var logo = "imgname=scrfix-logo.png&"; //Name of my image
var shopping = "imgname=shopping-cart.jpg&"; //Name of my image
var forums = "imgname=forums.jpg&"; //Name of my image
var signin = "imgname=sign-in.jpg&"; //Name of my image
var contact = "imgname=contactus.jpg&"; //Name of my image
var printer = "imgname=printer.jpg&"; //Name of my image
// End of Variables to be sent to PHP. The below variables are only for this script.
var script = "/shrink.php?"; // The name of the php script
var scrpth = script + path; //Combine both the script and the path to make it less to work with below.

document.write('<a href="/"><img border="0" class="headerimages" src="' + scrpth + logo + width + '" alt="Spectacular Computer Repair" title="Spectacular Computer Repair" /></a>');
//document.write('<a href="/catalog/"><img border="0" class="headerimages" src="' + scrpth + shopping + width + '" alt="Computer Repair Shopping" title="Computer Repair Shopping" /></a>');
document.write('<a href="/computer-repair-forums/"><img border="0" class="headerimages" src="' + scrpth + forums + width + '" alt="Computer Repair Forums" title="Computer Repair Forums" /></a>');
document.write('<a href="/coordinator.php"><img border="0" class="headerimages" src="' + scrpth + signin + width + '" alt="User Sign In" title="User Sign In" /></a>');
document.write('<a href="/contact.php"><img border="0" class="headerimages" src="' + scrpth + contact + width + '" alt="Contact Spectacular Computer Repair" title="Contact Spectacular Computer Repair" /></a>');
document.write('<a href="#" onclick="window.print();return false;"><img border="0" class="headerimages" src="' + scrpth + printer + width + '" alt="Print This Page" title="Print This Page" /></a>');

return 0;
<script type="text/javascript">
function suppress_errors() {return true;}


4:37 pm on Sep 23, 2008 (gmt 0)

5+ Year Member

I created two separate files. js.php and jsopen.php

<script type='text/javascript' src='/js/quickmenu.js'></script>
<script type='text/javascript' src='/js/imageres.js'></script>
<script type='text/javascript' src='/js/popups.js'></script>

The rest of the open JavaScript code above.

Any ideas on including jsopen.php within smartys without messing up the other webpages (see below):

Okay, I attempted my idea of {literal}{include file='../../../jsopen.php'}{/literal} and it did not work. It works for all other pages but does not work for VTigerCRM. It merely put {literal}{include file='../../../jsopen.php'}{/literal} directly on the VTigerCRM webpage. Back to the drawing board.

This puts a damper on items because I have two other files to include as well; innercode.php, navbar.php, breadcrumbs.php as well as this jsopen.php.

Inside the jsopen.php I can put {literal}{/literal} around the javascript but that does not work for the non smarty webpages. It actually displays the {literal}{/literal} directly on all of those webpage. I am trying to get this to work with all applications.

I think the rest of the files should be just fine because most of it is either html or php which works with no problems.

I have to resolve this jsopen.php issue. As soon as smartys sees the { in the javascript code it freaks out and breaks.

The only other one that I have concern on is the navbar.php file. It has a couple of {} in it but they are encased within php code so it should be fine in theory.



Featured Threads

Hot Threads This Week

Hot Threads This Month