Welcome, Guest. Please login or register.
Did you miss your activation email?
May 25, 2012, 05:45:19 AM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
155476 Posts in 21708 Topics by 7734 Members
Latest Member: rofroodoOvego
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: Clock needed. Use module, snippet or droplets?  (Read 622 times)
Peter R

Offline Offline

Posts: 17


« on: January 30, 2009, 08:55:41 AM »

Hello you all,

I have a three-column page, and in the top of the right upper column, I want to show time and date. I found a small piece of js to do this. For installing I need to change <body> to <body onLoad="show_clock()">. In the body, where timemust be shown, add the script call:
Code:
<script language="javascript" src="liveclock.js"></script>
and place the file liveclock.js in the root.

My question is, how do I implement it using the WB way. The change of <body> can be done in de template file. I can copy liveclock.js into the root. But now for script call, how should I do that? I am almost sure that I don’t have to create a module fore it, because a module is for adding big functionality with front end and back end adding’s/possibilities. But it is still not clear for me what the difference is between a snippet and a droplet. And does this work with JS? In an other treat, I am also asking for help implementing a nice tab extension that needs an css file, JS file and html adaptations. I have trouble getting this working, and I think it has something to do with files that somehow cannot find each other.

Have fun, just like me.
Peter
Logged
pcwacht
AddOn Development
*
Offline Offline

Posts: 2856



WWW
« Reply #1 on: January 30, 2009, 10:56:09 AM »

difference from a snippet and a droplet

pfew, good question Wink

droplet is much more an enhanced form of a snippet and can be more easely used IN wysiywg content.


In your case, if you need the clock on every page embed it in the template seems easiest to do.

Have fun!
John
Logged

http://www.ictwacht.nl = Dutch ICT info
http://www.pcwacht.nl = My first
both still work in progress, since years.....
kweitzel
Forum administrator
*****
Offline Offline

Posts: 6975


WWW
« Reply #2 on: January 30, 2009, 11:16:27 AM »

Your current code looks for the JS in the same path where the page is. You should place it in a central location and then call it with the WB Variables for the location you placed the file.

cheers

Klaus
Logged

WebsiteBaker Org e.V. - for WebsiteBaker

Peter R

Offline Offline

Posts: 17


« Reply #3 on: January 30, 2009, 11:25:23 AM »

@John
> difference from a snippet and a droplet
> pfew, good question 
Tell me about it

> droplet is much more an enhanced form of a snippet and can be more
> easely used IN wysiywg content.
Oke, I’m am getting it, a little bit, maybe.
For starters, a module is on top and a snippet on bottom. Maybe I should take a closer look to the code of the given modules and so on.

>In your case, if you need the clock on every page embed it in
> the template seems easiest to do.
And that is helping me a lot!
Correct me if I am wrong: put the code in the index.php of the template I am using. The extra CSS files needed should be in the template file too, together with the CSS files used for the template. JS script files, called in index.php should be in the root.
Is this the way to go?

>Have fun!
Thanks, you too.

@Klaus
>Your current code looks for the JS in the same path where the page is.
>You should place it in a central location and then call it with the WB
>Variables for the location you placed the file.
I am using WB for some weeks now, so I a not sure if I know what you mean. In I add a call for a js script in index.php of my template, with:
<script language="javascript" src="liveclock.js"></script>
and this file is in the same root with WB, the code will not find it? If that is the case, where should I put liveclock.js?

So I guess this is way:
http://www.websitebaker2.org/forum/index.php/topic,12647.0.html
is not working?

>cheers
Thanks, proost.
Logged
ruebenwurzel
WebsiteBaker Org e.V.

Offline Offline

Posts: 7972



WWW
« Reply #4 on: January 30, 2009, 11:55:03 AM »

Hello,

you should place the liveclock.js within your template and call it in the index.php of your template with src="<?php echo TEMPLATE_DIR; ?>/livelock.js". This way you can be shure the script works on all pages and subpages.

Matthias
Logged
kweitzel
Forum administrator
*****
Offline Offline

Posts: 6975


WWW
« Reply #5 on: January 30, 2009, 11:58:22 AM »

@Klaus
>Your current code looks for the JS in the same path where the page is.
>You should place it in a central location and then call it with the WB
>Variables for the location you placed the file.
I am using WB for some weeks now, so I a not sure if I know what you mean. In I add a call for a js script in index.php of my template, with:
<script language="javascript" src="liveclock.js"></script>
and this file is in the same root with WB, the code will not find it? If that is the case, where should I put liveclock.js?

Matthias gave my answer already ... further explanation: If you just place the source like you did, it will always look for it relative to the pagelocation while Matthias gave you the variable which is translated by WB into a fixed location.

cheers

Klaus
Logged

WebsiteBaker Org e.V. - for WebsiteBaker

Peter R

Offline Offline

Posts: 17


« Reply #6 on: January 30, 2009, 02:35:11 PM »

Yes it is working!
It took some time to find out I was calling for livelock.js instead of liveclock.js.
Now I can cleanup my index.php, and start again with the tab issue from my other topic.

Thanks again guys!
Logged
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!