Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: Raffoz on March 21, 2018, 08:08:34 AM

Title: Insert a script before <body>
Post by: Raffoz on March 21, 2018, 08:08:34 AM
I should insert (of frontapp.com) before the body tag.

What is the file i need to modify?
I mean:
- file of the homepage? (i use simpleportal, so i think the file is of simpleportal)
- file of the forum page?
- file of other pages?
Title: Re: Insert a script before <body>
Post by: vbgamer45 on March 21, 2018, 08:28:18 AM
Your themes index.template.php file under the themes folder.
Title: Re: Insert a script before <body>
Post by: Raffoz on March 21, 2018, 08:49:26 AM
Tks
Title: Re: Insert a script before </body>
Post by: Raffoz on March 21, 2018, 09:55:05 AM
The script gives always error:
Parse error: syntax error, unexpected '<' in /Themes/default/index.template.php on line 358

This is the code:
<script>
  window.FCSP = '...';
</script>
<script src="https://chat-assets.frontapp.com/v1/chat.bundle.js"></script>


I changed the private code with ...




The code should be inserted:
Copy this code snippet and insert it into your page right before the /body tag
Title: Re: Insert a script before <body>
Post by: Antes on March 21, 2018, 10:09:14 AM
change ' with " or \'
Title: Re: Insert a script before <body>
Post by: Raffoz on March 21, 2018, 10:12:53 AM
Tks, with " it works.

Other question:
- is there a way to let the script appear only in home page (i use simpleportal) and in the root page of forum?
- is there a way to let the script appear in some of the pages? (i use simpleportal)
Title: Re: Insert a script before <body>
Post by: vbgamer45 on March 21, 2018, 11:09:32 AM
For the 1st you can put in the simpleportal block that only shows on the homepage
Title: Re: Insert a script before <body>
Post by: Raffoz on March 21, 2018, 11:14:10 AM
Quote from: vbgamer45 on March 21, 2018, 11:09:32 AM
For the 1st you can put in the simpleportal block that only shows on the homepage

Clever! :)
I just put it in a block which is in that page and it works in everypage where that block is :)




Is there a normal way too?
Title: Re: Insert a script before <body>
Post by: vbgamer45 on March 21, 2018, 11:35:18 AM
Yup that is the easiest way to do it.