Forum Moderators: coopster

Message Too Old, No Replies

A dynamic page for a dynamic site

Multiple content varies

         

Soa307

4:35 pm on May 2, 2006 (gmt 0)

10+ Year Member



If any of you know me by know, i'm new to PhP but i get the basics of where i'm at, which is simple.

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?

henry0

9:14 pm on May 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you use a template then you are “using a template” :)
If you were not using a template you could do as you mentioned
And script a “if this and if that” to build the page on the fly
But if I understand you correctly then you need to create a new template accordingly to the new page design
So the first job before coding is to define the site overall look and create corresponding templates

Soa307

6:51 am on May 3, 2006 (gmt 0)

10+ Year Member



I'm not sure exactly how to explain it without posting code and editting links and such.

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?

henry0

11:09 am on May 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If a template needs to be on the fly modified I would not use one and build each page upon user's preference.

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….

Soa307

6:31 pm on May 5, 2006 (gmt 0)

10+ Year Member



It's not a user preference it's the page's preference.

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.

coopster

2:58 pm on May 8, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member




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
}

Another way of writing control structures such as these is the switch [php.net] statement.

Soa307

4:53 pm on May 9, 2006 (gmt 0)

10+ Year Member



I'm not sure entirely how to code it but i'mma try that. It's the basic structure I needed.... Hmm... I dunno it's just hard to think of how to make it.

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 -.-

RedBaron

4:08 am on May 10, 2006 (gmt 0)

10+ Year Member



Don't know if you've thought of this, but you could make a "Page not found" page and if no 4 echo "Page not found".