adding a script part

Started by glennmckenna, June 10, 2013, 10:20:20 AM

Previous topic - Next topic

glennmckenna

i would like a hand on how to add this
     <script type="text/javascript" src="scripts/jquery-1.9.0.min.js"></script>
    <script type="text/javascript" src="scripts/jquery.nivo.slider.js"></script>
    <script type="text/javascript">
    $(window).load(function() {
        $('#slider').nivoSlider();
    });
    </script>

to this

<?php

$ssi_theme
= 4;
require_once(
'forum/SSI.php');
$context['page_title_html_safe'] = 'home';
if (empty(
$context['html_headers']))
 
$context['html_headers'] = '';

$context['html_headers'] .= '<link href="css/main.css" rel="stylesheet" type="text/css">';
$context['html_headers'] .= '<link href="css/nivo-slider.css" rel="stylesheet" type="text/css">';


template_header();

echo
'

        <div class="slider-wrapper theme-default">
           <div id="slider" class="nivoSlider">
               <img src="images/toystory.jpg" data-thumb="images/toystory.jpg" alt="" />
               <a href="http://dev7studios.com"><img src="images/up.jpg" data-thumb="images/up.jpg" alt="" title="This is an example of a caption" /></a>
               <img src="images/walle.jpg" data-thumb="images/walle.jpg" alt="" data-transition="slideInLeft" />
               <img src="images/nemo.jpg" data-thumb="images/nemo.jpg" alt="" title="#htmlcaption" />
           </div>
           <div id="htmlcaption" class="nivo-html-caption">
               <strong>This</strong> is an example of a <em>HTML</em> caption with <a href="#">a link</a>.
           </div>
       </div>


<a class="twitter-timeline"  href="https://twitter.com/aulnaynatation" data-widget-id="282847438883135488">Tweets de @aulnaynatation</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>

<div class="menu-right">
<div class="menu-header" style="width: 300px"><strong>who are we</strong>
<div style="margin-bottom:10px; width: 300px;" class="menu-body">
summer swimming club affiliated<br>to the French Swimming
Federation.<br>We have many activities some including all the
family we welcome swimmers of all levels from<br>beginners to
competitive including<br>non swimmers as these lessons are<br>
also provided form six years plus,<br>we are a part of the
French National swimming school discover all the benefits,
enjoyment, fitness, discipline, for everyone of swimming. <br>&nbsp;
</div>
</div>
<div class="menu-header" style="margin-top:15px"><strong>weather<strong>
<div class="menu-body">
<center>
<div id="c_c12b608b55173f57f58a42ecbafb8113" class="alto">
<h2 style="color: #000000; margin: 0 0 3px; padding: 2px; font: bold 13px/1.2 Verdana; text-align: center;"><a href="http://www.meteorama.fr/m%C3%A9t%C3%A9o-aulnay.html" style="color: #000000; text-decoration: none;">meteo a Aulnay</a></h2></div><script type="text/javascript" src="http://www.meteorama.fr/widget/widget_loader/c12b608b55173f57f58a42ecbafb8113"></script>
</center>
</div>
</div>
</div>
<div style="margin:25px 10px" align="center">
<a target="_blank" href="http://charente-maritime.fr/CG17/jcms/j_5/accueil">
<img src="images/CG 17.jpg" alt="charente marentime" class="logo"/></a>
<a target="_blank" href="http://www.cnds.info/">
<img src="images/Etat CNDS.JPG" alt="cnds" class="logo"/></a>
<a target="_blank" href="http://www.cdc-aulnay.fr/">
<img src="images/logo cdc.jpg" alt="conton de aulnay" class="logo"/></a>
<a target="_blank" href="http://www.ffnatation.fr/webffn/index.php">
<img src="images/logo_ffn.png" alt="ffn" class="logo"/></a>
<a target="_blank" href="http://www.poitou-charentes.fr/accueil.html;jsessionid=853A0918DE3F77AA12AB64DCC193FA02">
<img src="images/logo-rpc-espritequip.JPG" alt="" class="logo"/></a>
<a target="_blank" href="http://charentemaritime.ffnatation.fr/script/index.php">
<img src="images/logo FFN issi.gif" alt="logo FFN charente maritime" class="logo" /></a>
<a target="_blank" href="http://poitoucharentes.ffnatation.fr/script/index.php">
<img src="images/logo ffn poitou charente.jpg" alt="logo ffn poitou charente" class="logo" /></a>
</div>

'
;
 
template_footer() ;

?>

the script will be used to run my nivo-slider


glennmckenna


kat

Depends, really, dunnit? ;)

What page(s) do you want it on? What position, on the page? Those kinda things.

When I do things, like that, I tend to use the ol' tried and trusted "Trial and error" method. (Keeping copies of the original files I edit, as backups, obviously)

If you want it on all pages, you'll need to put the code in index.template.php. If you want it on all themes, it'll need to go in each theme's index.template.

What I tend to do, is make a single file, for that kinda thing, and call it from each template, using the il' "include" statement, so I don't have to bung the whole code in every template. Something like:

include 'nivo.php';

The file "nivo.php" would need to be in the forum's root, unless you specify otherwise.

Kays

If it needs to go into the head of the page. Add it to $context['html_headers']

Otherwise, echo it out in the location it should be.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods


glennmckenna

i would like the slider to be postioned where either of the arrows go (above or bellow the select language part)
and i only want it on that page
https://www.dropbox.com/s/to6eavfo1c5wtnl/site%20mod.png

if i wanted to fetch it from another page would i be able to echo it ?

kat

Hmmm... Not a standard SMF homepage. Is that a portal? If so, you could just create a php block, with that.

glennmckenna

Quote from: K@ on June 10, 2013, 02:06:16 PM
Hmmm... Not a standard SMF homepage. Is that a portal? If so, you could just create a php block, with that.
no it not a portal
here is the code for it

<?php

$ssi_theme
= 4;
require_once(
'forum/SSI.php');
$context['page_title_html_safe'] = 'home';
if (empty(
$context['html_headers']))
 
$context['html_headers'] = '';

$context['html_headers'] .= '<link href="main.css" rel="stylesheet" type="text/css">';



template_header();

echo
'


<a class="twitter-timeline"  href="https://twitter.com/aulnaynatation" data-widget-id="282847438883135488">Tweets de @aulnaynatation</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>

<div class="menu-right">
<div class="menu-header" style="width: 300px"><strong>who are we</strong>
<div style="margin-bottom:10px; width: 300px;" class="menu-body">
summer swimming club affiliated<br>to the French Swimming
Federation.<br>We have many activities some including all the
family we welcome swimmers of all levels from<br>beginners to
competitive including<br>non swimmers as these lessons are<br>
also provided form six years plus,<br>we are a part of the
French National swimming school discover all the benefits,
enjoyment, fitness, discipline, for everyone of swimming.
</div>
</div>
<div class="menu-header" style="margin-top:15px"><strong>weather<strong>
<div class="menu-body">
<center>
<div id="c_c12b608b55173f57f58a42ecbafb8113" class="alto">
<h2 style="color: #000000; margin: 0 0 3px; padding: 2px; font: bold 13px/1.2 Verdana; text-align: center;"><a href="http://www.meteorama.fr/m%C3%A9t%C3%A9o-aulnay.html" style="color: #000000; text-decoration: none;">meteo a Aulnay</a></h2></div><script type="text/javascript" src="http://www.meteorama.fr/widget/widget_loader/c12b608b55173f57f58a42ecbafb8113"></script>
</center>
</div>
</div>
</div>
<div style="margin:25px 10px" align="center">
<a target="_blank" href="http://charente-maritime.fr/CG17/jcms/j_5/accueil">
<img src="../images/CG 17.jpg" alt="charente marentime" class="logo"/></a>
<a target="_blank" href="http://www.cnds.info/">
<img src="../images/Etat CNDS.JPG" alt="cnds" class="logo"/></a>
<a target="_blank" href="http://www.cdc-aulnay.fr/">
<img src="../images/logo cdc.jpg" alt="conton de aulnay" class="logo"/></a>
<a target="_blank" href="http://www.ffnatation.fr/webffn/index.php">
<img src="../images/logo_ffn.png" alt="ffn" class="logo"/></a>
<a target="_blank" href="http://www.poitou-charentes.fr/accueil.html;jsessionid=853A0918DE3F77AA12AB64DCC193FA02">
<img src="../images/logo-rpc-espritequip.JPG" alt="" class="logo"/></a>
<a target="_blank" href="http://charentemaritime.ffnatation.fr/script/index.php">
<img src="../images/logo FFN issi.gif" alt="logo FFN charente maritime" class="logo" /></a>
<a target="_blank" href="http://poitoucharentes.ffnatation.fr/script/index.php">
<img src="../images/logo ffn poitou charente.jpg" alt="logo ffn poitou charente" class="logo" /></a>
</div>

'
;
 
template_footer() ;
?>


if not wouldn't there be a way of loading it from another page without using iframe

kat

I'd be tempted to stick it after the:

template_header();

echo '


and before the:

<a class="twitter-timeline"  href="https://twitter.com/aulnaynatation" data-widget-id="282847438883135488">Tweets de @aulnaynatation</a>

You might need another echo, after it.

As I said, it's probably "Trial and error" time, coz I obviously can't test it. :)

glennmckenna

Quote from: K@ on June 10, 2013, 02:33:09 PM
I'd be tempted to stick it after the:

template_header();

echo '


and before the:

<a class="twitter-timeline"  href="https://twitter.com/aulnaynatation" data-widget-id="282847438883135488">Tweets de @aulnaynatation</a>

You might need another echo, after it.

As I said, it's probably "Trial and error" time, coz I obviously can't test it. :)
this is wat i got
Parse error: syntax error, unexpected '}', expecting ',' or ';' in C:\xampp\htdocs\usaulnaynatation\home.php on line 22

kat

Shame. Well, as I said, I can't check these things, coz I don't have them on my site. So, you're gonna need to keep a copy of the original file, as a backup, and try a few things out.

Sorry. But, I really can't suggest anything, apart from that.

Did you try adding an extra  echo ' after the code, as I suggested?

glennmckenna

Quote from: K@ on June 10, 2013, 04:04:36 PM
Shame. Well, as I said, I can't check these things, coz I don't have them on my site. So, you're gonna need to keep a copy of the original file, as a backup, and try a few things out.

Sorry. But, I really can't suggest anything, apart from that.

Did you try adding an extra  echo ' after the code, as I suggested?
year tried that to
isn't there something i could use to replace the script part ?

also by my guess this is cause the problems
    $(window).load(function() {
        $('#slider').nivoSlider();
    })
    </script>

but i can't remove that part

Herman's Mixen

just change the part

$('#slider').nivoSlider();


into


$("#slider").nivoSlider();


with javascripts and single quote(s) usually break things... so better use double quote(s) ;)
Met vriendelijke groet, The Burglar!

 House Mixes | Mixcloud | Any Intelligent fool can make things bigger, more complex, and more violent.
It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Albert Einstein

Former Godfather of our dutch community ;)

kat


glennmckenna

i doesn't want to know
Parse error: syntax error, unexpected ''#slider'' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ';' in C:\xampp\htdocs\usaulnaynatation\home.php on line 21

Herman's Mixen

can you attach the file here ?! so i can take a look into it ?

Edit : you did use double single quotes ' ' instead of the " double quotes
Met vriendelijke groet, The Burglar!

 House Mixes | Mixcloud | Any Intelligent fool can make things bigger, more complex, and more violent.
It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Albert Einstein

Former Godfather of our dutch community ;)

glennmckenna

#17
Quote from: The Burglar! on June 10, 2013, 04:34:17 PM
can you attach the file here ?! so i can take a look into it ?

Edit : you did use double single quotes ' ' instead of the " double quotes
euuu no compent  ;D

any way we are now getting somewere
https://www.dropbox.com/s/r3lpmmef8sebset/site%20mod1.png
the only proble is that i don't have the arrows or the dots

if you want the scripts just ask

edit:
take that back stupid me forgot a line for the css

Advertisement: