473,387 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Dynamically assigning a CSS file to a TPL file

I have a situation where I am trying to abstract away not only the
organization of the presentation (via TPL files) but also some of the
finer formatting features (via CSS).

So, for a particular request, I want to be able to select a specific
TPL file to render (easy enough), but I also want to indicate a
specific CSS file to use with the selected TPL.

Can this assignment be done dynamically, i.e. at runtime? I am hoping
I can pass the name of the CSS file to the TPL file, as any other
dynamically assigned tag, but I am unsure whether the TPL file would be
compiled before or after the CSS file would be assigned.

Nov 1 '06 #1
4 2302
Hi,

You can do this probably with include:

$smarty->assign('css', 'my.css');

{include file="$css"}

Cookie Jar wrote:
I have a situation where I am trying to abstract away not only the
organization of the presentation (via TPL files) but also some of the
finer formatting features (via CSS).

So, for a particular request, I want to be able to select a specific
TPL file to render (easy enough), but I also want to indicate a
specific CSS file to use with the selected TPL.

Can this assignment be done dynamically, i.e. at runtime? I am hoping
I can pass the name of the CSS file to the TPL file, as any other
dynamically assigned tag, but I am unsure whether the TPL file would be
compiled before or after the CSS file would be assigned.
Nov 1 '06 #2
Cookie Jar wrote:
I have a situation where I am trying to abstract away not only the
organization of the presentation (via TPL files) but also some of the
finer formatting features (via CSS).

So, for a particular request, I want to be able to select a specific
TPL file to render (easy enough), but I also want to indicate a
specific CSS file to use with the selected TPL.

Can this assignment be done dynamically, i.e. at runtime? I am hoping
I can pass the name of the CSS file to the TPL file, as any other
dynamically assigned tag, but I am unsure whether the TPL file would be
compiled before or after the CSS file would be assigned.

Not that bad. In your header, just add:

<link href="<?php echo $cssfile; ?>" rel="stylesheet" type="text/css">

Where $cssfile is the name of the css filename you wish to use.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 2 '06 #3
Thank you both. I was hoping I could do this, but just needed to be
sure the css file name didn't have to be hard coded.

Thanks! - cj

Jerry Stuckle wrote:
In your header, just add:

<link href="<?php echo $cssfile; ?>" rel="stylesheet" type="text/css">
Nov 2 '06 #4
Cookie Jar wrote:
Thank you both. I was hoping I could do this, but just needed to be
sure the css file name didn't have to be hard coded.

Thanks! - cj

Jerry Stuckle wrote:

>In your header, just add:

<link href="<?php echo $cssfile; ?>" rel="stylesheet" type="text/css">
The browser is who requests the CSS file - the server doesn't even look
at the statement. And by the time it gets to the browser, there is no
way to distinguish statically from dynamically generated HTML. So no
problem.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 4 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Eric | last post by:
How can I dynamically assign an event to an element? I have tried : (myelement is a text input) document.getElementById('myelement').onKeyUp = "myfnc(param1,param2,param3)"; ...
10
by: Randy Webb | last post by:
This page: http://www.hikksworld.com/loadJSFiles/ Is one where I was testing the ability of browsers that can/can't dynamically load a JS file with one of the three methods: 1)Changing the src...
16
by: sirsean | last post by:
Hi all. I'm trying to dynamically build menus and objects after my page loads. Data is stored in an XML file and is parsed at runtime into Javascript objects. At the moment, I'm working on creating...
7
by: cjl | last post by:
Hey all: I've searched the newsgroup, and googled, but I'm stuck. I want to be able to 'dynamically' add a .js file to a web page after the page has loaded, based on user interaction. For...
3
by: yogi | last post by:
Hi guys, I'm trying to write a program that will read in a series of files and create a 3D array from the files read in for converting 2D images to 3D objects. The values read in will be...
11
by: skumar434 | last post by:
Hi everybody, I am faceing problem while assigning the memory dynamically to a array of structures . Suppose I have a structure typedef struct hom_id{ int32_t nod_de; int32_t hom_id;
1
by: vega80 | last post by:
Hi. I have a problem with assigning an onkeypress-function to dynamically created input-boxes.I want to put the content of an input-field into a tag-list when the user hits enter. This works...
7
by: Ron Goral | last post by:
Hello I am new to creating objects in javascript, so please no flames about my coding style. =) I am trying to create an object that will represent a "div" element as a menu. I have written...
5
by: arnabit | last post by:
I have created a dropdown ,which is inside a panel and the panel is inside a place holder . the panel and the dropdown is created dynamically. I do have a button when the button is clicked i am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.