Welcome, Guest. Please login or register.
Did you miss your activation email?
May 25, 2012, 05:41:22 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: How show some JS, PHP and html code in index only?  (Read 786 times)
Peter R

Offline Offline

Posts: 17


« on: January 29, 2009, 01:04:57 PM »

I am working with WB for some weeks now, and I really like it. I use it as a portal for a scrapbook site. On the home page, I want to show some pictures and information out of the shop, photo gallery and forum. I can easily write some code to retrieve all information and pictures needed I want to show. It will be completely working on itself, so no setting via admin is necessary. My question is how do I show this on the home page, and only on the homepage? I need JS, PHP and some html for this. I tried to add a page with type “code”, but that is not really what I am looking for.

What is the way to go for this?
Logged
mr-fan

Offline Offline

Posts: 1556


WWW
« Reply #1 on: January 29, 2009, 02:59:43 PM »

ok hi peter,

for best imput of JS php or html you can use the code2 module

here:

http://www.websitebakers.com/pages/admin/core-replacements/code-2.php

or for input of JS in the head of your template you can make it dynamik with the page headline in the wb options and a call in the template like this

Code:
<?php 
// this allows to add custom information to the head section of your template (WB-->Settings-->Website Header)
echo WEBSITE_HEADER
?>

i use this for eg with short js scripts in the head of a index...

but this works only if you don't use the website header for something else...like the normal use in your template...

regards martin
Logged

 
Peter R

Offline Offline

Posts: 17


« Reply #2 on: January 29, 2009, 04:33:44 PM »

Thanks for the response!

I tried code2, but it is not working like I planned.
And I have no Idea what is wrong.
Checkout:
http://www. digitop3.com/pages/test3.php
and:
http://www. digitop3.com/test.php

The first one is via code2.
The second, I copied the the code my browser was making of the first example in a php file.

If I look to what my browser is making of both files, it looks the same.

 huh
Logged
mr-fan

Offline Offline

Posts: 1556


WWW
« Reply #3 on: January 29, 2009, 06:55:18 PM »

hi,

can you post whatt you have put in the code 2 page and what you have put in your index.php....

with the # code button so it is possible to reconstruct your problem...Wink

rgds martin
Logged

 
Peter R

Offline Offline

Posts: 17


« Reply #4 on: January 29, 2009, 08:28:16 PM »

Hi Martin

The code I am trying to implement can be found on:
http://www. digitop3.com/example.html
To get this nice piece of code working, I had to put the example.css and tabber.js file in the root.

For implementing this code in WB, I also copied example.css in the template folder, where also the css file for my template can be found. To be sure, I also copied tabber.js to that location.

In the head of index.php, I added:
Code:
<script type="text/javascript" src="tabber.js"></script>
<link rel="stylesheet" href="example.css" TYPE="text/css" MEDIA="screen">
<link rel="stylesheet" href="example-print.css" TYPE="text/css" MEDIA="print">

<script type="text/javascript">

/* Optional: Temporarily hide the "tabber" class so it does not "flash"
   on the page as plain HTML. After tabber runs, the class is changed
   to "tabberlive" and it will appear. */

document.write('<style type="text/css">.tabber{display:none;}<\/style>');
</script>

Via code2, I added:
Code:
<h1>Tabber Example</h1>

<p>&larr; <a href="http://www.barelyfitz.com/projects/tabber/">Tabber Home</a></p>

<div class="tabber">

     <div class="tabbertab">
      <h2>Tab 1</h2>
      <p>Tab 1 content.</p>
     </div>


     <div class="tabbertab">
      <h2>Tab 2</h2>
      <p>Tab 2 content.</p>
     </div>


     <div class="tabbertab">
      <h2>Tab 3</h2>
      <p>Tab 3 content.</p>
     </div>

</div>

I am shure I tried all possibilities, but because it is not working, I probebly forgot a possebility. I am almost sure it hase something to do with the location of js or css files

Thanks for looking!






hi,

can you post whatt you have put in the code 2 page and what you have put in your index.php....

with the # code button so it is possible to reconstruct your problem...Wink

rgds martin
Logged
mr-fan

Offline Offline

Posts: 1556


WWW
« Reply #5 on: January 30, 2009, 12:51:05 PM »

ok here you go....

try a path like this one....maybe it helps  wink

Code:
.....src="<?php echo TEMPLATE_DIR?>.....

for the css and the js file in the template directory... grin

for other wb variables...pathes look here

http://help.websitebaker.org/pages/en/advanced-docu/developer-guide/variables-and-constants.php

for an other example for files in the root (wb path)

you can use something like this

Code:
.....src="<?php echo WB_PATH?>.....

regards martin
« Last Edit: January 30, 2009, 06:27:42 PM by mr-fan » Logged

 
Peter R

Offline Offline

Posts: 17


« Reply #6 on: January 31, 2009, 12:18:46 PM »

Hi there,

Thanks again. Clearing the path via TEMPLATE_DIR did the trick. Well, that is to say, after I removed some code from the clock I discussed in an other threat. For making the clock work, I needed to change <body> into <body onLoad="show_clock()">. The tab code is not liking this. My knolledge of JS is more less, then it is more, let’s say bad, but I can imagine that onLoad is something that the tab feature doesn’t like at all.

Maybe this forum is not the place for the next question, but I just give it a try. Does somebody know an alternative for onLoad? I really need to have a clock. Not with local time, but UTC (aka GMT), so it gives the same time in all time zones. And of coarse UTC date must also be shown, but that is not to difficult. The date is more or less static, but time keeps on moving by the second. So for this, JS is needed, and that is really not my cup of coffee.

I must stop pulling out my hear with these JS problems. It starts looking ridicules.
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!