Jump to content

Let customer chose the theme


inthanet

Recommended Posts

Hi,

I'm looking for a solution that a customer can choose the theme (Normal / Dark)

I use the WHMCS default theme "twenty-one" and have additional "twenty-one as dark theme" by using child-theme.

I would like that our customer can choose what they prefer Normal or Dark theme

 

Has anyone an idea how a solution could look like?

Link to comment
Share on other sites

4 minutes ago, inthanet said:

Hi,

I'm looking for a solution that a customer can choose the theme (Normal / Dark)

I use the WHMCS default theme "twenty-one" and have additional "twenty-one as dark theme" by using child-theme.

I would like that our customer can choose what they prefer Normal or Dark theme

 

Has anyone an idea how a solution could look like?

Could add some JavaScript to change the theme by adding 

?systpl=dark-theme-name

to the end of the URL. Not ideal though and much better ways to do it.

Link to comment
Share on other sites

2 hours ago, leemahoney3 said:

Could add some JavaScript to change the theme by adding 


?systpl=dark-theme-name

to the end of the URL. Not ideal though and much better ways to do it.

Hi,

actually I had the same thought, but the problem is when the customer navigate throughout the menu, the additional parameter may get lost. 

Thanks for your suggestion.

 

P.S.

I try to find out how I could use a hook to accomplish this

Link to comment
Share on other sites

4 hours ago, inthanet said:

Hi,

I'm looking for a solution that a customer can choose the theme (Normal / Dark)

I use the WHMCS default theme "twenty-one" and have additional "twenty-one as dark theme" by using child-theme.

I would like that our customer can choose what they prefer Normal or Dark theme

 

Has anyone an idea how a solution could look like?

Did you look into this?

https://marketplace.whmcs.com/product/6194-twenty-one-dark-theme

Link to comment
Share on other sites

1 hour ago, evolve hosting said:

That exactly the theme I have purchased, it's working great so far. A few CSS tweaks are needed, but no problem.

WHMCS let me choose the Theme via general settings, but this will be fixed for all users.
I like that users are able to select the theme (Normal or Dark)

The information could be saved in a WHMCS custom field. 

When the user login this information would be available so that the user would see the website according to the custom field data.

 

Link to comment
Share on other sites

9 hours ago, inthanet said:

actually I had the same thought, but the problem is when the customer navigate throughout the menu, the additional parameter may get lost. 

It doesn't matter. For visitors (or users who have not logged) the parameter is transfered to a session or cookie (can't remember) hence the they would continue navigation with dark template you just defined in systpl. Keep in mind session is short-living so the user might go back to default template in a couple of minutes. To overcome this simply transfer template name (eg. dark or light) from session to a long-living cookie.

As for logged users, systpl automatically sets template in their settings. More in particular in tblclients.template. This way when they come back they keep navigating with the correct template.

Link to comment
Share on other sites

13 hours ago, Kian said:

It doesn't matter. For visitors (or users who have not logged) the parameter is transfered to a session or cookie (can't remember) hence the they would continue navigation with dark template you just defined in systpl. Keep in mind session is short-living so the user might go back to default template in a couple of minutes. To overcome this simply transfer template name (eg. dark or light) from session to a long-living cookie.

As for logged users, systpl automatically sets template in their settings. More in particular in tblclients.template. This way when they come back they keep navigating with the correct template.

OK, thank you and leemahoney3  for sharing your thoughts.
I will give a try, this sounds like promising solution.

Link to comment
Share on other sites

On 2/15/2023 at 7:50 PM, Kian said:

It doesn't matter. For visitors (or users who have not logged) the parameter is transfered to a session or cookie (can't remember) hence the they would continue navigation with dark template you just defined in systpl. Keep in mind session is short-living so the user might go back to default template in a couple of minutes. To overcome this simply transfer template name (eg. dark or light) from session to a long-living cookie.

As for logged users, systpl automatically sets template in their settings. More in particular in tblclients.template. This way when they come back they keep navigating with the correct template.

...... To overcome this simply transfer template name (eg. dark or light) from session to a long-living cookie

Where/how to use the "long-living cookie" (via hook)? 

Link to comment
Share on other sites

 I have been forced to take screenshots of my post because this f*o*r*u*m* thinks that PHP variables and URLs are hacks. Click to zoom and report WHMCS to Police 😑  A f*o*r*u*m* can't be so stupidly restrictive (yes, we can't even type f*o*r*u*m) 😡

 

  immagine.thumb.png.da4b17f2c5bac1cbcf3934e3e5970973.png

Edited by Kian
Link to comment
Share on other sites

13 minutes ago, Kian said:

 I have been forced to take screenshots of my post because this f*o*r*u*m* thinks that PHP variables and URLs are hacks. Click to zoom and report WHMCS to Police 😑  A f*o*r*u*m* can't be so stupidly restrictive (yes, we can't even type f*o*r*u*m) 😡

 

  immagine.thumb.png.da4b17f2c5bac1cbcf3934e3e5970973.png

Thanks for your suggestion/Solution. I will take a closer look to improve my code or may I see something for future projects 🙂

In the meantime, I found a solution which works for me so far.

By the way, I have the same problem, when I try to post something in this community as code I get an HTTP403 Error
My Solution attached as screenshot 🙂 

 

ThemeSwitchHook.png

Edited by inthanet
Link to comment
Share on other sites

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.   Paste as plain text instead

  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

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated