Jump to content

Programming Site Skin Changes with PHP


BelovedDoll

Recommended Posts

I`ve seen sites, such as ones using Drupal and other open source codes, where skin changes can be done at the click of a button and the site can look drastically different. I have one in place where it`s very basic for my users to select which skins they want but it`s so basic that just colour changes are made (such as text colour, background colour of content boxes, etc). And the code I`m is all custom code I`ve been doing myself.

 

I downloaded Drupal in hopes of being able to look at it`s codes and see how they do things (it`s how I learn, by seeing codes). But unfortunately the way they write their codes, I don`t understand it at all. I probably only understand about 5% of what they have. I was even looking into how they do blocking but couldn`t get that either.

 

Examples of what I`m looking for:

Skin 1 may have the navigation menu on the top of the page

Skin 2 may have the navigation menu on the left of the page and are just text links

Skin 3 may have the navigation menu on the left of the page and are pictured tabs

 

All of which may also have their own colour codes for texts and background changes and how content boxes are done, etc.

 

How will I be able to write up codes to have my site`s skin change in a total fashion and in a way that I can work with where it`s simple and I can edit it at any time if I choose to (though it may not be needed)?

Link to comment
Share on other sites

I must not have worded myself clearly. I apologize for that. I sometimes am not so good with explaining myself.

 

What I`m looking for is to get it started, mainly how I can my code to display the menu in different places (and other aspects) based on the skin that is chosen. I have in place the programming for users to choose the skin and my system recognizes the user`s chosen skin via the database.

 

I just need it to go full out the way I want it so that every part can be customized, including placement of items.

Link to comment
Share on other sites

No I`m not looking for a drag and drop. I`m looking for something like the user chooses a skin and clicks the submit button then BAM! The skin is changed; colors are different, images are different, navigation menu will be in a different place and styled different, etc. I create the designs/skins, the user just chooses of those skins what they want.

 

I`m looking for how placement of items, such as the navigation menu, can be moved or displayed based on the skin design.

Link to comment
Share on other sites

The positioning of elements on the site & the look & feel (colors, backgrounds, etc) should be controlled via CSS. Change the CSS file & reload and the site will be different.  There are also ways of immediately applying the new CSS via Javascript.

 

Ken

Link to comment
Share on other sites

I don`t see how CSS could tell items where to be placed or how to construct content boxes based on the design I come up with (ie, curved edges or not) that will move and resize according to screen size or size of content boxes and use my designs in the way they should be. I have tried CSS before and while it definitely has some good points to it that I love (and currently use) but it hasn`t come out functioning the way I expected it to in many areas and has become more problem than helpful and has ruined things. Like I created a table CSS, and any table within that table were totally messed up and I couldn`t change their looks at all and I tried everything to do it.

 

I guess my best thing at this point is to just create multiple php files for the same piece, with their own designs and things, to be called upon depending on which skin is being used, similar to what I did with the content box creation files.

Link to comment
Share on other sites

I don`t see how CSS could tell items where to be placed or how to construct content boxes based on the design I come up with (ie, curved edges or not) that will move and resize according to screen size or size of content boxes and use my designs in the way they should be.

 

!!!

 

CSS is the best way to construct a layout.  Why?  Because it has a ton of positional attributes and options that allow you to put an element anywhere on the page, regardless of where it was written in the HTML document.

 

 

I have tried CSS before and while it definitely has some good points to it that I love (and currently use) but it hasn`t come out functioning the way I expected it to in many areas and has become more problem than helpful and has ruined things. Like I created a table CSS, and any table within that table were totally messed up and I couldn`t change their looks at all and I tried everything to do it.

 

If this table was for layout, you shouldn't have been using a table anyway.  Tables are for tabular data, not layout.  Use divs instead.  It's a lot easier that way.  Also, don't give up on CSS because you had a bad experience with it.  If you're going to be doing any kind of web work professionally, you need to know it and use it.  Not doing so is akin to a chef not knowing how to boil water.  It is that fundamental.

 

If you're having trouble with CSS positioning, do a Google search for 'CSS box model'.

Link to comment
Share on other sites

Oh trust me, I have read up on many CSS tutorials and am not giving up on CSS, which I am surprised that you think I am when I have made the statement that I currently use CSS. I have worked with it for some months now and find that some pieces of it make things incredibly easy to do, then other areas it`s super difficult. I have constructed a table with CSS, following many tutorials, and it was taking a long time and was constantly needing re-adjustments and made things looked funky if the viewer had different screen resolution than I did.

 

I just find PHP far easier for me to work with and quicker to setup. Plus it doesn`t give me as nearly many headaches or struggles as CSS does.

 

EDIT

Stop jumping on me and trying to make it look like I`m saying that CSS is terrible and shouldn`t be used. I`m saying that FOR ME it isn`t working out and FOR ME it is difficult in some areas and FOR ME I can`t get it to do things the way I expect it to. FOR ME, PHP is the better choice. Nowhere am I saying that nobody shouldn`t use CSS.

Link to comment
Share on other sites

Take a look at the site CSS Zen Garden and then say that CSS can't be used to do what you want to do.

 

I took a look at that and I don`t see the design as what I`m trying to do with my website. I also find the page kind of jumbled with it`s main content on the page, but that could easily be because of the choice of the person, not the program`s fault.

Link to comment
Share on other sites

That is exactly what you are trying to do with your site.  If you click on the different designs, you are getting the exact same data applied in different ways BAM like that.  You could set your site up just as fluid with CSS. This is the ONLY way to do it without making templates for each design (maintenance intensive). This way, a new design is just a CSS file away.

Link to comment
Share on other sites

Some CSS is hard to do.  No denying that.  That's one of the reasons I suggested you look up the box model.  CSS positioning didn't make any sense to me until I learned that.  Positioning and document flow are the two most powerful, and the two most difficult, concepts to grasp with CSS.  Once you understand them, the rest is child's play.

 

And, the purpose of the Zen Garden site is to showcase what CSS can do.  There's but one HTML file for the demonstration page.  All of the differences between the various layouts (images, fonts, positioning) are due to the CSS files.

 

Why does it HAVE to be CSS? Why can`t it be in a form that works for me? Why can`t I do my own programming in an environment I`m comfortable with that works?

 

We're suggesting it because:

 

1. It really is the most efficient way to do it.

2. It's something you need to be comfortable with if you want to do web work for a living.

 

No one is holding a gun to your head.  Do what you want.  You have nothing to prove to us.  But remember that you did come to us for advice.  I believe we all gave you the best advice we could.  Do what you want with it.

Link to comment
Share on other sites

I asked for help on how to do it with PHP, not what form of code everyone believes is best for doing it.

 

I am not looking to do programming for a living, I just want to do it for my own website. Knowing how competitive and difficult it is to get a job in programming (from trying for years), it`s too hard for me to even try and squeeze in among everyone else who are all far more knowledged than I. So I just wouldn`t stand a chance against the competition so there`s no point in me even trying to join the races. Because it`s only grounds for failure for me.

Link to comment
Share on other sites

The only other way to do it is to make individual PHP template files.  include them based on a user's settings.  You'll need to make sure you keep your code that handles and processes requests as separate as possible from the code that handles displaying things.

 

I already advised that way also, but the OP stated that wasn't what he wanted.  The only other way is CSS.

Link to comment
Share on other sites

The only other way to do it is to make individual PHP template files.  include them based on a user's settings.  You'll need to make sure you keep your code that handles and processes requests as separate as possible from the code that handles displaying things.

 

I already advised that way also, but the OP stated that wasn't what he wanted.  The only other way is CSS.

@jcbones

First off I`m a girl. Not that I have made this indication publicly like everyone else but I thought that a username of "Beloved Doll" would be feminine and wouldn`t indicate any masculinity. So my theory stands corrected. I`ll have to indicate my gender and help with any confusion in that department. I`m not offended by it since with old names I`ve used, I`ve been mistaken for a guy repeatedly so I`m used to it.

 

Secondly, I went back in the posts, and I didn`t see anywhere that I said that I didn`t want to do includes. So I don`t know where you are getting this from. Your suggestions were CSS, drag and drop, and cookie/database. I didn`t find "includes" in your posts.

 

@Nightslyr

I`m still having trouble figuring out how the placement of items could change based on the skin of choice. The placement of the navigation bar is what I`m currently am scratching my head over. This is one idea I had but am not sure if it`s the best way to do it for any future additions of skins:

Have file1.php be containment and calling of all items that come before the content of the page.

In file1.php, it calls skin.php which has all info on skin selection and what their specifications are (such as colours and whatnot).

Also in file1.php, have something like if $skin == 5 then display navigation for the top, elseif $skin == 36 then display navigation for the side (which requires all the coding for the navigation to be there with each and every if statement so I would have to add in new navigation items [or remove any] from each and every if statement).

 

But surely there is a better way to do it? Or is that really the way to do it and I have to find another way for the navigation to call on the items from one source so I only have to edit that once and not edit the navigation menu for each and every skin?

Link to comment
Share on other sites

I asked for help on how to do it with PHP, not what form of code everyone believes is best for doing it.

 

I am not looking to do programming for a living, I just want to do it for my own website. Knowing how competitive and difficult it is to get a job in programming (from trying for years), it`s too hard for me to even try and squeeze in among everyone else who are all far more knowledged than I. So I just wouldn`t stand a chance against the competition so there`s no point in me even trying to join the races. Because it`s only grounds for failure for me.

 

You clearly have no idea of what CSS is. Drupal, joomla and any website not created by monkeys uses it.

 

just go to W3schools.com/css do the tutorial  run through it.

Ones you know what classes and id's  are you can use php to set the class or id, and than quickly switch between styles.

 

in css you have for instance 2 styles day and night

.day{
background-color: white;
}
.night{
background-color: black;
}

 

in you php file or html you do

<?php
// get style from database and put it in $style
?>
...
<body>
...
<p class="<?php echo $style; ?>"> hello i am text within a p element</p>
...
</body>

 

this way you keep your structure, functionality and style separate. Not because some geek said so, but because it's more efficient and easier to read for yourself teammembers and anyone else interested. If your function is not working you check your php, don't like your colors, alter your css etc etc.

Link to comment
Share on other sites

@Nightslyr

I`m still having trouble figuring out how the placement of items could change based on the skin of choice. The placement of the navigation bar is what I`m currently am scratching my head over. This is one idea I had but am not sure if it`s the best way to do it for any future additions of skins:

Have file1.php be containment and calling of all items that come before the content of the page.

In file1.php, it calls skin.php which has all info on skin selection and what their specifications are (such as colours and whatnot).

Also in file1.php, have something like if $skin == 5 then display navigation for the top, elseif $skin == 36 then display navigation for the side (which requires all the coding for the navigation to be there with each and every if statement so I would have to add in new navigation items [or remove any] from each and every if statement).

 

But surely there is a better way to do it? Or is that really the way to do it and I have to find another way for the navigation to call on the items from one source so I only have to edit that once and not edit the navigation menu for each and every skin?

 

This is actually close to the way Joomla does templates.  They use PHP files which are mostly HTML.  The PHP bits check to see if any modules should be displayed at set positions.  You should download Joomla and take a look.  It comes with three different templates out of the box.  Look at their index.php files.

Link to comment
Share on other sites

@fortnox007

I know exactly what CSS is. As my third time stating this, I currently use CSS for my website.

 

@Nightslyr

You recommend Joomla? I`ve never used it before. Hmm, I`ll take a gander at it. The hardest part I had with Drupal is that it`s code is totally unreadable to me. I`ll get a hold of Joomla and see how that works out.

Link to comment
Share on other sites

@Nightslyr

You recommend Joomla? I`ve never used it before. Hmm, I`ll take a gander at it. The hardest part I had with Drupal is that it`s code is totally unreadable to me. I`ll get a hold of Joomla and see how that works out.

 

 

I don't recommend Joomla as a substitute for what you're trying to do.  I find it to be flawed in several areas.  I do think you should look at how it handles templates in its code, just so you can see how a non-CSS only approach could look.

 

In other words, don't use Joomla as your solution.  Look at its code to figure out how to do it yourself. 

 

Personally, I wouldn't recommend Joomla to anyone, having done some work with it recently.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.