Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 20 Nov 2016, 16:33
David Karol David Karol is offline
 
Join Date: Jan 2011
CSS for Template ID verus Page ID

When editing templates based on page ID (.page10 as example), only that specific page item is affected. Other pages that share the same templates are not.

Is there a quick and easy way to hit a specific template instead, via CSS?
Reply With Quote
  #2  
Old 21 Nov 2016, 03:23
Replicant's Avatar
Replicant Replicant is offline
 
Join Date: Sep 2014
Real name: Mel
You can with javascript/jquery. There is a javascript object on every page called pageData. The pagetemplateid is in that array. You can find the pagetemplate id by right click, view source, find (Ctrl-f) pagetemplateid. So if you do something like this for pagetemplate 93


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

It would set the background css attribute red for the body tag. You can use #your-id or .your-class in place of body and change the css attribute to whatever you want to set.
__________________
VB5 mods - RepliClock VB4 mods - Member Online Status
Reply With Quote
  #3  
Old 23 Nov 2016, 04:13
David Karol David Karol is offline
 
Join Date: Jan 2011
Hi,

Thanks for replying. Are java queries like this able to be executed from inside additional.css? I added the code below, but don't see the equivalent result with avoiding the templateid check.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

On top of this, should multiple items be allowed in as below:
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

versus
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #4  
Old 23 Nov 2016, 11:17
Replicant's Avatar
Replicant Replicant is offline
 
Join Date: Sep 2014
Real name: Mel
No. additional.css is just for css. Easiest way to add the script is in an ad module. Open site-builder, drag the ad module down on the page, paste the code above in the ad module editor enclosed in script tags. You can also add the code via template hook if you want it on every page.



Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


And on your second question, you almost had it in example two. The braces go between the parenthesis.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
VB5 mods - RepliClock VB4 mods - Member Online Status

Last edited by Replicant; 23 Nov 2016 at 11:23.
Reply With Quote
  #5  
Old 24 Nov 2016, 01:58
noypiscripter's Avatar
noypiscripter noypiscripter is offline
 
Join Date: Aug 2013
It would be easier for the script to simply add a css class in the body tag based on the template id. Then use that class to style in css whatever elements on the page you want to style.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Then in CSS:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
Glenn Vergara, an ex-vB Developer, now a vB Mod Developer

GIPHY for vB5 | AutoLinker | Video Attachments Player | New Registered Users Module | Clear System Cache Cron | DragNDrop Upload | Topic AJAX AutoUpdate | Force Read Topic
Reply With Quote
  #6  
Old 25 Nov 2016, 00:40
David Karol David Karol is offline
 
Join Date: Jan 2011
I added below code to a hook, run from header_head.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

This results in an browser console error: "Cant find variable $". I tried to enclose everything in (function($)), which led to no more error. With that though, the pagetemplateID never made it into page source.

What does work is amending header template, line 146 as below:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #7  
Old 25 Nov 2016, 22:10
noypiscripter's Avatar
noypiscripter noypiscripter is offline
 
Join Date: Aug 2013
Because jQuery is not available at that point yet.

Use header_after_body_begin hook location with this script.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
Glenn Vergara, an ex-vB Developer, now a vB Mod Developer

GIPHY for vB5 | AutoLinker | Video Attachments Player | New Registered Users Module | Clear System Cache Cron | DragNDrop Upload | Topic AJAX AutoUpdate | Force Read Topic
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 14:23.

Layout Options | Width: Wide Color: