News:

Wondering if this will always be free?  See why free is better.

Main Menu

Problem adding Alexa code on SMF 2.0.8 Forum

Started by gxm13, August 05, 2014, 06:00:31 PM

Previous topic - Next topic

gxm13

Hello , I've recently encountered some errors when trying to add the Alexa code to my index.php file .

<!-- Start Alexa Certify Javascript -->
<script type="text/javascript">
_atrk_opts = { atrk_acct:"gcoTj1a0Sn00if", domain:"l2funfactory.com",dynamic: true};
(function() { var as = document.createElement('script'); as.type = 'text/javascript'; as.async = true; as.src = "https://d31qbv1cthcecs.cloudfront.net/atrk.js"; var s = document.getElementsByTagName('script')[0];s.parentNode.insertBefore(as, s); })();
</script>
<noscript><img src="https://d5nxst8fruw4z.cloudfront.net/atrk.gif?account=gcoTj1a0Sn00if" style="display:none" height="1" width="1" alt="" /></noscript>
<!-- End Alexa Certify Javascript -->


I even tried adding /* at the start and */ at the end so it wont affect my forum . But unfortunately Alexa says that they can't see my code on the forum after they scan it .

I would really love assistance because it seems that only this problem occurs on php.

I have also attached the index.php file .

Thank you in advance .

NanoSector

Hi gxm13, welcome to SMF!

You should add this code to Themes/{yourtheme}/index.template.php for it to work, Index.php won't work.
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

gxm13

Ok , I'm sorry , a bit newbie to this .

I've added it to index.template.php .

Also attached it as well .

When I add the code I get this error .

Template Parse Error!

It seems something has gone sour on the forum with the template system. This problem should only be temporary, so please come back later and try again. If you continue to see this message, please contact the administrator.

You can also try refreshing this page.


Can you please assist?

NanoSector

My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

gxm13

Quote from: NanoSector on August 05, 2014, 06:37:19 PM
Try this file.

Wow it worked , thank you .

Can you please explain in noob language what was the actual problem ?

NanoSector

When you want to output anything in PHP, you use echo: http://php.net/manual/en/function.echo.php

However, echo has a small problem - it doesn't like quotes.

So, something like this:
echo 'This isn't right!';
Will cause issues, because of "isn't". It has a quote into it, and echo doesn't like quotes.

What do we do about that? You should escape it. You escape quotes with \. So, the previous piece of code will work if we use it like this:
echo 'This isn\'t right!';

That's the two main things you forgot to do - but you'll learn from errors :)
I made this same mistake multiple times when I first started out.
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

gxm13

Wow , thank you so much .
That was really helpful :)

Advertisement: