Skip to content

NodeBB Theme/Skin Switcher

Solved Customisation
  • @Teemberland Odd. Is there any way I can see this in process? Failing that, try the below code, which is the latest version

    $(document).ready(function() {
    	function generateRandomString(length) {
    
    		var text = "";
    		var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    
    		for (var i = 0; i < length; i++) {
    			text += possible.charAt(Math.floor(Math.random() * possible.length));
    		}
    
    		return text;
    	}
    	var string = generateRandomString(10);
    	$("#random_string").text(string);
    	var whichTheme = localStorage.getItem("theme");
    	var activeTheme = localStorage.getItem("activeTheme");
    	// If no theme is detected (for example, a new visitor), then set this to default
    	if (!whichTheme) {
    		// dark-mode media query matched or not
    		let matched = window.matchMedia('(prefers-color-scheme: dark)').matches;
    		//var override = getUrlParameter('override');
    
    		if (matched) {
    			// Offer the mifnight theme by default
    			whichTheme = "midnight";
    			activeTheme = "/assets/customcss/midnight.css?version=" + string;
    			//$("link[rel=stylesheet]").attr('href' , thishref + "?version=" + string + "");
    		} else {
    			// Leave the default theme intact
    			whichTheme = "default";
    			activeTheme = "/assets/customcss/daylight.css?version=" + string;
    		}
    		// See if override has been enabled
    		if (whichTheme === 'default') {
    			// Sudonix is overriding operating system settings and will force dark scheme
    			activeTheme = "/assets/customcss/daylight.css?version=" + string;
    		}
    		if (whichTheme === 'daylight') {
    			// $('[component="post"]').addClass("background");
    			$('li.self-post .content:not(.isSolved [component="post/content"]').addClass("response");
    		} else {
    			// Nothing to do :)
    		}
    	}
    
    	/*$(".forum-logo").attr("src","/assets/uploads/system/sl_" + whichTheme + ".webp?version=" + string + ""); */
    	var panel = $('<li id="switcher" class="dropdown"> \
    <a title="" data-original-title="Swatch" class="navigation-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> \
    <i id="ticon" class="fa fa-light fa-swatchbook" data-content="" aria-hidden="true"></i> \
    <span class="visible-xs-inline">Swatch</span> \
    <i class="fa fa-caret-down" aria-hidden="true"></i> \
    </a> \
    <ul id="theme" class="dropdown-menu"> \
    <li><a id="default" href="#" rel="/assets/customcss/yourtheme.css">Your Theme</a></li> \
    </ul> \
    </li> \
    </div> \
    ');
    
    
    	if (whichTheme) {
    		$.get(activeTheme, function(css) {
    			$('<style type="text/css"></style>')
    				.html(css)
    				.appendTo("head");
    		});
    	} else {}
    
    	$('#main-nav').append(panel);
    
    	if (utils.findBootstrapEnvironment() === 'xs') {
    		$('#main-nav').append(panel);
    	}
    
    	$(document).ready(function() {
    
    		$("body").on("click change", "#theme li a", function() {
    			var thishref = $(this).attr('rel') + '?version=' + string;
    			$.get(thishref, function(css) {
    				$('<style type="text/css"></style>')
    					.html(css)
    					.appendTo("head");
    			});
    			console.log("Applying swatch " + thishref);
    			//location.reload();
    			var selected = $(this).attr("id");
    			var theTheme = $(this).attr("rel");
    			if (selected === 'default') {
    				localStorage.setItem("theme", selected);
    				localStorage.setItem("activeTheme", "/assets/customcss/daylight.css?version=" + string);
    				//location.reload();
    			} else {
    				localStorage.setItem("theme", selected);
    				localStorage.setItem("activeTheme", theTheme);
    			}
    			return false;
    		});
    	});
    });
    

    Note that there are assumptions here in that default is actually daylight.css on Sudonix if you are using light mode, and midnight if you are using dark mode - these are taken from the browser settings, and the operating system if supported.

  • @phenomlab okay, now I can see the style tag being appended on click. Now I’m thinking I have an error in my css file.

    Looking at one of your css files here, it looks something like this:

    @import "/assets/customcss/editors/stackoverflow-dark.css";
    :root {
        --first: #2b3e50;
        --second: #4e5d6c;
        ....
    

    How is that being generated?

  • @Teemberland It’s not “generated” - it’s created manually in the CSS files I put together. Essentially, each time you change the swatch, the CSS isn’t being loaded all over again (for clarity, all CSS MUST be placed in admin/appearance/customise#custom-css) - instead, it’s just changing the variables you have assigned.

    For example

    :root {
    --background: #ffffff;
    --body: #cccccc;
    ..... etc
    }
    

    In the CSS you add to admin/appearance/customise#custom-css, you’d use these variables like the below

    body {
    background: var(--body);
    }
    ..... etc
    

    This way, the CSS is only being executed once at page load, and then the swatch vars are the only thing changed when you switch themes or swatches.

  • @phenomlab gotcha! I’ll work on this and report back later. Thank you!

  • @phenomlab I can see my custom css being appended to head, but it’s odd that the variable in my custom css is not loading on the page.
    I’m keeping it simple and just trying to change the background-color of my forum by setting the following code in ACP > Appearance > Custom Content > Custom CSS

    body { background-color: var(--body); }
    

    But when I inspect the page, I can see my root styles being loaded, but the code above is no where to be found. Unlike in your forums, when you inspect the page, you can see the styles for body with this rule:

    body { var(--first) !important }
    
  • @Teemberland can you share the css you are using ?

  • @phenomlab here’s what I have in my default.css which is located in /assets/customcss/default.css

    :root {
      --body: #fff;
      --primary-color: #000;
    }
    

    here’s what I in dark_skin.css

    :root {
      --body: #424242;
    }
    

    here’s what I have in ACP > CUSTOM CSS

    body {
      background-color: var(--body);
    }
    
    /*----------------------------------------------------------------------------*/
    /*----------------------        Themes Switcher        -----------------------*/
    /*----------------------------------------------------------------------------*/
    
    /* Works with CUSTOM JS */
    /* DON'T DELETE - DON'T MOVE */
    /* -- */
    /* Fonctionne avec du CUSTOM JS */
    /* NE PAS SUPPRIMER - NE PAS  DEPLACER */
    
    /*Desktop*/
    /*Allows to have the "Theme Switcher" icon in black after a mouse click and during the dropdown */
    /*Permet d'avoir l'icone du "Theme Switcher" en noir après un clic souris et lors du dropdown */
    [aria-expanded="true"] a #ticon {
      color: #000000;
    }
    
    /*Theme Switcher icon color via CUSTOM JAVASCRIPT */
    /* Blank without mouse over */
    /*Couleur de l'icone du Theme Switcher via le CUSTOM JAVASCRIPT */
    /* Blanc sans mouse over*/
    .themeon {
      color: #ffffff !important;
    }
    
    /*Black with mouseover*/
    /*Noir avec mouse over*/
    .themeoff {
      color: #000000 !important;
    }
    
    /*Smartphone*/
    @media all and (max-width: 1024px) {
    
      /*BUGFIX: Placement of the "Theme Switcher" */
      /*BUGFIX: Placement du "Theme Switcher" */
      #switcher {
        list-style: none;
        margin-left: -80px;
        padding-top: 15px;
      }
    
      /*BUGFIX: Space between the icon and the text "Theme Switcher" */
      /*BUGFIX: Espace entre l'icone et le texte "Theme Switcher" */
      #switcher .fa-fw {
        text-align: center;
        width: 1.25em;
        padding-right: 25px;
      }
    
      /* DON'T DELETE - DON'T MOVE */
      /*Allows to have the "Theme Switcher" icon in white after a mouse click and during the dropdown */
      /* NE PAS SUPPRIMER - NE PAS  DEPLACER */
      /*Permet d'avoir l'icone du "Theme Switcher" en blanc après un clic souris et lors du dropdown */
      [aria-expanded="true"] a #ticon {
        color: #ffffff;
      }
    
      /*Theme Switcher icon color via CUSTOM JAVASCRIPT */
      /* Blank without mouse over */
      /*Couleur de l'icone du Theme Switcher via le CUSTOM JAVASCRIPT */
      /* Blanc sans mouse over*/
      .themeoff {
        color: #ffffff !important;
      }
    }
    
    /*FIREFOX BUGFIX: Remove dotted border from icon when clicked */
    /*BUGFIX FIREFOX: Suppression de la bordure pointillée de l'icône quand on clique dessus */
    /*Desktop*/
    a:focus {
      outline: 0;
    }
    
    /*Smartphone*/
    @media all and (max-width: 1024px) {
      a:focus {
        outline: 0;
      }
    }
    
    
    /* Desktop */
    /*Button Position */
    /*Position du Bouton */
    .header #theme_dropdown {
      /*padding: 9px 15px;*/
      padding: 9px 15px;
      padding-top: 9px;
      padding-bottom: 9px;
      margin-top: -4px;
      padding-top: 15px;
      padding-bottom: 14px;
    }
    
    /* ---- Appearance of the "Theme Switcher" icon in the navbar via Font Awesome (!!Change the CSS class also in the JS!!) ----*/
    /*Ampule*/
    /* ---- Apparence de l'icône du "Theme Switcher" dans la navbar via Font Awesome (!!Changer la class CSS aussi dans le JS!!) ----*/
    /*Ampoule*/
    .fa.fa-lightbulb-o:before {
      content: "\f0eb";
    }
    
    /*Navbar height to play with background height */
    /*Hauteur navbar pour jouer avec la hauteur du background */
    .navbar-default {
      height: 51px;
    }
    
    /*Spacing between "Search" and "Notifications" icons */
    /*Espacement entre les icônes "Recherche" et "Notifications" */
    #switcher {
      margin-top: 4px;
    }
    
    /*We remove the background on the icon */
    /*On supprime le background sur l'icone */
    #switcher .btn-link:hover {
      background: none !important;
    }
    
    /*Background color on mouseover (Default Theme) */
    /*Couleur du background au survol souris (Default Theme) */
    .navbar-default .navbar-nav>li>label:hover {
      background: #eeeeee;
    }
    
    /*Appearance of selection menu */
    /*Apparence du menu de sélection */
    #theme.dropdown-menu {
      position: absolute;
      top: 44px;
      right: 0px;
      z-index: 1000;
      float: left;
      min-width: 160px;
      padding: 5px 0;
      margin: 2px 0 0;
      list-style: none;
      font-size: 14px;
      text-align: left;
      background-clip: padding-box;
    }
    
    /* Smartphone */
    /*Appearance of button and drop-down menu on Smartphone */
    /*Apparence du bouton et du menu déroulant sur Smartphone */
    @media all and (max-width: 1024px) {
    
      /*Dropdown menu text color */
      /*Couleur du texte du menu déroulant */
      #theme.dropdown-menu>li>a {
        display: block;
        padding: 3px 20px;
        clear: both;
        font-weight: 400;
        line-height: 1.42857143;
        color: #fff;
        white-space: nowrap;
        background: #3A3C41;
      }
    
      /*Appearance and position of button and drop-down menu */
      /*Apparence et position du bouton et du menu déroulant */
      #theme.dropdown-menu {
        position: fixed;
        top: 140px;
        left: 15px;
        z-index: 1000;
        float: left;
        min-width: 185px;
        padding: 5px 0;
        margin: 2px 0 0;
        list-style: none;
        font-size: 14px;
        text-align: left;
        /* background-clip: padding-box; */
        color: #fff;
        background: #3A3C41;
        width: 60px;
        /* VIOLENCE: Largeur */
        border: 1px solid black;
      }
    
    
      /*Text color and button background when selected */
      /*Couleur du texte et background du bouton lors de la selection */
      .btn-link:focus,
      .btn-link:hover {
        /*color: #23527c;*/
        color: lightgrey;
        text-decoration: underline;
        background-color: transparent;
      }
    
      /*We remove the white bars at the top and bottom of the button on Smartphone */
      /*On supprime les barres blanches en haut et en bas du bouton sur Smartphone */
      .navbar-form {
        left: 20px;
        box-shadow: none;
        list-style: none;
      }
    }
    

    I put body on top of custom css for visibility.

    NOTE: When I create a new styles for body in the inspector using the variable, it works fine. I think once my styles in ACP > CUSTOM CSS shows up, it will start working.

  • @Teemberland what happens if you append the body CSS class with !important ? You shouldn’t need this, but I think your style is being overridden further down by the default css.

  • @phenomlab yeah I tried this earlier, it didn’t work. In theory, when you add any css rule in ACP > CUSTOM CSS, it should show right away right? I can’t quite figure out why it’s not working.

    EDIT: I also made sure I’m rebuilding/restarting after I change my CUSTOM CSS in ACP.

  • @Teemberland you’re correct, it shouldn’t require a rebuild. Humour me though. In the ACP within the custom css, look at the bottom and ensure the custom css is enabled?

    It’s disabled by default.

  • @phenomlab ha! that’s the next thing I checked yesterday. But it is enabled. Maybe I can add the styles in Extend > Widgets > HTML ?

  • @Teemberland that shouldn’t be necessary as the CSS is taken from the ACP. Clearly, something is amiss here. Can you provide a list of what you’ve done thus far so I can take a look? A better way would be to get access to your environment directly for review.

  • @phenomlab Yeah, I’m not quite sure what I’m missing here. Anyways, here’s what I’ve done so far.

    1. Placed CSS in ACP > Appearance > Custom Content > Custom CSS
    body {
      background-color: var(--body) !important;
    }
    
    /*----------------------------------------------------------------------------*/
    /*----------------------        Themes Switcher        -----------------------*/
    /*----------------------------------------------------------------------------*/
    
    /* Works with CUSTOM JS */
    /* DON'T DELETE - DON'T MOVE */
    /* -- */
    /* Fonctionne avec du CUSTOM JS */
    /* NE PAS SUPPRIMER - NE PAS  DEPLACER */
    
    /*Desktop*/
    /*Allows to have the "Theme Switcher" icon in black after a mouse click and during the dropdown */
    /*Permet d'avoir l'icone du "Theme Switcher" en noir après un clic souris et lors du dropdown */
    [aria-expanded="true"] a #ticon {
      color: #000000;
    }
    
    /*Theme Switcher icon color via CUSTOM JAVASCRIPT */
    /* Blank without mouse over */
    /*Couleur de l'icone du Theme Switcher via le CUSTOM JAVASCRIPT */
    /* Blanc sans mouse over*/
    .themeon {
      color: #ffffff !important;
    }
    
    /*Black with mouseover*/
    /*Noir avec mouse over*/
    .themeoff {
      color: #000000 !important;
    }
    
    /*Smartphone*/
    @media all and (max-width: 1024px) {
    
      /*BUGFIX: Placement of the "Theme Switcher" */
      /*BUGFIX: Placement du "Theme Switcher" */
      #switcher {
        list-style: none;
        margin-left: -80px;
        padding-top: 15px;
      }
    
      /*BUGFIX: Space between the icon and the text "Theme Switcher" */
      /*BUGFIX: Espace entre l'icone et le texte "Theme Switcher" */
      #switcher .fa-fw {
        text-align: center;
        width: 1.25em;
        padding-right: 25px;
      }
    
      /* DON'T DELETE - DON'T MOVE */
      /*Allows to have the "Theme Switcher" icon in white after a mouse click and during the dropdown */
      /* NE PAS SUPPRIMER - NE PAS  DEPLACER */
      /*Permet d'avoir l'icone du "Theme Switcher" en blanc après un clic souris et lors du dropdown */
      [aria-expanded="true"] a #ticon {
        color: #ffffff;
      }
    
      /*Theme Switcher icon color via CUSTOM JAVASCRIPT */
      /* Blank without mouse over */
      /*Couleur de l'icone du Theme Switcher via le CUSTOM JAVASCRIPT */
      /* Blanc sans mouse over*/
      .themeoff {
        color: #ffffff !important;
      }
    }
    
    /*FIREFOX BUGFIX: Remove dotted border from icon when clicked */
    /*BUGFIX FIREFOX: Suppression de la bordure pointillée de l'icône quand on clique dessus */
    /*Desktop*/
    a:focus {
      outline: 0;
    }
    
    /*Smartphone*/
    @media all and (max-width: 1024px) {
      a:focus {
        outline: 0;
      }
    }
    
    
    /* Desktop */
    /*Button Position */
    /*Position du Bouton */
    .header #theme_dropdown {
      /*padding: 9px 15px;*/
      padding: 9px 15px;
      padding-top: 9px;
      padding-bottom: 9px;
      margin-top: -4px;
      padding-top: 15px;
      padding-bottom: 14px;
    }
    
    /* ---- Appearance of the "Theme Switcher" icon in the navbar via Font Awesome (!!Change the CSS class also in the JS!!) ----*/
    /*Ampule*/
    /* ---- Apparence de l'icône du "Theme Switcher" dans la navbar via Font Awesome (!!Changer la class CSS aussi dans le JS!!) ----*/
    /*Ampoule*/
    .fa.fa-lightbulb-o:before {
      content: "\f0eb";
    }
    
    /*Navbar height to play with background height */
    /*Hauteur navbar pour jouer avec la hauteur du background */
    .navbar-default {
      height: 51px;
    }
    
    /*Spacing between "Search" and "Notifications" icons */
    /*Espacement entre les icônes "Recherche" et "Notifications" */
    #switcher {
      margin-top: 4px;
    }
    
    /*We remove the background on the icon */
    /*On supprime le background sur l'icone */
    #switcher .btn-link:hover {
      background: none !important;
    }
    
    /*Background color on mouseover (Default Theme) */
    /*Couleur du background au survol souris (Default Theme) */
    .navbar-default .navbar-nav>li>label:hover {
      background: #eeeeee;
    }
    
    /*Appearance of selection menu */
    /*Apparence du menu de sélection */
    #theme.dropdown-menu {
      position: absolute;
      top: 44px;
      right: 0px;
      z-index: 1000;
      float: left;
      min-width: 160px;
      padding: 5px 0;
      margin: 2px 0 0;
      list-style: none;
      font-size: 14px;
      text-align: left;
      background-clip: padding-box;
    }
    
    /* Smartphone */
    /*Appearance of button and drop-down menu on Smartphone */
    /*Apparence du bouton et du menu déroulant sur Smartphone */
    @media all and (max-width: 1024px) {
    
      /*Dropdown menu text color */
      /*Couleur du texte du menu déroulant */
      #theme.dropdown-menu>li>a {
        display: block;
        padding: 3px 20px;
        clear: both;
        font-weight: 400;
        line-height: 1.42857143;
        color: #fff;
        white-space: nowrap;
        background: #3A3C41;
      }
    
      /*Appearance and position of button and drop-down menu */
      /*Apparence et position du bouton et du menu déroulant */
      #theme.dropdown-menu {
        position: fixed;
        top: 140px;
        left: 15px;
        z-index: 1000;
        float: left;
        min-width: 185px;
        padding: 5px 0;
        margin: 2px 0 0;
        list-style: none;
        font-size: 14px;
        text-align: left;
        /* background-clip: padding-box; */
        color: #fff;
        background: #3A3C41;
        width: 60px;
        /* VIOLENCE: Largeur */
        border: 1px solid black;
      }
    
    
      /*Text color and button background when selected */
      /*Couleur du texte et background du bouton lors de la selection */
      .btn-link:focus,
      .btn-link:hover {
        /*color: #23527c;*/
        color: lightgrey;
        text-decoration: underline;
        background-color: transparent;
      }
    
      /*We remove the white bars at the top and bottom of the button on Smartphone */
      /*On supprime les barres blanches en haut et en bas du bouton sur Smartphone */
      .navbar-form {
        left: 20px;
        box-shadow: none;
        list-style: none;
      }
    }
    
    1. Placed JS ACP > Appearance > Custom Content > Custom JS
    $(document).ready(function() {
    	function generateRandomString(length) {
    
    		var text = "";
    		var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    
    		for (var i = 0; i < length; i++) {
    			text += possible.charAt(Math.floor(Math.random() * possible.length));
    		}
    
    		return text;
    	}
    	var string = generateRandomString(10);
    	$("#random_string").text(string);
    	var whichTheme = localStorage.getItem("theme");
    	var activeTheme = localStorage.getItem("activeTheme");
    	// If no theme is detected (for example, a new visitor), then set this to default
    	if (!whichTheme) {
    		// dark-mode media query matched or not
    		let matched = window.matchMedia('(prefers-color-scheme: dark)').matches;
    		//var override = getUrlParameter('override');
    
    		if (matched) {
    			// Offer the mifnight theme by default
    			whichTheme = "dark";
    			activeTheme = "/assets/customcss/dark_skin.css?version=" + string;
    			//$("link[rel=stylesheet]").attr('href' , thishref + "?version=" + string + "");
    		} else {
    			// Leave the default theme intact
    			whichTheme = "default";
    			activeTheme = "/assets/customcss/default.css?version=" + string;
    		}
    		// See if override has been enabled
    		if (whichTheme === 'default') {
    			// Sudonix is overriding operating system settings and will force dark scheme
    			activeTheme = "/assets/customcss/default.css?version=" + string;
    		}
    		if (whichTheme === 'default') {
    			// $('[component="post"]').addClass("background");
    			$('li.self-post .content:not(.isSolved [component="post/content"]').addClass("response");
    		} else {
    			// Nothing to do :)
    		}
    	}
    
    	/*$(".forum-logo").attr("src","/assets/uploads/system/sl_" + whichTheme + ".webp?version=" + string + ""); */
    	var panel = $('<li id="switcher" class="dropdown"> \
    <a title="" data-original-title="Swatch" class="navigation-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> \
    <i id="ticon" class="fa fa-light fa-swatchbook" data-content="" aria-hidden="true"></i> \
    <span class="visible-xs-inline">Swatch</span> \
    <i class="fa fa-caret-down" aria-hidden="true"></i> \
    </a> \
    <ul id="theme" class="dropdown-menu"> \
    <li><a id="default" href="#" rel="/assets/customcss/default.css">Default</a></li> \
    <li><a id="dark" href="#" rel="/assets/customcss/dark_skin.css">Dark</a></li> \
    </ul> \
    </li> \
    </div> \
    ');
    
    
    	if (whichTheme) {
    		$.get(activeTheme, function(css) {
    			$('<style type="text/css"></style>')
    				.html(css)
    				.appendTo("head");
    		});
    	} else {}
    
    	$('#main-nav').append(panel);
    
    	if (utils.findBootstrapEnvironment() === 'xs') {
    		$('#main-nav').append(panel);
    	}
    
    	$(document).ready(function() {
    
    		$("body").on("click change", "#theme li a", function() {
    			var thishref = $(this).attr('rel') + '?version=' + string;
    			$.get(thishref, function(css) {
    				$('<style type="text/css"></style>')
    					.html(css)
    					.appendTo("head");
    			});
    			console.log("Applying swatch " + thishref);
    			//location.reload();
    			var selected = $(this).attr("id");
    			var theTheme = $(this).attr("rel");
    			if (selected === 'default') {
    				localStorage.setItem("theme", selected);
    				localStorage.setItem("activeTheme", "/assets/customcss/dark_skin.css?version=" + string);
    				//location.reload();
    			} else {
    				localStorage.setItem("theme", selected);
    				localStorage.setItem("activeTheme", theTheme);
    			}
    			return false;
    		});
    	});
    });
    
    1. Made sure that both custom css and js are enabled in ACP
    2. I can confirm that when I select a skin in the switcher, it does append the style tag to <head>
    3. The custom styles are found when you inspect the page
      Screen Shot 2022-11-02 at 13.32.57 PM.png

    Issue: The following CSS rule is not showing on the page.

    body {
      background-color: var(--body);
    }
    

    I hope this helps.

  • @Teemberland can you try the site under incognito mode? I’m interested to know if this is related to caching.

  • @phenomlab tried it, CSS class is still not showing. 😞

  • @Teemberland can you remove all JS and leave the custom CSS with just the basic body class and let me know if that works?

  • @phenomlab that doesn’t work either.

  • @Teemberland ok, there’s definitely something wrong here. Are you sure there’s no errors in the console or you don’t have any script blockers running in your browser that could be interfering with execution?

  • @phenomlab correct. No console error or script blockers.
    EDIT:
    It shouldn’t matter what theme I use, correct? I’m currently using Slick theme.

    EDIT #2: I added my CSS rule to a widget. I can now see it on the page. Perhaps this is my only work around at this point.

  • @Teemberland can you switch to Persona and see if the issue exists there as well ? I know that the Slick theme does have some issues.


Did this solution help you?
Did you find the suggested solution useful? Why not buy me a coffee? It's a nice gesture, and a great way to show your appreciation 💗

  • 1 Votes
    26 Posts
    1k Views

    Yes ogproxy too is functionnal on dev

  • NodeBB: Consent page

    Solved Configure
    16
    4 Votes
    16 Posts
    559 Views

    @DownPW I still do not see any issues.

  • Heading text on NodeBB forum

    Solved Customisation
    27
    1 Votes
    27 Posts
    2k Views

    @mventures I’ve not done anything here.

  • Custom badges

    Solved Customisation
    103
    49 Votes
    103 Posts
    9k Views

    Perfect 😉

  • Podcast Share NodeBB

    Solved Configure
    15
    4 Votes
    15 Posts
    483 Views

    @cagatay You could experiment with nodebb-plugin-ns-embed but I expect the x-origin tag on the remote site to prevent playback.

  • 5 Votes
    9 Posts
    2k Views

    @phenomlab

    Very very great Mark 😉
    Thanks again, It’s perfect now !

    –> I share my code that I modified.

    I’ve added French and English comments.
    If you see things to change Mark, don’t hesitate.

    As usual, all the access paths (FA icons, logo) will have to be modified according to your architecture.

    You can also very well add/remove time slots and change welcome messages to suit your needs.

    Widgets ACP/HTML Widget Footer Logo <center> <br><br> <img id="thislogo" src="path/to/my/image"> </center> Widget Welcome Message <!-- IF loggedIn --> <div class="getUsername">, <a href="/me"><span class="username"></span></a></div> <!-- ENDIF loggedIn --> CSS

    – I added the size font-weight: 900; in the CSS because otherwise some FA icon wasn’t displayed correctly and reduce margin :

    i#thisicon { font-family: "Font Awesome 5 Free"; font-style: normal; margin-right: 8px; font-weight: 900; } .getUsername { padding-top: 20px; text-align: right; } /*Smartphone*/ /*On désactive le message de bienvenue"*/ /*We disable the welcome message"*/ @media all and (max-width: 1024px) { .getUsername { display: none; } } JAVASCRIPT // ------------------------------------------ // Welcome Message avec icône et Footer logo // Welcome Message with icon and Footer logo // ------------------------------------------ $(window).on('action:ajaxify.end', function (data) { //On récupère le username dans le DOM et on l'affiche //We retrieve the username from the DOM and display it function updateUsername() { $('.getUsername .username').text(app.user.username); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', updateUsername); } else { updateUsername(); } //On déclare les variables principales (themessage & thehours) ainsi que les variables secondaires correspondants aux plages horaires //We declare the main variables (themessage & thehours) as well as the secondary variables corresponding to the time slots var thehours = new Date().getHours(); var themessage; var wakeup = ('Good day'); var morning = ('Good morning'); var lunch = ('Bon appétit'); var afternoon = ('Good afternoon'); var drink = ('Cheers'); var evening = ('Good evening'); var night = ('Good night'); var welcome = ('Welcome'); var matched = false; //On peux ici tester le résultat du code en spécifiant une heure (!!!IMPORTANT: Commenter une fois le script testé!!!) //Here we can test the result of the code by specifying a time (!!!IMPORTANT: Comment once the script has been tested!!!) //thehours = 20 //On déclare les plages horaires avec les icones FA et les logos //We declare the time slots with FA icons and logos path if (thehours >= 0 && thehours < 6) { themessage = night; theicon = "fa-solid fa-moon"; thelogo = "/assets/customlogo/XXX.png"; } else if (thehours >= 6 && thehours < 8) { themessage = wakeup; theicon = "fa-solid fa-mug-hot"; thelogo = "/assets/customlogo/XXX.png"; } else if (thehours >= 8 && thehours < 12) { themessage = morning; theicon = "fa-solid fa-sun"; thelogo = "/assets/customlogo/XXX.png"; } else if (thehours >= 12 && thehours < 13) { themessage = lunch; theicon = "fas fa-hamburger"; thelogo = "/assets/customlogo/XXX.png"; } else if (thehours >= 13 && thehours < 16) { themessage = afternoon; theicon = "fa-solid fa-sun"; thelogo = "/assets/customlogo/XXX.png"; } else if (thehours >= 16 && thehours < 18) { themessage = welcome; theicon = "fa-solid fa-rocket"; thelogo = "/assets/customlogo/XXX.png"; } else if (thehours >= 18 && thehours < 19) { themessage = drink; theicon = "fa-solid fa-wine-glass"; thelogo = "/assets/customlogo/XXX.png"; } else if (thehours >= 19 && thehours < 20) { themessage = lunch; theicon = "fas fa-pizza-slice"; thelogo = "/assets/customlogo/XXX.png"; } else if (thehours >= 20 && thehours < 24) { themessage = evening; theicon = "fa-solid fa-tv"; thelogo = "/assets/customlogo/XXX.png"; } // Si la page active est un topic, on désactive/cache le message de bienvenue // If the active page is a topic, we deactivate/hide the welcome message if (window.location.href.indexOf("topic") > -1) { console.log("This is a topic, so hide the user welcome message"); $('#thisuser').hide(); } // Sinon, on affiche le message en fonction, l'icone FA et son emplacement (prepend) // Otherwise, we display the message in function, the FA icon and its location (prepend) else { $('.getUsername').prepend("<i id='thisicon' class='" + theicon + "'></i>" + themessage); $("#thislogo").attr("src", thelogo); //$('.getUsername').prepend("<img id='thisicon' src='" + thelogo + "'></>" + themessage); } });
  • 0 Votes
    7 Posts
    726 Views

    @downpw ooops. Forgot that. Thanks for adding.

  • 24 Votes
    112 Posts
    13k Views

    @DownPW as discussed in PM

    Seems to have been solved with the new JS code that you added allowing the version CSS file change!!

    Cache problem therefore with the JS of the Switcher theme

    Based on this, I will close this thread and reference
    https://sudonix.com/topic/207/nodebb-help-for-my-custom-css/27