Re: Help with an if/then statement
<?php if( #conditional# ) {
//some code
} ?>
Unfortunately determining if this is the last page is a little bit difficult. You need code like this (taken from template-functions.php):
global $page, $topic;
$add = topic_pages_add();
$last_page = get_page_number( $topic->topic_posts + $add );
if( $page == $last_page ) {
//some code
}
which is way more code than it should be. You should be able to use (but can’t yet)
if( bb_last_page() ) {
// some code
}
so I’m submitting a trac ticket so that hopefully in the next version you can do that.
In your case, the // some code
should be:
print( '<h2 class="post-form">POST A REPLY</h2>' );
Worth noting, in PHP strings
(ie. text in code) are marked by opening and closing with '
or "
. If you open a string with '
then "
will be ignored and the other way round, too. So you could have used
print( "<h2 class='post-form'>POST A REPLY</h2>" );
Also in PHP functions have to be like this: function_name( #arguments );
where #arguments can be things like a string, or a variable you set earlier. Some functions do without the brackets but all of them work fine with brackets, so it’s best to always use them.