PHP And Bootstrap Themes

Asked

Viewed 112 times

-1

Do you remember that in Orkut had that option to change color, and the chosen color worked on everything.

So, I read some articles and saw that you can do this with SASS, but I do not understand SASS and I would like to know how I can do this with PHP?

Without using a shitload of IFs.

  • You want the user to change, is that it? I rarely used Orkut, so I have no idea if this is what you mean, would it be like the twitter color theme for the user? You want this to be only visible to the user or such user has a profile and you want this profile to change color for anyone who accesses?

  • That would be like the theme of twitter, but that no one has access the profile is unique to the person, is a sisteminha I want to implement that she can choose the color of the navbar.

  • So it’s not like twitter, because twitter spreads to everyone else your profile, in this case it’s simpler, I’ll tell you, you’ll need to choose, between saving the theme in the user-related database or just in the user’s browser session, but that would depend on what you already have ready.

  • So Guilherme, I have nothing ready, I managed to change the theme with JS doing so [link]<button type="button" name="button" class="btn btn-Primary col-Sm-4 col-Md-4 col-lg-4 pt-4 mt-4" onclick="Document.getElementById('navbar').style.background = 'blue'">Blue</button> [/link] but I don’t know if it’s right or if it’s right to save this, and how to bring this information

  • And what would be wrong with saving in the bank? Could even be a tmp file related to user ID, the issue is not what is right or wrong, the issue is what you need.

  • So, I don’t know how to save this in the bank, is it possible to save it in the bank? a cmd javascript?

  • CMD and JS? What’s this for? Web is HTTP, just save it to the backend, whether it’s database, txt, or Session.

  • CMD is abbreviating command, ie I created this button using Onclick to change the color of navbar, my question is how to save it in mysql database and load it as I can ?

Show 3 more comments

1 answer

1

Create multiple versions of your layout with different colors:

  • layout.azul.css
  • layout.red.css
  • layout.verde.css

Then, considering that you have the user configuration persisted in some way, you can load the CSS file referring to the layout that it chose. For example, assuming the color the user chose is in the variable $cor, you can do

<link href="layout.<?= $cor ?>.css" rel="stylesheet">

Thus loading the respective file to that user.

  • I understood this way, but how I would escape from ifs??

  • @Fábiostraliotimartins Que ifs?

  • In this case, I would create several versions of the right layout? then the user would define in the settings what to use, an example, pink. you showed me by loading [code] <link href="layout. <?= $color ? >. css" rel="stylesheet"> [/code], but I would have to do some ifs in the places I want to change the color would not be?

  • No, inside the file layout.rosa.css would already have all the CSS configured for the color pink. The only thing is that so would have to maintain several versions of your layout, which can harm maintenance.

  • The maintenance would be quiet, because it would leave fixed color, the way to call this function is what is my doubt, because by default will have the red layout, the person clicking the pink would change to the pink, but would have to overlap the red. My question is, how to call the pink layout instead of the red one? or just calling for the link it will overlap?

  • Will making an if at the time the person chooses it will override all?

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.