This topic is locked
[SOLVED]

 Theme Selector for ver10

10/3/2019 10:47:38 PM
PHPRunner General questions
W
WilliamB authorDevClub member

There was an old post that had a theme selector.
https://asprunner.com/forums/topic/24460-bootstrap-theme-selector/
This was in ver9 and it no longer works for ver10.
Has anyone got it to work for ver10?
Billy

N
Nir Frumer 10/7/2019

Hi Themes are on the Editor page

Other formattings are on the designer page...
hope it helps

Nir.

woodey2002 10/8/2019

Use firebug and the Custom CSS option in the editor tab and you can create any look/style you desire yourself.
Cheers,

James

W
WilliamB authorDevClub member 10/8/2019

Thanks woodey2002 and nir frumer but I think you both misread my post.
I know how to change the theme in PHPRunner. If you follow the link you will see that the theme selector was to allow users of the app to select their own choice of theme.
https://asprunner.com/forums/topic/24460-bootstrap-theme-selector/
This stopped working after ver9.8. I would like to allow this in ver10.
William

S
sthefaine 10/8/2019

I have it working in ver10. I used this as a guideline and all worked perfectly. https://asprunner.co...theme-selector/ but very similar.

Can I ask you how you have it setup and maybe we can pinpoint where the issue is? Thanks Steve

W
WilliamB authorDevClub member 10/10/2019



I have it working in ver10. I used this as a guideline and all worked perfectly. https://asprunner.com/forums/topic/24460-bootstrap-theme-selector/ but very similar.

Can I ask you how you have it setup and maybe we can pinpoint where the issue is? Thanks Steve


I will look at everything again but I haven't changed any code and all was working in ver9.8. It stopped after changing versions. Is it working in ver10.2 or 10.3 for you?

S
sthefaine 10/11/2019

Billy,
See this part :

  • In Line 50, you can find this code

    $layout->bootstrapTheme = "##@layoutInfo.bootstrapTheme##";
  • Modify the code to

    $layout->bootstrapTheme = $_SESSION["MyCoolTheme"];
    I found this no longer worked and put it back the way it was originally.
    I then found if I changed appsettings.php in the source\include directory of the 10.2 or 10.3 install line 614

    $bsProjectTheme = $_SESSION["MyCoolTheme"];
    This made everything work again.
    Steve

W
WilliamB authorDevClub member 10/11/2019



Billy,
See this part :

  • In Line 50, you can find this code

    $layout->bootstrapTheme = "##@layoutInfo.bootstrapTheme##";
  • Modify the code to

    $layout->bootstrapTheme = $_SESSION["MyCoolTheme"];
    I found this no longer worked and put it back the way it was originally.
    I then found if I changed appsettings.php in the source\include directory of the 10.2 or 10.3 install line 614

    $bsProjectTheme = $_SESSION["MyCoolTheme"];
    This made everything work again.
    Steve


I looked a bit last night and saw that it wasn't taking that line 50 anymore as well. I didn't look further. I will modify that file and put it in my custom files to replace original.
Thanks for your help here!!

Billy

W
WilliamB authorDevClub member 10/16/2019

It looks like this actually does not work on the login and the initial landing on the menu page. The stylesheet does not load properly. All other project pages seem to work fine.
Billy

W
WilliamB authorDevClub member 10/18/2019

OK I found the fix. This will work for v10.2 or v10.3.
I didn't need to change appsettings.php or the layoutbuilder.php.

  1. Create a new table in your database, for example: "theme_list"

    Inside theme_list table, create one field: "themes"

    Now, add the following records to themes field:



cyborg

darkly

default

flatly

journal

lumen

paper

readable

sandstone

simplex

slate

spacelab

superhero

united

yeti

bootstrap

cerulean

cosmo



2. In login table add fields

MyTheme

MyThemeSize



3. Copy All bootstrap styles from C:\Program Files\PHPRunner10.3\styles\bootstrap to /yourwebroot/styles/bootstrap
4. In AfterAppInit on Events tab add this code.

//Theme selector

if(!Security::isLoggedIn()){

$_SESSION["MyTheme"] = "cerulean";

$_SESSION["MyThemeSize"] = "normal";

}else{

$sql = "SELECT MyTheme, MyThemeSize FROM YourLoginTableName WHERE UsernameField='".$_SESSION["UserID"]."'";

$rs = DB::Query($sql);

$data = $rs->fetchAssoc();

$_SESSION["MyTheme"] = $data["MyTheme"];

$_SESSION["MyThemeSize"] = $data["MyThemeSize"];

}

$bsProjectTheme = $_SESSION["MyTheme"];

$bsProjectSize = $_SESSION["MyThemeSize"];



Change "YourLoginTableName" and "UsernameField" to what you use.
5. I make a custom view of the login table (I'll call it Employees) make sure you include fields "MyTheme" and "MyThemeSize" and any others you want available for the users to edit. MyTheme is a lookup table of point 1. MyThemeSize is a lookup of values "normal" and "small". Then on the Security tab click Advanced... Set the table Employees to "Users can see and edit their own data only".
You will now have themes for your users to select themselves!