Recent Topics

1 Oct 20, 2005 21:10    

I want to add a "home" button that doesn't display on the home page.

What do I add to my _main.php to detect if the user is not at the home page of the blog? By home page I mean that they are at the root "index.php" with no categories selected, not looking at any archives or anything like that. I have already added a home link to the comments and post details page.

Seems like it should be easy but I can't work it out!

Thanks,
-ken-

2 Oct 20, 2005 22:27

Try this:

<?php
if( $s || $cat || !empty($catsel) || $m || $disp!='posts' || $title || $p )
{
?>
  <!--Insert Home Page Button Here-->
<?php
}
?>

3 Oct 20, 2005 23:28

It doesn't seem to work when I use the navigation "previous" and "next" buttons

ie when the url looks like this:
index.php?blog=2&page=1&disp=posts&paged=2

4 Oct 20, 2005 23:52

Ah, yes. Did not test that scenario. Try this version:

<?php
if( $s || $cat || !empty($catsel) || $m || $disp!='posts' || $title || $p || $page )
{
?>
  <!--Insert Home Page Button Here-->
<?php
}
?>

5 Oct 21, 2005 01:52

Now it doesn't seem to do anything at all.

Presumably there's some mechanism that makes the blog default to displaying page one, or the 'home page' when there's no url variables passed. Couldn't I add something there like a boolean? $ishome=true

Or does anyone know where the part is that checks to see whats passed from the url and whether it leaves some variable in a known state when nothing is passed?

6 Oct 21, 2005 16:31

Now it doesn't seem to do anything at all.

Do you mean that it never displays your button, or it always displays your button?

The blog does essentially the same thing on the home page as other pages, it just checks certain variables along the way to make decisions about what to display.

The variables I listed correspond to different "sections" of the blog, such as archives, individual posts, paged posts, etc. On your "default" page, none of those should evaluate to "true", so the button shouldn't be displayed. Everywhere else, it should find at least one of those and display the button.

This code works on my blog, but maybe I'm missing something or doing something different than you are. Perhaps one of the devs will chime in.

7 Oct 21, 2005 17:18

Kweb, I get it to display, but it displays on index.php as well as all others

8 Oct 21, 2005 19:02

Sorry, yes, I mean it displays all the time. I think because $page usually equals 1, and it doesn't mean what page you're on because $paged means that.

I changed it to


if( $s || $cat || !empty($catsel) || $m || $disp!='posts' || $title || $p || $paged >= 2 )

and so far that seems to work but I'm testing on localhost and I'm never sure what's cached or about all the contingencies.

9 Oct 21, 2005 19:21

A quick and dirty live test and it seems to work just fine Kenneth

Just have to find a nice useable position for it :)

Nice touch

10 Oct 21, 2005 19:30

Typically, the "home" link is incorporated into the site title. In your case, John, I would think that making the the "Wow Factor" graphic (or the "Wow Factor" text), the link ... would make some sense.

Just an idea.

-stk

PS ... altho, the link shows when I'm ON the home page ... which (I thought) wasn't the effect desired.

11 Oct 21, 2005 19:34

would make some sense.

tooo true :)
But that top menu is there all the time anyhow.

It is nice to have an alternative "home" placed at convenient locations though. .

12 Oct 21, 2005 20:27

Thanks chaps! It's now up and works with every contingency I can think of.

I've put the Home link next to the Next Page/Previous Page navigation things, figuring that if people are navigating, that's where they'll be looking when wanting to go home again. Meanwhile, if they are using categories and don't spot the home thing, there's the "All" category, which when you're thinking in terms of categories makes more sense than 'home'. Then there's another one when viewing individual posts or commenting which includes the full name of the blog, and that's at the bottom of the post before the comments, with the navigation one still there at the bottom of the page as well.

If you're putting it with a load of tabs or navigation, you could do this:


<?php if( $s || $cat || !empty($catsel) || $m || $disp!='posts' || $title || $p || $paged >= 2 ) 
		{ ?><a href="<?php bloginfo('url'); ?>" title="<?php bloginfo('name'); ?>">Home</a><?php }
else { ?>
<strong>Home</strong>
<?php } ?>

 ?>

to prove to users that they are currently home and thus reinforce consistency. Nice if you have a row of buttons, then you can do a 'selected' button. Good to let users know they are home when they have just clicked it. But seeing as mine is next to Next and Previous, which disappear when not relevant, I figured disappearing was better.


Form is loading...