Forum Moderators: coopster
I have one page which calls a template (the backbone) and 2 navigation pages (left and right). Now the template page is set for 3 tables and the index has
$content1
$content2
$content3
Now... What if the "about.php" page only needs to tables? How would that go in the template...
I'm guessing the first table would be normal. "echo $content1", but what about 2 and 3? I know it would have to be a "if / else" statement but how would I make it call up the table and the content variable, and if there is not content3 then to null and void it?
I'm guessing here...
if
content3 then (table code) echo content3 (end table)
else
... what would make it just... do nothing?
I just need a way for... the template to develop itself according to what the page needs. Like I said, the index will have 5 variables of content, meaning the template will need to display 5 tables with the 5 variables.
The about page will need 1 or 2 tables with the content displayed inside... But how?
Code:
-----------------------------------------------------
<html>
<head>
<title>Project: Osiris - Testing Page</title>
<link rel="stylesheet" type="text/css" href="core_dark.css" title="dark">
<link rel="alternate stylesheet" type="text/css" href="core_light.css" title="light">
<link rel="alternate stylesheet" type="text/css" href="core_moon.css" title="moon">
<script type="text/javascript" src="styleswitcher.js"></script>
</head>
<body>
<div id="header">
<div align="right"><font size="1">Version: Pre-Alpha 4</font></div>
<div align="center"><img src="test_banner.gif"></div>
</div>
<div id="left">
<table cellSpacing=1 width="100%" bgcolor="#000000" border=0>
<tr>
<td class="head">.:: Main ::.</td></tr>
<tr>
<td class="navi">
<?
echo $main;
?>
</td>
</tr>
</table>
<br>
<table cellSpacing=1 width="100%" bgcolor="#000000" border=0>
<tr>
<td class="head">.:: Media ::.</td></tr>
<tr>
<td class="navi">
<?
echo $media;
?>
</td>
</tr>
</table>
<br>
<table cellSpacing=1 width="100%" bgcolor="#000000" border=0>
<tr>
<td class="head">.:: Programs ::.</td></tr>
<tr>
<td class="navi">
<?
echo $programs;
?>
</td>
</tr>
</table>
<br>
<table cellSpacing=1 width="100%" bgcolor="#000000" border=0>
<tr>
<td class="head">.:: Games ::.</td></tr>
<tr>
<td class="navi">
<?
echo $games;
?>
</td>
</tr>
</table>
<br>
<table cellSpacing=1 width="100%" bgcolor="#000000" border=0>
<tr>
<td class="head">.:: Members ::.</td></tr>
<tr>
<td class="navi">
<?
echo $members;
?>
</td>
</tr>
</table>
<br>
<table cellSpacing=1 width="100%" bgcolor="#000000" border=0>
<tr>
<td class="head">.:: Contact ::.</td></tr>
<tr>
<td class="navi">
<?
echo $contact;
?>
</td>
</tr>
</table>
<br>
<table cellSpacing=1 width="100%" bgcolor="#000000" border=0>
<tr>
<td class="head">.:: Supporters ::.</td></tr>
<tr>
<td class="navi">
<?
echo $supporters;
?>
</td>
</tr>
</table>
</div>
</div>
<div id="center">
<table cellSpacing=1 width="100%" bgcolor="#000000" border=0>
<tr>
<td class="head">.:: News - February 14, 2006 - 1:59a.m. ::.</td></tr>
<tr>
<td class="content">
<?
echo $content;
?>
</td>
</tr>
</table>
<br>
<table cellSpacing=1 width="100%" bgcolor="#000000" border=0>
<tr>
<td class="head">.:: News - January 14, 2006 - 11:49p.m. ::.</td></tr>
<tr>
<td class="content">
<?
echo $content2;
?>
</td>
</tr>
</table>
<br>
<table cellSpacing=1 width="100%" bgcolor="#000000" border=0>
<tr>
<td class="head">.:: News - January 14, 2006 - 11:49p.m. ::.</td></tr>
<tr>
<td class="content">
<?
echo $content3;
?>
</td>
</tr>
</table>
</div>
<div id="right">
<table cellSpacing=1 width="100%" bgcolor="#000000" border=0>
<tr>
<td class="head">.:: Links ::.</td></tr>
<tr>
<td class="navi">
<?
echo $links;
?>
</td>
</tr>
</table>
<br>
<table cellSpacing=1 width="100%" bgcolor="#000000" border=0>
<tr>
<td class="head">.:: Flash Games ::.</td></tr>
<tr>
<td class="navi">
<?
echo $f_games;
?>
</td>
</tr>
</table>
<br>
<table cellSpacing=1 width="100%" bgcolor="#000000" border=0>
<tr>
<td class="head">.:: PC News ::.</td></tr>
<tr>
<td class="navi">
<?
echo $news;
?>
</td>
</tr>
</table>
</div>
</body>
</html>
---------------------------------------------------
I have 3 different CSS files called up by a javascript on which you preferred, and will save that as a cookie (don't as me how, but that's what the header is), then the rest is right there... but how do I get the content tables to be varied?
If you want to stick with your concept then you need to find how you want to trigger the template change
Is it upon user’s level?
Is it upon user’s registration preferences?
Is it upon clicking on available choice?
Then it should be quite straightforward
I suppose that you use a query to populate the tpl
So you need to build as many queries as solutions you envision
And include the requested query at the top of your tpl
For ex: do a query and find user level
You get $level=1
If ($level==1)
{
include “query_a”;
}
etc….
if you goto the index, it'll call up content 1-5, but if you goto the about page, that's content 1 and 2.
Goto the video page, that's content 1 only.
The user has nothign to do with it, it's all up to the page calling the template. The has to be a way to set something like...
If page has content = 5 then print content 1-5, if =4, print 4, if 3, print 3 tables, and so on... there has to be a way.
if
content3 then (table code) echo content3 (end table)else
... what would make it just... do nothing?
Don't use a bare
else. Use an
else if.
if () {
// do something
} else if () {
// do something else
} else if () {
// do something else
} if it sees cotent 1, print this, and echo what's in it... if u see content 2, print this, echo what's in it... if u see 3, print this and echo what's in it.. if no 4, then stop.
I see the structure, I just don't see what would go where -.-