1 obtruse_man4 Jul 11, 2006 22:38
3 obtruse_man4 Jul 12, 2006 01:04
That would work perfectly, however I'm not that good at writing php. I don't know very much about switching, so I had to do a google. Here's something I wrote up:
$link = "index.php?page=";
switch ($link){
case "about":
require ("about.php");
break;
case "gallery":
require ("gallery.php");
break;
case "downloads":
require ("downloads.php");
break;
default:
<<blog posts here>>;
break;
}
I have several questions though, and I really doubt if this is a step in the right direction. How do I tell the link which one to switch to? How do I say, if user clicks on about link, go here...?
Also, does all this code go in the _main.php file of my skin? Where should I put this statement on the page; at the very top?
4 balupton Jul 12, 2006 01:20
Ok a bit off.. but in the right direction :)
Firstly you should have the following somewhere at the beggining of your skin's _main.php file;
$pages = array(false,'about','gallery'); // false means use blog's page
param('page','string',$pages[0]);
// varname, vartype, default
Then use the following for your links;
$s = sizeof($pages);
for ( $i = 0; $i < $s; $i++ ) {
$c = & $pages[$i];
if ( $page != $c )
echo '<a href="'.regenerate_url('page='.$c).'" title="'.$c.'">'.$c.'</a>';
else
echo $c;
}
Then to include the page;
if ( $page != false ) {
$file = 'pages/_'.$page.'.php';
if ( file_exists($file) )
include $file;
else
echo $page.' page does not exist!!!!';
}
That should give you the idea, none of that code is tested but with some fidling and research it should work ;)
Now what you can do with your $pages array is this;
$pages = array( false, array('about','pages/_about.php') );
So you have the link to the page inside the array, so thats the only thing u need to hardcode. Hardcoding things in is bad when you want to upgrade or change things.
Yeh. So have a fiddle ;)
5 obtruse_man4 Jul 12, 2006 02:00
wow, I'm sorry, but you've completely lost me. I have no clue how to fiddle with that, because I don't understand most of it :p
After I posted that bit of code I came up with something a little bit better. At least something that seems to be half-working.
Here's the links:
<ul>
<li><a href="index.php?page=about" title="About"><span>About</span></a></li>
<li><a href="index.php?page=gallery" title="Gallery"><span>Gallery</span></a></li>
<li><a href="../../index.php?page=downloads" title="Downloads"><span>Downloads</span></a></li>
</ul>
and here's the code I replaced the blog posts php code with:
<?php
$link = $_GET['page'];
switch ($link){
case "about":
require ("about.php");
break;
case "gallery":
require ("gallery.php");
break;
case "downloads":
require ("downloads.php");
break;
// these are all the blog posts. if no link is selected the posts are displayed.
default:
require ("posts.php");
break;
}
?>
[quote]
The statement is working at least partially because it's pulling up the posts. I can't figure out how to get the links to work though. Is this perhaps an alternative way of doing things, because I understand this a lot better than I do your code :) [/quote]
6 balupton Jul 12, 2006 02:37
check attachment.
also note that using the variable $page will cause b2evo to chuck a sad at you as it is a reserved variable name.
7 obtruse_man4 Jul 12, 2006 03:29
Thanks a lot for the code! I tried implementing it, but only got so far. The top page links have space above them, that I can't get rid of, and only a little bit of the style of the link button displays. Also the links don't work. I've checked and double checks the paths, and they should work, I'm just not sure why. I decided to attach what I have so far, just to show you exactly what I've done. Any suggestions?
8 balupton Jul 12, 2006 03:43
Update your conditional statement on line 70 (i think) to
echo ($special_page != $t)
? '<li><a href="'.regenerate_url('','special_page='.$t).'" title="'.$t.'">'.$t.'</a></li>'
: '<li>'.$t.'</li>';
The stuff after :, is what is used if it is the current page, after ? is what to use if it is not the current page. condition ? true : false ; Easy!
That is a great looking site, can you should post your v1.8 ready version of the skin :D
Now back to the topic;
Why don't you have the following:
Your gallery link;
/blogs/index.php?page=gallery
Now in your code just change where the posts are to be displayed have a if/switch statement that handles these pages, and if it is a special page then use then include the special page instead of the posts.
Of course you would need to add a lot of if/switch statements everywhere else so you are not including any post/blog information, like rss info, blog title, etc.
Anyway it's easy to do, if what i just said is what you want to do.
And i'm going to make a plugin to provide a more guided way to do this, it seems to be a popular request that i wouldn't mind myself. (Although don't expect the plugin that soon...)