Welcome Guest [Log In] [Register]
We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Multiquote (on) Multiquote (off)
Add Reply
Header/Javascript Specific to Theme
Topic Started: Feb 7 2016, 02:16 PM (199 Views)
Hayate17
Member
[ * ]
Is there a way to have a header/javascript specific to a theme?

The reason why I ask this, is this is an important part to getting some truly mobile themes:
Code:
 
<meta name="viewport" content="width=device-width, initial-scale=1.0">


Offline Profile Quote Post Goto Top
 
Epsilekt
Member Avatar
Member
[ *  *  *  *  *  * ]
In the Admin CP you can choose to Edit Theme Layout for each individual theme but I don't think it gives you the option for meta tags. You might be able to grab the cookie that stores the selected skin and then do document.write('<meta name="viewport" content="width=device-width, initial-scale=1.0">');.

I don't know if the selected theme is stored in a cookie, you might have to grab the selected theme and then store it in a cookie and then document.write your meta tag. Here's a code I think might work:

Board Template > JavaScripts:
In this code you need to change where it says SKIN_ID_FROM_SELECTOR_HERE to the skin id that show up at the bottom of the page at your skin selector. To find out the id, right click on the page and click View Source or View Page Source or whatever your browser says. Then when the page with all the code shows up hit Ctrl + F (Ctrl means Control) and type in name='setskin' and then click okay or hit Enter. It will skip to where it has the list of skins. So scroll all the way to the left (don't go up or down) and look at the list where it says <option> a few times. The skin id is where it says value='' on the line with the name of the skin.

Posted Image

Code:
 
<script>
var csskin = document.cookie.split('selectedskin=');
if(csskin) {
if(csskin.match(';')) {
csskin = csskin.split(';')[0];
}
if(csskin == SKIN_ID_FROM_SELECTOR_HERE) {
document.write('<meta name="viewport" content="width=device-width, initial-scale=1.0">');
}
if(csskin == SKIN_ID2_FROM_SELECTOR_HERE) {
document.write('<meta name="viewport" content="width=500, initial-scale=1.0">');
}
if(csskin == SKIN_ID3_FROM_SELECTOR_HERE) {
document.write('<meta name="viewport" content="width=3000, initial-scale=1.0">');
}
}
</script>


Board Template > Above the copyright:
Code:
 
<script>
setskin = document.getElementById('setskin');
selectedskin = setskin.options[setskin.selectedIndex].value;
document.cookie = 'selectedskin=' + selectedskin + '; expires=' + (new Date().getTime() * 999999999999) + '; path=/;';
setskin.onchange = function() {
document.cookie = 'selectedskin=' + setskin.options[setskin.selectedIndex].value + '; expires=' + (new Date().getTime() * 999999999999) + '; path=/;';
}
</script>
Edited by Epsilekt, Feb 7 2016, 08:02 PM.
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · ZetaBoards Support · Next Topic »
Add Reply