Recent Topics

1 May 20, 2005 19:51    

I want to have a static post on the main page to my blog that only appears on the entry page. I have already set it up by editing the main.php file. However, when I click on the "categories" links on the sidebar, the static content is displayed on that page as well.

Is there anyway to make the static post only appear on the first page?

Thanks everyone!

Here is a link to the blog: www.alvinbaker.net/twowheel

2 May 20, 2005 23:28

The thing is, there is really only one page to b2evolution. It's just showing different content based on what parameters are passed, and doing a bunch of includes. So, if you add something to the _main.php page in your skin, it's going to show up everywhere.

There is a way to do this, though - you have to use some logic to figure out if you are displaying the "default" content or some specially requested content ( single post, comments, category, etc.).

From what I can tell, the easiest way to check for this is to check the values of the following functions:

	single_cat_title();
	single_month_title();
	single_post_title();
	arcdir_title();
	last_comments_title();
	stats_title();
	profile_title();

Since one of these will return a value whenever "special" content is requested, checking to see that they all return empty strings should tell you that you are displaying the default content.

So, to get what you want, you need to use something like this:

if (!(strlen(single_cat_title('',false)) +  strlen(single_month_title('',false)) +  strlen(single_post_title('',false)) + strlen(arcdir_title('',false)) + strlen(last_comments_title('',false)) + strlen(stats_title('',false)) + strlen(profile_title('',false))  > 0 ))
{ ?>
// place your static content here
<?php }

By adding up the lengths of the return values of all those functions, and checking to see that they don't total more than zero, you can tell that you are on the "default page".

It might be a good idea to create a seperate php file with your static content in it, and use an include to insert it inside the if statement. That way, you keep your static content seperate and can edit it easier.

3 May 21, 2005 02:43

Good idea Kweb. But here's a simpler way that doesn't call a lot of unnecessary functions and does the same thing:

<?php
if( !$s && !$cat && isempty($catsel) && !$m && !$w && $disp=='posts' && !$title && !$p )
{
  ?>Here be the stuffs.<?php
}
?>

4 May 21, 2005 03:57

Ah, yes, well, I suppose if you like things simple... :)

Thanks for the tip. I'm fairly new to b2evolution, and still getting familiar with the code and what's available there.

5 May 21, 2005 15:25

Thanks to both of you! I will try this out later today.

6 May 22, 2005 01:57

I can't get either of these to work. The error is saying "isempty" is an undefined function.

7 May 22, 2005 02:14

I fixed it. The function should be "isset", not "isempty"

8 May 22, 2005 16:22

I spoke too soon! I had it working while using multi blogs, but now just using one, it doesn't work anymore. You can see what I am talkinga about by going here: www.twowheeltravels.com . I have a welcome messeage that I only want displayed on the first page. When you click on the categories on the right, I do not want it to be displayed like it currently is..

Does anyone have any ideas on how to do this?

9 May 23, 2005 02:53

Just a guess - If you changed "isempty" to "isset", then you might need to put a "!" in front of it to make it negative (is not set).

It may help if you would post the actual code you are using since we've given you a couple of suggestions and then you (may have) changed the code slightly from what we gave you.

10 May 23, 2005 03:26

This is the code I have in _main.php... If I use isempty like Isaac suggested, I get an error for an undefined function.

<?php 
if( !$s && !$cat && isset($catsel) && !$m && !$w && $disp=='posts' && !$title && !$p ) 
{ 
  ?>
  
  <div class="bPost">
          <h3 class="bTitle">Welcome...</h3>
          <div class="bText">
            We live in central Illinois and spend as much time as possible each 
            summer on our motorcycles traveling the roads of the United States. 
            We put this site together to share our experiences with other people 
            who enjoy motorcycle touring and also to encourage those who may be 
            considering it. We are not hard core Iron Butt riders but we aren't 
            fair weather riders either. We put a fair amount of miles on each 
            summer and spend the long mid-west winters in local watering holes 
            reliving our past trips and planning the next ones.
            <p>We have both been riding several years and have similar riding 
            styles and habits which is important on long trips. Through many 
            years of experience and regular practice sessions our alcohol 
            consumption rates are pretty similar as well. While we certainly 
            don't condone or recommend anyone ride a motorcycle after drinking 
            adult beverages, we do contend that with focused dedication and 
            years of practice one can achieve a certain level of expertise. In 
            constant pursuit of this goal, we encourage you to visit our 
            feedback page and let us know your favorite watering hole. We will 
            try to visit as many of these as we can fit into our training 
            schedule. While you're at it, let us know your favorite ride or 
            section of road. Give us enough details to find it and we will do 
            our best to get there and ride it ourselves. When we have collected 
            enough data, we will add listings by state here on the site so 
            everyone can access the information as you plan your own trips. </p>
            <p>We'll also be putting up photo pages of some recent trips as well 
            as posting the trip logs we keep on the road. With both of those you 
            should have enough information to get you there if it looks 
            interesting to you. As we travel on our next adventures, we plan to 
            update the site regularly from the road.</p>
            <p>Enough introduction, check out the rest of the site, visit the 
            feedback page, let us know what you want to see. Check out our 
            equipment lists and product reviews as we try out new items on the 
            market.</p>
            <p>Ride Safe, Brad & Steve</p>
            </div></div>


<div class="bPost">
<h3 class="bTitle">Latest posts...</h3>
</div>  
  
  <?php 
} 
?>
  
  


<!-- =================================== START OF MAIN AREA =================================== -->

11 May 23, 2005 04:19

Strangely, I don't get anything when I use that code. It only shows up for me if I remove "!$w" from the list of variables it is checking (I'm not even sure what that is). I wonder if it has to do with the way your blog is set to display (mine is set to "posts paged").

Isaac, would you mind giving us some info on what each of these variables are checking?

12 May 23, 2005 04:46

You may be on to something. I removed the "!$w" from the list just like you and now it is working how I need it to!

I am still curious as to what the individual variables do...

Anyway, thanks again for your help, Kweb!

13 May 23, 2005 05:15

works for me ... ::)
and here's how I have it set ...

<h2><?php
	single_cat_title();
	single_month_title();
	single_post_title();
	arcdir_title();
	last_comments_title();
	stats_title();
	profile_title();
?></h2>
<?php
if( !$s && !$cat && isset($catsel) && !$m && $disp=='posts' && !$title && !$p )
{
  ?>
  <h2>embedded Flash</h2>
  <?php
}
?>

14 May 23, 2005 18:00

b2evo registers a few url parameters as global variables. It will check to see if they're set already before grabbing from the $_GET superglobal.

$w = what week to show? (weekly archives)
$m = the daterange, YYYYMMDD (2005 would be all of 2005 - 200505 would be all of may, 2005 - 20050501 would be may 1, 2005. useful for archives.)
$cat = a list of categories as a string. Also show the children of any categories in the string. (links in teh category list set this.)
$catsel[] = an array of selected categories. Don't show children of any selected categories. (checkboxes in teh category list set this.)
$p = the id of the post to show (single-post mode)
$title = the url title of the post to show (single-post mode)
$disp = string to say what to show 'posts', 'stats', 'arcdir' (archive directory), 'comments', etc.

I made a mistake because $w always gets set to a value, even if it's not needed.

isset($catsel) should be empty($catsel), I believe. It will always be set - the question is whether or not it has any entries.

See: http://b2evolution.net/man/2004/06/04/url_parameters

15 May 23, 2005 18:22

Isaac.. I'm assuming you mean replace isset with empty.. It seems to work fine. Thanks for the variables detail

<?php
if( !$s && !$cat && empty($catsel) && !$m && $disp=='posts' && !$title && !$p )
{
  ?>
  <h2>embedded Flash</h2>
  <?php
}
?>

16 May 24, 2005 01:55

Yes, thanks for the explanation, and the link.

17 Aug 11, 2005 09:27

<p>
   <?php
if( !$s && !$cat && empty($catsel) && !$m && $disp=='posts' && !$title && !$p )
{
  ?>
<div align="center"><h3 class="post-title">Reisinformatie Weblog voor Vakantiereizen</h3></div>
  <div align="center"><img src="http://www.alltravel-consultancy.com/reisinformatie-weblog/images/travel-news-start.jpg"></p></div>   
    <p><div align="center"><h3 class="post-title">Informatie over reizen en vakanties</h3></p></div>
		<p><u>Reis Informatie Weblog</u> met nieuws over reizen, laatste aanbiedingen, beschrijvingen van hotels en onze inspecties, informatie over reisverzekeringen, gezond op reis en andere reismedische zaken, nieuwe reisbestemmingen en vakantielanden, actualiteiten ter plekke en alles wat het voorbereiden van uw vakantiereis kan vergemakkelijken.</p>
  <?php
}
?>
</p>

Also with the code here provided I had no success. See the "volgende pagina" link at the bottom of the page.

http://www.reisinformatieweblog.com

Somehow I mess up ??? :-)


Form is loading...