Forum Moderators: coopster
The problem is that each blog has a few pages. For example, there's a picture page, and a user info (bio) page. Currently these are using different template files.
Is there a way to get them all on the same template file? Like how in phpbb they use a <!--SWITCH --> to display different pages on the same template
Does anyone know what i mean?
[domain.com...] (bio page)
[domain.com...] (picture page)
In the top of mytemplate.php, you'd write some php to collect the value of 'display' and then display the relevent data.
Co-incidentally, I just came across this thread on query strings in the forum, which might be a good place to start if you're unfamiliar with how they work.
[webmasterworld.com...]
Hope that helps. :)
$whichpage = $_GET['view'];
switch ($whichpage) {
case 'pictures':
// code here
break;
case 'profile':
// code here
break;
default:
echo 'you entered an invalid pagename';
break;
}
something like that, you need the default case to handle if someone enters junk in your url. You may need to send 404 headers for that as it wouldn't be a valid page. Or even just send them your standard 404 page.
You would just need to weave your template code into those cases. If you figure out just what your templates are doing it shouldn't be too bad.
I can switch modes in the journal.php file, between $_GET['view'] == pictures and $_GET['view'] == profile, the problem is i can only use html in the journal.php file to display those, because the template file has all the journal code in it..
How can i explain this.. I have one template file. Lets call it myname.tpl. In that is all the html and variables that display the journal. Now, i can change the variables sent to the template depending on the section being viewed (like in that suggestion you made) but that doesnt get rid of the HTML for the journal section, so just doing that wont work..
Do you know what i mean? This is hard to explain to i hope im making sence
EDIT:
Just to make clear, there are 2 files involved. The journal.php file and the template.tpl file.
Right now when vieing pictures, its done directly from journal.php without any template file
if ($_GET['view'] == "pictures") {
//i simply put the html and php variables here to display pictures, same if it was for the profile
}
But if none of those are called, then the main journal page is displayed with the template
else {
include_once('bTemplate');
$tpl->set('variable_1', $variable_1);
$tpl->set('variable_2', $variable_2);
//and so on
//call the template
echo $tpl->fetch("template.tpl");