solved jquery to exclude code from running on index page

soaringeagle
@soaringeagle
6 years ago
3,304 posts
adsense has a new auto ads feature that works absolutely amazing all over the site (double income) but on the front page messes up the activity feed
they have url rules which should allow you to set what adsare diplayed based on url, however being a new feature it doesn't seem to accept wildcard urls
so i wanted a workaound that can be placed in meta.tpl
that would run the code on every page, except the index page
been trying for a week now to work with the url rules and have it function right

so..to clarify
if url = /
do nothing
else
run javascript code

i found many ways to try it in google searces none seemed to work right


--
soaringeagle
head dreadhead at dreadlocks site
glider pilot student and member/volunteer coordinator with freedoms wings international soaring for people with disabilities

updated by @soaringeagle: 07/02/18 09:39:49AM
michael
@michael
6 years ago
7,714 posts
You can tell what the URI of the page is on the {$_post['uri']} variable. or it maybe {$_post['_uri']}, not sure. put {debug} in to get the exact spelling of the variable.
soaringeagle
@soaringeagle
6 years ago
3,304 posts
well.. what i want is a js to run sitewide, except on the front page
guess a smarty if else
using $jamroom_url

ok so would it be something like
if {$_post['_uri']} == $_jamroom_url
(nothing)
else
javascript here
/if
guess makes more sense to do it that way then using jquery to inject it
but syntax aside that logic would work right?
(too tired to think it through right now)


--
soaringeagle
head dreadhead at dreadlocks site
glider pilot student and member/volunteer coordinator with freedoms wings international soaring for people with disabilities
douglas
@douglas
6 years ago
2,790 posts
You could simply set a variable in your index.tpl and then check for it where your javascript is located.

Top of index.tpl
{$newvariable="something"}

Check for the variable:
{if !isset($newvariable) || $newvariable != 'something'}
Java script goes here...
{/if}

Hope this helps!


--

Douglas Hackney
Jamroom Team - Designer/Developer/Support
FAQ-Docs-Help Videos
soaringeagle
@soaringeagle
6 years ago
3,304 posts
brilliant


--
soaringeagle
head dreadhead at dreadlocks site
glider pilot student and member/volunteer coordinator with freedoms wings international soaring for people with disabilities
soaringeagle
@soaringeagle
6 years ago
3,304 posts
hmm id not seem to have the desired effect..codes still running on every page
index.tpl
{$newvariable="indexpage"}
{assign var="selected" value="home"}
{* Include Header File *}
{jrCore_include template="header.tpl"}
meta.tpl
{if !isset($newvariable) || $newvariable != 'indexpage'}
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({
          google_ad_client: "ca-pub-1147632186808710",
          enable_page_level_ads: true
     });
</script>
{/if}

is it cause i use sitebuilder should the variable go somewhere else?


--
soaringeagle
head dreadhead at dreadlocks site
glider pilot student and member/volunteer coordinator with freedoms wings international soaring for people with disabilities
soaringeagle
@soaringeagle
6 years ago
3,304 posts
got it it was in the sitebuilder templates


--
soaringeagle
head dreadhead at dreadlocks site
glider pilot student and member/volunteer coordinator with freedoms wings international soaring for people with disabilities
SteveX
SteveX
@ultrajam
6 years ago
2,584 posts
Dammit, I've lost money on this not being a 30+ post thread :(


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)

Tags