Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
1.7k views
in Themes by

Hello ever1!

I have problem. How can i add script cookien on my Q&A website? I need put this stylesheet to my <head> section:

<link rel=”stylesheet”
href=”http://twoja-strona.pl/cookies/divante.cookies.min.css
type=”text/css” media=”all” />

and this:

<script type=”text/javascript”
src=”http://twoja-strona.pl/cookies/divante.cookies.min.js“></script>
<script>window.jQuery.cookie || document.write(‘<script
src=”http://twoja-strona.pl/cookies/jquery.cookie.min.js“></script>’)</script>
<script type=”text/javascript”>
$.divanteCookies.render({
privacyPolicy : true,
cookiesPageURL : ‘http://…/’
});
</script>

to my <body> section. Please help me... i dont know where i must put this.

1 Answer

+1 vote
by

Use an advanced theme. Add to your qa-theme.php:

    function head_script() {
        qa_html_theme_base::head_script();
        $this->output('MYSCRIPT ...');
    }

Cheers,
Kai

by
Ok, i put this:

function head_script() {
        qa_html_theme_base::head_script();
        $this->output('<link rel=”stylesheet”
href=”http://xxxxx.com/divante.cookies.min.css”
type=”text/css” media=”all” />');
}

function head_script() {
        qa_html_theme_base::head_script();
        $this->output('<script type=”text/javascript”
src=”http://xxxx.com/divante.cookies.min.js“></script>
<script>window.jQuery.cookie || document.write(‘<script
src=”http://xxxxxx.com/jquery.cookie.min.js“></script>’)</script>
<script type=”text/javascript”>
$.divanteCookies.render({
privacyPolicy : true,
cookiesPageURL : ‘http://xxxx.com’
});
</script>');
}

And i have this error:
Fatal error: Cannot redeclare head_script() (previously declared in /usr/home/xxx/domains/xxxx.com/public_html/qa-theme/Snow/qa-theme.php:3) in /usr/home/xxx/domains/xxxxx.com/public_html/qa-theme/Snow/qa-theme.php on line 21

Line 3 is:
qa_html_theme_base::head_script();

and 21 is:
}
by
The problem is you have declared the function twice in qa-theme.php. Just do it once like that:

function head_script() {
    qa_html_theme_base::head_script();
    $this->output('<link rel="stylesheet" href="http://xxxxx.com/divante.cookies.min.css" type="text/css" media="all" />');
    $this->output('<script type="text/javascript" src="http://xxxx.com/divante.cookies.min.js“></script>
    <script>window.jQuery.cookie || document.write(‘<script src="http://xxxxxx.com/jquery.cookie.min.js“></script>')</script>
    <script type="text/javascript"> $.divanteCookies.render({ privacyPolicy : true, cookiesPageURL : ‘http://xxxx.com' }); </script>');
}
by
It work thanks!
...