473,769 Members | 6,337 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2318
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*******@attgl obal.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*******@attgl obal.net
=============== ===
Nov 4 '06 #5

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

Similar topics

4
12581
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)"; document.getElementById('myelement') = new Function("myfnc(param1,param2,param3)");
10
2199
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 property of a script tag. 2)Inserting a script src="" tag in a div via innerHTML 3)Using document.createElement to add a script element. The fourth method on the page is writing a script tag to a layer, and to the best of my knowledge it only...
16
1827
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 menu items from these objects. The parsing works fine (using Sarissa), and Firefox builds the menu no problem. IE, however, does not. The functionality of the menu will be a single onclick event. It seems that Firefox allows me to set the...
7
5066
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 example, the user make a choice by clicking on an item called 20050928, and as a result a file named "20050928/case.js" is "included", and the data contained within is available.
3
1848
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 considered as pixel colours and the size that 1 pixel occupies will depend on an input from the user when running the program. How can I dynamically change the data type of my 3D array at runtime. eg. 3D array was defined as type unsigned char in the code...
11
3785
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
7495
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 fine the first time (when the input-field is created in a non-dynamical way). The next input-field is created dynamically by a function that is called when the user hits enter (the previously generated input-field will be hidden). Then I'm trying...
7
2531
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 several methods that are working fine. The problem is if I want to dynamically assign an event handler to the object, the event handler is not called. What am I doing wrong? Below is a sample HTML doc with everything in place. <!DOCTYPE HTML PUBLIC...
5
1500
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 trying to read the values from the dropdown.but the problem i am facing is that i am not getting the id of the dropdown .Please advice me how to get the id of the dropdown .
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10222
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9999
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8876
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3967
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3570
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.