Announcement

Collapse
No announcement yet.

CONDITIONAL: newpost template when forumid=x and is a new thread?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • CONDITIONAL: newpost template when forumid=x and is a new thread?

    I want to add some additional information right above the post area on the newpost_messagearea_x templates when the conditions are:

    $forumid == 8 AND IsNewThread

    In other words when the forum=8 and it's not a reply to another post

    I have pasted the code below, but $post[postid] evident;ly isn't defined on the post/reply page.

    1) How do I figure out which variables ARE available for me to use in a given template and,

    2) What's the one to check if its a new thread or a reply?

    Code:
    <if condition="$forumid == 8 & ! $post[postid]">
    <div align="center">
      <center>
      <table border="0" width="300" height="10%" bgcolor="#FFFF99" cellspacing="1">
    	<tr>
    	  <td width="100%" height="13">
    		<p align="center"><font face="Arial" size="1">$bbuserinfo[username], thanks for taking the time
    		to give feedback!<br>
    		</font><b><font face="Arial" size="2" color="#FF0000">PLEASE PASTE THE
    		ADDRESS OF THE STORY YOU ARE REVIEWING INTO THE BODY OF YOUR MESSAGE $postid</font></b></td>
    	</tr>
      </table>
      </center>
    </div>
    </if>

  • #2
    I think it's:

    <if condition="$forumid == 8 & ! $thread[dateline] > $bbuserinfo[lastvisit]">

    Comment


    • #3
      It's a funny one. $bbuserinfo is defined, but $thread doesn't seem to be.

      Comment


      • #4
        <if condition="$forumid == 8 && strpos('ewthread.php',strtolower($_SERVER[PHP_SELF])) > 0"> will also do it

        Comment


        • #5
          Oleg,

          Thanks for the help ... that code results in the following message. I am just looking over the vb code to try to determine what variables might be available for me to test on that template.

          Any additional ideas would, of course, be appreciated.


          Code:
          The following template conditional expression contains function calls:
          
          <if condition="$forumid == 8 && strpos('ewthread.php',strtolower($_SERVER[PHP_SELF])) > 0">
          
          Function NameUsage in Expressionstrposstrpos(\'ewthread.php\',strtolower($_SERVER[PHP_SELF])strtolowerstrtolower($_SERVER[PHP_SELF])
          With a few exceptions, function calls are not permitted in template conditional expressions. Please go back and re-write this expression.
          
          The following functions are allowed in template conditional expressions:
          in_array() is_array() is_numeric() isset() empty() defined() can_moderate() exec_switch_bg()

          Comment


          • #6
            I would love to see more comments on this issue, but in the meantime I did manage to get it working thanks to Oleg's hints.

            I didn't use Oleg's code verbatin, but I also didn't realize I could pull in PHP defined variables ... so I just ended up testing $_SERVER[PHP_SELF] to make sure it wasn't '/vbulletin/newreply.php'
            Code:
            <if condition="$forumid == 8 & $_SERVER[PHP_SELF]!='/vbulletin/newreply.php'">

            Comment


            • #7
              Originally posted by bdbourn
              I would love to see more comments on this issue, but in the meantime I did manage to get it working thanks to Oleg's hints.

              I didn't use Oleg's code verbatin, but I also didn't realize I could pull in PHP defined variables ... so I just ended up testing $_SERVER[PHP_SELF] to make sure it wasn't '/vbulletin/newreply.php'
              Code:
              <if condition="$forumid == 8 & $_SERVER[PHP_SELF]!='/vbulletin/newreply.php'">
              Oh, didn't understand what you meant. I thought you wanted to see if the thread a user was replying to was new since the user's last visit, not if the user was posting a new thread.

              Comment


              • #8
                No but that's a nifty idea N!ck!

                Maaaaan! I can see where conditionals might warrant their own special forum at some point!!!


                Originally posted by N!ck
                Oh, didn't understand what you meant. I thought you wanted to see if the thread a user was replying to was new since the user's last visit, not if the user was posting a new thread.

                Comment


                • #9
                  Glad you got it working.

                  Comment


                  • #10
                    You don't need to look at PHP_SELF

                    If you want to know if you are on new reply you just need to do

                    <if condition="'THIS_SCRIPT == 'newreply'">

                    If you want to access the thread array, try $threadinfo, not $thread.

                    Comment


                    • #11
                      Thanks freddie ...

                      PHP_SELF works but THIS_SCRIPT is more elegant.

                      One question ... I take it $threadinfo is not defined on the new post template?

                      Even outputting just plain $threadinfo doesn't produce any results where normally I would expect 'Array' to display.

                      Am I correct or am I doing somthing wrong?

                      vB doesn't pre-fetch a postid when you hit the new post page does it?



                      Originally posted by freddie
                      You don't need to look at PHP_SELF

                      If you want to know if you are on new reply you just need to do

                      <if condition="'THIS_SCRIPT == 'newreply'">

                      If you want to access the thread array, try $threadinfo, not $thread.

                      Comment


                      • #12
                        $threadinfo would be defined on newreply but not newthread.

                        Comment

                        Loading...
                        Working...
                        X