Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSS & CFML - How do I get there? 1

Status
Not open for further replies.

josel

Programmer
Oct 16, 2001
716
0
0
US
Hello friends, I am working on a simple CF App (my first one). I am looking into writing code in a way such that would allow browsers to set their own themes (picked from a list of preset ...) and based on what I've found so far, this is best done using CSS and cookies; I would gladly stand corrected as I am just repeating my interpretation of some material I've read.

Now, I do not want to re-ivent the wheel. I am hoping some one can point me to a set of CSS (open source would be nice) and/or sample CF code where this is employed. I have ONLY written a handful of templates and I am trying to replicate YAHOO! :)

If you have the knowledge, consult and educate those who need it! - Jose Lerebours
 
You mean have the people choose how what they want their colors to be and such?
 
Yes!

Of course, each theme will consist of a combination of colors and fonts. I am thinking of even disabling images (show plain text only).

I will run but for now, I would be glad if I could walk.

thanks;

josel If you have the knowledge, consult and educate those who need it! - Jose Lerebours
 
This sounds easy enough. You have the right idea I think. Here is a way you could implement it. Build a database table that has 3 fields. First an ID field (unique), second a short description of the style, and the third containing the actuall code for the style. For example:
Col 1: 123
Col 2: Does nothing
Col 3: <style type=&quot;text/css&quot;> Body {color: blue;} </style>

Use the second col to populate a box of the styles the people can select from. When they choose one set a cookie on their machine with the value from col 1 of the row that the col 2 was from. Then when you load a page on your site, read the number from the cookie. Then run code like this (assuming datasource is styles and col3 is named style.
Code:
<cfquery name=&quot;asdf&quot; datasource=&quot;styles&quot;>
 select style
 from style_table
 where ID = value_from_cookie
</cfquery>
<cfoutput query=&quot;asdf&quot;>
 #style#
</cfouptut>
Does this help?
-Leslie
 
Leslie,

You hit the nail in the head - and yet - opened a whole new concept. Figure this:

a) Have a table with name & description of all preset style templates

b) Have field in myProfile (user's table) identifying user's style of choice (aka: theme)

c) Use code (see above) to present user with list of preset templates to choose from.

d) Set cookie as selection is made

e) Have code to check on cookie_value and retrieve chosen style from table thus identifying the template to be included using <cfinclude> and while at it, load some other user's information such as name ...

what do you think? Are we on the same page?

Thank you very much!!!

josel
If you have the knowledge, consult and educate those who need it! - Jose Lerebours
 
Well, I would simply load into each page an external stylesheet containing all of the class definitions. Although, to make it possible for the developer to modify the styles using a browser, you could generate the stylesheet on the fly based on data retrieved from the database.

Otherwise, I like the idea of using cookies to store the user's elections. If your users are required to login, then you migh consider storing the user's elections in the database. That way they will get their theme regardless of which computer their browser running is on, and for that matter, regardless of which browser they use.
 
If I were to place the entire <style></style> block in a field, what kind of field should this be in the table? Keep in mind that any given style selectors.class list may get lenghly.

Of course, the key for this to work is that all style selectors.class in every template should use same class/IDs for all definitions; as these would be spread throughout the CFML code.

Is this overkill?

josel If you have the knowledge, consult and educate those who need it! - Jose Lerebours
 
I would put the style definitions in a memo field. Those should be long enough for what you need. What you had as an additional idea after my last post sounds good. I hadn't actually thought about this before I saw your post. But now that i look at it, it seems to be a useful thing to do. Good luck with it.
Leslie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top