CSS editing by user

Started on the old forum in January 2012 · view the original in the archive · old links redirect here

9 replies · 776 views · started 14 years ago · 1 min read

3 participants
arnage Lead · 811 posts #1

Does anyone have in use this in sql based? It would be nice to hear experiences, advice, at what to pay attention...

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
just_m3. Developer · 199 posts #2

Depends on how the user is able to edit the css , as a text ? in a text area form ? or just by div ids as body{} and others via submit form with drop down options menu ...

i used to let my users customize their page look by a submit form with a drop down menu with options... for example

customize css on body{}

background:

<option value="#000">black</option> <option value="#19A6FF">blue</option> <option value="#FFFFFF">white</option>

got it ? 😀 // just an idea 😛

Added after 4 minutes:

as by payn' attention to something that would be the options you should enable for changing by your user (div's ,global's as body,img,a link,etc,) and an option to set it back to default .. / resset

Added after 10 minutes:

and something else to add

you could output for use to a php file with header

header('Content-type: text/css'); by simply echoing it from database / per user select and then use it to your header

echo'<link rel="stylesheet" href="http://'.$_SERVER['HTTP_HOST'].'/style.css" type="text/css"/>';

on .htaccess

RewriteEngine On RewriteRule ^style.css$ /style.php [L]

This is ten percent luck, twenty percent skill Fifteen percent concentrated power of will Five percent pleasure, fifty percent pain 😂And a hundred percent reason to remember the name!

arnage Lead · 811 posts #3

just_m3. wrote: Depends on how the user is able to edit the css , as a text ? in a text area form ? or just by div ids as body{} and others via submit form with drop down options menu ...

i used to let my users customize their page look by a submit form with a drop down menu with options... for example

customize css on body{}

background:

<option value="#000">black</option> <option value="#19A6FF">blue</option> <option value="#FFFFFF">white</option>

got it ? 😀 // just an idea 😛

Added after 4 minutes:

as by payn' attention to something that would be the options you should enable for changing by your user (div's ,global's as body,img,a link,etc,) and an option to set it back to default .. / resset

Lets say fully, via textarea.

I have investegate this and thats why i need someone who have this in use by any way, anything. 🙂

If i should go by predefined CSS attributes than i'll make an array do loop foreach ($color_array as $col => $color) ... , you don't want that i post color_array. 🤣 No way that im gonna scroll 2.000 lines just because color select option, i have them 115 in that array. And than text size, font, borders, border style, weight, ......... Thats too much, can do, but its too nasty. 🙂

Added after 2 minutes:

just_m3. wrote: Added after 10 minutes:

and something else to add

you could output for use to a php file with header

header('Content-type: text/css'); by simply echoing it from database / per user select and then use it to your header

echo'<link rel="stylesheet" href="http://'.$_SERVER['HTTP_HOST'].'/style.css" type="text/css"/>';

on .htaccess

RewriteEngine On RewriteRule ^style.css$ /style.php [L]

Not that bro. 🙂

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
GumSlone Administrator Principal · 1,690 posts #4

arnage wrote: Does anyone have in use this in sql based? It would be nice to hear experiences, advice, at what to pay attention...

you want your users to edit the css in a textarea and save the edited css in sql for every user? if so, i'm using something similar at one of my sites, so that users can customize their profiles.

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

arnage Lead · 811 posts #5

GumSlone wrote: you want your users to edit the css in a textarea and save the edited css in sql for every user? if so, i'm using something similar at one of my sites, so that users can customize their profiles.

Exactly. Just for guest books but its the same. How did you solve it? 🙂

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
GumSlone Administrator Principal · 1,690 posts #6

arnage wrote: Exactly. Just for guest books but its the same. How did you solve it? :)

i made a form where they could change colors for links, text, background etc, and then just placed the values into a css code and saved the code in the database.

you can make it via textarea but its bad idea because not many users know much about css.

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

just_m3. Developer · 199 posts #7

GumSlone wrote: i made a form where they could change colors for links, text, background etc, and then just placed the values into a css code and saved the code in the database.

you can make it via textarea but its bad idea because not many users know much about css.

the very same way as i used and gived demo in the first post .. 😛

This is ten percent luck, twenty percent skill Fifteen percent concentrated power of will Five percent pleasure, fifty percent pain 😂And a hundred percent reason to remember the name!

arnage Lead · 811 posts #8

Thats how i started, with predefined values via form and got to a very nasty, big code, and its just gonna be bigger. 🙂 Was thinking about textarea but i couldn't solve chars... Good point for users, maybe is best to continue this way.

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
just_m3. Developer · 199 posts #9

"is best to continue this way". 😉

This is ten percent luck, twenty percent skill Fifteen percent concentrated power of will Five percent pleasure, fifty percent pain 😂And a hundred percent reason to remember the name!

arnage Lead · 811 posts #10

just_m3. wrote: "is best to continue this way". ;)

just_m3. wrote: the very same way as i used and gived demo in the first post .. :p

Slightly elegant way. 🙂

$color_array = array(
'Aqua[00FFFF]' => '00FFFF', 'Black[000000]' => '000000', 'Blue[0000FF]' => '0000FF', 'Fuchsia[FF00FF]' => 'FF00FF', 'Gray[808080]' => '808080',
'Green[008000]' => '008000', 'Lime[00FF00]' => '00FF00', 'Maroon[800000]' => '800000', 'Navy[000080]' => '000080', 'Olive[808000]' => '808000',
'Purple[800080]' => '800080', 'Red[FF0000]' => 'FF0000', 'Silver[C0C0C0]' => 'C0C0C0', 'Teal[008080]' => '008080', 'White[FFFFFF]' => 'FFFFFF',
'Yellow[FFFF00]' => 'FFFF00', 'Aquamarine[7FFFD4]' => '7FFFD4', 'Blueviolet[8A2BE2]' => '8A2BE2', 'Brown[A52A2A]' => 'A52A2A', 'Burlywood[DEB887]' => 'DEB887',
'Cadetblue[5F9EA0]' => '5F9EA0', 'Chocolate[02691E]' => '02691E', 'Coral[FF7F50]' => 'FF7F50', 'Cornflowerblue[6495ED]' => '6495ED', 'Crimson[DC143C]' => 'DC143C',
'Darkcyan[008686]' => '008686', 'Darkgoldenrod[688606]' => '688606', 'Darkgray[A9A9A9]' => 'A9A9A9', 'Darkgreen[006400]' => '006400', 'Darkkhaki[606766]' => '606766',
'Darkmagenta[860086]' => '860086', 'Darkolivegreen[55662F]' => '55662F', 'Darkorange[FF8C00]' => 'FF8C00', 'Darkorchid[9932CC]' => '9932CC', 'Darkred[860000]' => '860000',
'Darksalmon[E9967A]' => 'E9967A', 'Darkslateblue[483086]' => '483086', 'Darkslategray[2F4F4F]' => '2F4F4F', 'Darkturquoise[00CED1]' => '00CED1', 'Darkviolet[940003]' => '940003',
'Deeppink[FF1493]' => 'FF1493', 'Deepskyblue[00BFFF]' => '00BFFF', 'Dimgray[696969]' => '696969', 'Dodgerblue[1E90FF]' => '1E90FF', 'Firebrick[622222]' => '622222',
'Floralwhite[FFFAF0]' => 'FFFAF0', 'Forestgreen[228622]' => '228622', 'Gainsboro[DCDCDC]' => 'DCDCDC', 'Gold[FFD700]' => 'FFD700', 'Goldenrod[DAA520]' => 'DAA520',
'Greenyellow[ADFF2F]' => 'ADFF2F', 'Hotpink[FF69B4]' => 'FF69B4', 'Indianred[CD5C5C]' => 'CD5C5C', 'Indigo[460082]' => '460082', 'Khaki[F0E68C]' => 'F0E68C',
'Lavender[E6E6FA]' => 'E6E6FA', 'Lavenderblush[FFF0F5]' => 'FFF0F5', 'Lawngreen[7CFC00]' => '7CFC00', 'Lightblue[ADD8E6]' => 'ADD8E6', 'Lightcoral[F08080]' => 'F08080',
'Lightcyan[E0FFFF]' => 'E0FFFF', 'Lightgreen[90EE90]' => '90EE90', 'Lightgrey[D3D3D3]' => 'D3D3D3', 'Lightpink[FFB6C1]' => 'FFB6C1', 'Lightsalmon[FFA07A]' => 'FFA07A',
'Lightseagreen[20B2AA]' => '20B2AA', 'Lightskyblue[87CEFA]' => '87CEFA', 'Lightslategray[778899]' => '778899', 'Lightsteelblue[B0C4DE]' => 'B0C4DE', 'Limegreen[32CD32]' => '32CD32',
'Linen[FAF0E6]' => 'FAF0E6', 'Mediumorchid[BA55D3]' => 'BA55D3', 'Mediumpurple[9370DB]' => '9370DB', 'Mediumseagreen[3CB371]' => '3CB371', 'Mediumslateblue[7B68EE]' => '7B68EE',
'Mediumturquoise[4801CC]' => '4801CC', 'Mediumvioletred[071585]' => '071585', 'Midnightblue[191970]' => '191970', 'Mintcream[F5FFFA]' => 'F5FFFA', 'Mistyrose[FFE4E1]' => 'FFE4E1',
'Moccasin[FFE4B5]' => 'FFE4B5', 'Navajowhite[FFDEAD]' => 'FFDEAD', 'Old lace[FDF5E6]' => 'FDF5E6', 'Olivedrab[6B8E23]' => '6B8E23', 'Orange[FFA500]' => 'FFA500',
'Orangered[FF4500]' => 'FF4500', 'Orchid[DA70D6]' => 'DA70D6', 'Palegoldenrod[EEE8AA]' => 'EEE8AA', 'Palegreen[98F698]' => '98F698', 'Paleturquoise[AFEEEE]' => 'AFEEEE',
'Palevioletred[DB7093]' => 'DB7093', 'Peachpuff[FFDAB9]' => 'FFDAB9', 'Peru[CD853F]' => 'CD853F', 'Pink[FFCOC8]' => 'FFCOC8', 'Plum[DDA0DD]' => 'DDA0DD',
'Powderblue[B0E0E6]' => 'B0E0E6', 'Rosybrown[BC8F8F]' => 'BC8F8F', 'Royalblue[4169E1]' => '4169E1', 'Saddlebrown[864513]' => '864513', 'Salmon[FA8072]' => 'FA8072',
'Sandybrown[F4A460]' => 'F4A460', 'Seagreen[2E8B57]' => '2E8B57', 'Sienna[A0522D]' => 'A0522D', 'Skyblue[87CEEB]' => '87CEEB', 'Slateblue[6A5ACD]' => '6A5ACD',
'Slategray[708090]' => '708090', 'Springgreen[00FF7F]' => '00FF7F', 'Steelblue[468264]' => '468264', 'Tan[D2B48C]' => 'D2B48C', 'Thistle[D8BFD8]' => 'D8BFD8',
'Tomato[FF6347]' => 'FF6347', 'Turquoise[40E0D0]' => '40E0D0', 'Violet[EE82EE]' => 'EE82EE', 'Wheat[F5DEB3]' => 'F5DEB3', 'Yellowgreen[9ACD32]' => '9ACD32'
);

And than:

	echo 'Body Text Color:<br/>'."\n";
	echo '<select name="body_text_color" title="Select Body Text Color">'."\n";
		echo '<option value="">None</option>'."\n";
		foreach ($color_array as $col => $color) {
			echo '<option value="'.$color.'"'.($usersset['bodycolor'] == $color ? ' selected="selected">' : '>').$col.'</option>'."\n";
		}
	echo '</select>'."\n";

And retrieve from form:

	$body_color = !empty($_POST['body_text_color']) 
		? (in_array($_POST['body_text_color'], $color_array) ? $_POST['body_text_color'] : '') 
		: $usersset['bodycolor'];

And retrieve from SQL....

Than for borders array:

$border_array = array('none', 'solid', 'dashed', 'dotted', 'double', 'groove', 'ridge');

Than again loop:

	echo 'Title Border Style:<br/>'."\n";
	echo '<select name="set_title_border" title="Select Title Border Style">'."\n";
		foreach ($border_array as $border) {
			echo '<option value="'.$border.'"'.($usersset['title_border'] == $border ? ' selected="selected">' : '>').capsfirst($border).'</option>'."\n";
		}
	echo '</select>'."\n";

Than again retrieve from form and than retrieve from SQL:

echo ' // bla bla
'.($body_border_style == 'none' ? '' : 'border: '.$body_border_size.'px '.$body_border_style.' #'.$body_border_color.';').'
// bla bla';

And this way for each and every attribute in each and every div or span.... Manageable but too nasty. 🙂

Im gonna cut out some div's and take out span's, definetly.

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close