WebsiteBaker Support (2.8.x) > Templates, Menus & Design
Edit Index.php [Template] Help
batcity:
I'm trying to include an imagevar.php script which will display a table containing three random images in the header area of a site. I'm using the vincent03 template. The imagevar1.php resides in the root folder. I tried this:
<!-- mainContainer holds the thin line and everything in it-->
<div id="mainContainer">
<!-- everything within the white bordered area -->
<div id="container">
<!-- masthead holds the header and page title in semi transparent bar -->
<div id="masthead">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="95%">
<br><br>
<tr>
<td width="33%" align="center"><?
include '../../imagevar1.php';
?></td>
<td width="33%" align="center"><?
include '../../imagevar1.php';
?></td>
<td width="34%" align="center"><?
include '../../imagevar1.php';
?></td>
</tr>
</table>
</center>
<div class="stripe"><h1><?php echo PAGE_TITLE; ?></h1></div>
</div>
I'm not sure about the syntax here, but it does work on a Non-WB site. I'm also not sure about the relative addressing because of the wb structure. Any suggestions appreciated.
The site is www.allredhairsalon .com. I pulled the code out since it isn't working. I'd like the images to show up under the address/phone number lines.
johnp:
I not quite sure if this would help, but it seems that you had the same issue back on November 16, 2007
Here is the link to it
https://forum.WebsiteBaker.org/index.php/topic,7853.0.html
Not many post! But it appeared that a resolution was found
--- Quote ---I figured out the solution. Had to use the Sections feature and add the code section above the WYSIWYG section. Had to add other sections to format the includes. Pretty clugy, but it worked. Thanks for help.
--- End quote ---
Hope this points you in the right direction..
If not try changing
--- Code: ---<?
include '../../imagevar1.php';
?>
--- End code ---
to
--- Code: ---<?php include("../../imagevar1.php"); ?>
--- End code ---
John
BerndJM:
Hi,
1. the "short" opening tag for php: <? din't work on different configurations the safer way ist to use the "normal" tag: <?php
2. the include needs brackets:
--- Code: ---<?php include ('../../imagevar1.php'); ?>
--- End code ---
3. if you're in trouble with the relative adressing you can try this:
--- Code: ---<?php include (WB_PATH.'/imagevar1.php'); ?>
--- End code ---
Regards Bernd
batcity:
Got it. It was a combination of addressing and syntax. Turns out I can address directly in both the index.php file and in the var script. Thanks a bunch for your help! Appreciate it!
The imagevar1.php script looks like this:
<?php
$imagevar=rand(1, 3);
if($imagevar==1)
{
print "<img src='images/header/img_01.jpg'>";
}
else if($imagevar==2)
{
print "<img src='images/header/img_02.jpg'>";
}
else if($imagevar==3)
{
print "<img src='images/header/img_03.jpg'>";
}
?>
and the modified header code looks like this now (and it works). Just have to get the correct images and play with the spacing.
<div id="masthead">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="75%">
<tr>
<td width="33%" align="center">
<?php include ('imagevar1.php'); ?>
</td>
<td width="34%" align="center">
<?php include ('imagevar1.php'); ?>
</td>
<td width="33%" align="center">
<?php include ('imagevar1.php'); ?>
</td>
</tr>
</table>
</center>
<div class="stripe"><h1><?php echo PAGE_TITLE; ?></h1></div>
</div>
batcity:
Note: I also had to move a copy of the imagevar.php files and the images/ folder to the /pages directory.
Navigation
[0] Message Index
[#] Next page
Go to full version