3

I'm creating a joomla template that allows user to change the template styles (such as font-family setting, bgcolor, text color, etc) from the template backend.

Is it possible to create a reset button, so if you messed up the settings, you can easily revert back some fields to the default settings?

There's a workaround here but it's incomplete. Thanks!

  • I don't think there's any built-in option, so as @FFrewin said, a custom form field would be needed. Create a button that resets all input field values to their original state (you will most likely have to manually define these defaults). The user must then click the "save" button – Lodder Aug 18 '15 at 11:59
2

Template style options are saved in #__template_styles.params.

A Protostar's sample saved params:

{"templateColor":"#696969","templateBackgroundColor":"#E3E3E3","logoFile":"","googleFont":"1","googleFontName":"Open+Sans","fluidContainer":"0"}

So, I guess you will need a custom Field, that will run some update code to set your params of the current template style to a default state.

  • Yes, I think so. Thanks. Anyway, I just want to reset styles related params values only and leave the other untouched. Is it possible? – webchun Aug 18 '15 at 10:38
  • what are the related params? One idea would be to have in your update statement all the default params value, that will reset the template style. – FFrewin Aug 18 '15 at 12:03
  • Let say I have 4 fields, field A to control font-family, filed B to control web background color, field C to control text color, field D to control custom code for adding in <head> section. I want when user click the reset button, it will reset A,B,C only. Field D will not be modified. – webchun Aug 18 '15 at 12:39
  • Well, first I think you need to somehow know the current style's id, which I m not sure if there is a straight-forward way to have this in the edit style interface of the template's manager -if there isn't, then you will have to get it inside your custom field-, then you can first fetch the saved params and use any of these values inside your update statement. – FFrewin Aug 18 '15 at 13:23
  • Hmm, ok. Will try it and update my question soon. Thanks! – webchun Aug 18 '15 at 13:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.