Recent Topics

1 Jul 11, 2006 22:38    

First of all let me say hi, because I do believe that this is my first post on these forums. I've been using b2evolution for quite a while now, and I've always been able to work out my blog customizing problems myself, until now.

I've been having a major problem with spam, so when I saw that 1.8 summer beta had been released, I immediately upgraded. I had used the plain skin before, however since I couldn't find any skins that were compatable with 1.8, I looked for a different design, and found nautica2l. It's a great skin, and it didn't take me very long to customize it and update it to work with blog version 1.8. You can take a look at my blog [url=http://www.farsideofthegalaxy.com/]here[/url].

My blog looks great, at least I think it does, and it works excellently. However I would also like to add other pages to my website, and so far I've had major problems doing so. I'm not sure if it's the skin, or the updated blog, but I had no problem doing this with my old plain skin.

At the very top of the page, I already have links to about, downloads, and gallery. What I want to do is keep pretty much everything on the page except the blog posts, and replace the blog posts with other information. That way I still keep the structure of a nice and clean site, and add content at the same time. I copied and pasted the code from the _main.php of the nautica2l theme, and tried using it for an about page, but I keep getting fatal errors. The problem is that the about page, which is located in a different directory, doesn't know where to look for the php variables. I tried putting the about file in the nautica2l skins directory, but it still doesn't work.

My php and css knowledge is decent, and I can edit files pretty well, but this is way past my php knowledge. I can't figure out how to use the code with the variables, and I can't come up with a way to not use the variables; so I'm stuck!

The about page can be located [url=http://www.farsideofthegalaxy.com/about/]here[/url]. Thanks in advance for any and all help!

2 Jul 11, 2006 22:59

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

3 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 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 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 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 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 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!


Form is loading...