paddyhaig Posted July 10, 2010 Share Posted July 10, 2010 I have embedded a couple of variables in an external css. One of them works the others do not. The mapping to the background_image works fine, however the #color definitions do not. Any thoughts greatly appreciated. Here is a clip from the external css. At the top of the css I have a php include that has the color rules. body { background-repeat: no-repeat; background-color: <?php echo $body_background_color ?>; } #backdrop { position:absolute; width:970px; height:985px; z-index:0; left:50%; top: -1px; margin-left:-485px; background-image: url(../../graphics/<?php echo $_background_image ?>); } Quote Link to comment Share on other sites More sharing options...
paddyhaig Posted July 10, 2010 Author Share Posted July 10, 2010 Actually the mapping to the background_image works does not work, seems I had 2 background image mappings. What I am trying to do is create a way that the user can make certain customization to the css unique to their specific account. When they log into their account they can apply unique rules. Although the majority of the rules are static. Quote Link to comment Share on other sites More sharing options...
trq Posted July 10, 2010 Share Posted July 10, 2010 The files would either need to be saved with a php extension or you will need to configure your server to parse files with the css extension as php. Quote Link to comment Share on other sites More sharing options...
paddyhaig Posted July 10, 2010 Author Share Posted July 10, 2010 I tried to save them with the .php extension as opposed to the css ~ with not a lot of luck. I will try again, maybe I screwed something up. There's nothing I can do with the server unless it's a matter of introducing a .htaccess file. The site is with a paid hosting service. Thanks however for your input. Quote Link to comment Share on other sites More sharing options...
paddyhaig Posted July 10, 2010 Author Share Posted July 10, 2010 Does anyone know what method is used on other large php css projects for introducing specific account customizations. I am sure cookies are involved. For example, you log into your web based email and you can change the layout to your own specific likes. I have also introduced other languages, although I am not sure if I am using a standard method? Quote Link to comment Share on other sites More sharing options...
trq Posted July 11, 2010 Share Posted July 11, 2010 Usually those settings are stored within a database, then applied as a user logs in. Quote Link to comment Share on other sites More sharing options...
paddyhaig Posted July 11, 2010 Author Share Posted July 11, 2010 Hmmmm, I am using mySQL on the backend! I wonder what the syntax is.You wouldnt happen to know where I might find an example of how this is done. I am not even sure how I would term it in google? Quote Link to comment Share on other sites More sharing options...
trq Posted July 11, 2010 Share Posted July 11, 2010 Lots of ways it could be done, probably the simplest though is too simply store key => value pairs against a users id. So... you'd need a table. CREATE TABLE custom_settings ( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), user_id INT, k VARCHAR(80), v VARCHAR(80) ); Then, for say user 'thorpe' whos id is 19232, we store some settings. INSERT INTO custom_settings (k, v) VALUES ('text-color', '#fff'); INSERT INTO custom_settings (k, v) VALUES ('background-color', '#666'); INSERT INTO custom_settings (k, v) VALUES ('max-post-per-page', '20'); Then, when a user logs in you grab those settings and store them along with there session. // login code goes here. if ($result = mysql_query("SELECT k, v FROM custom_settings WHERE user_id = 19232")) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_assoc($result)) { list($k, $v) = $row; $_SESSION['custom_settings'][$k] = $v; } } } You can now use.... <?php echo $_SESSION['custom_settings']['background-color']; ?> wherever you need it and it will be custom for the logged in user. Of course the top few queries also need to be executed via php but that should be pretty simple to figure out. Quote Link to comment Share on other sites More sharing options...
paddyhaig Posted July 11, 2010 Author Share Posted July 11, 2010 Like it, I will check it out later. Thanks Quote Link to comment Share on other sites More sharing options...
trq Posted July 11, 2010 Share Posted July 11, 2010 There's a pretty major floor in the INSERT statements. I forgot, you'll need to put the user_id in there too. INSERT INTO custom_settings (user_id, k, v) VALUES (19232, 'text-color', '#fff'); INSERT INTO custom_settings (user_id, k, v) VALUES (19232, 'background-color', '#666'); INSERT INTO custom_settings (user_id, k, v) VALUES (19232, 'max-post-per-page', '20'); Quote Link to comment Share on other sites More sharing options...
paddyhaig Posted July 11, 2010 Author Share Posted July 11, 2010 Thanks for your help again, I will look into this later today as I have to work through the night on a different job. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.