Announcement

Collapse
No announcement yet.

Post content based on conditional

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

  • Post content based on conditional

    I am toying with the idea of instituting a delay before guests and some members can see the text of a post (and attachments, sigs, etc.). No one responded to my inquiry at .org so I've looked under the covers to get ideas. As far as I can tell, this is controlled by the postbit template.

    It should be as simple and effective as possible. This is what I'd like to test:
    • usergroup (an array of approved groups)
    • Time since user's last post -- over x seconds has a delay
    • Whether or not a robot (WOL)
    • Forumid
    Guests get a 24-hour delay; specific usergroups, people who've posted recently, and robots get no delay; and everyone else gets 12 hours. Some forums would have no delay for anyone.

    Anyone with a delay would have the text replaced with "This post will be readable in y hours."

    Apologies if this sounds involved (or infeasible). I am trying to deal with a large number of lurkers. My site frequently breaks local news, especially involving politics and municipal government, and I think there is time value in that to a number of people.

  • #2
    That is all possible with a template conditional except for the bot check.

    For example, in the postbit:

    Code:
    <if condition="is_member_of($bbuserinfo, X, Y, Z) OR in_array($GLOBALS[forumid], array(X, Y, Z)) OR (!$bbuserinfo[userid] AND TIMENOW - $post[dateline] > 86400) OR (TIMENOW - $bbuserinfo[lastpost] < X) OR ($bbuserinfo[userid] AND TIMENOW - $post[dateline] > 43200)">
    
    	CODE THAT DISPLAYS THE POST
    
    <else />
    
    	MESSAGE THAT THEY MUST WAIT
    
    </if>
    This code says... if the logged in user is a member of any of the usergroupids X, Y, Z, or the forumid is one of the open forums X, Y, Z (no delay), or the user is a guest and the post is more than 24 hours old, or the user has posted within the last X seconds, or the user is registered and the post is more than 12 hours old, then display the post, else display a wait message.

    I have not tested this, but hopefully that gives you an idea.

    Comment


    • #3
      How would you just specify the current forum number?

      I'm trying to use something close to this... but I don't think I'm using the right variable... this is in the postbit template

      HTML Code:
      <if condition="$post['forumid'] = 31">
      or 
      <if condition="$threadinfo['forumid'] = 31">
      this would only do the interior code if it's in a specific forum

      Comment


      • #4
        In the postbit:

        Code:
        <if condition="$GLOBALS[forumid] == 31">

        Comment


        • #5
          That is all possible with a template conditional except for the bot check.
          How do I test an array of useragents? I tried doing this and it wouldn't even save the template because it considered the agent string to be a function. Or, is that something I have to do in PHP and set a flag that the template can use?

          So far, all I'm testing is usergroup and forumid. Testing members' last posts comes after a trial period to see how well the guest thing works.

          Anyhow, thanks a lot for the help. If anyone wants to see this in action at the moment then go to my site, change the style to default, and pick a recent message from any forum except Site Info, Parrots, Upcoming Events, and RSS Feeds. Subject to change, obviously.

          Comment


          • #6
            You can use the in_arrary() function:

            Code:
            in_array($agent_string, array('string1', 'string2', 'string3'))

            Comment


            • #7
              Getting the following when I try to save:
              The following template conditional expression contains function calls:

              <if condition="(TIMENOW - $post[dateline] > 86400) OR is_member_of($bbuserinfo, 2, 6, 7) OR in_array($GLOBALS[forumid], array(2, 5, 27, 25)) OR in_array($agent_string, array('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)', 'Test'))">
              It's specifically complaining about Function Name 0 with usage
              "(compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)"

              Comment


              • #8
                Have this part of the project solved, I think. I created a hook in postbit_display_start.

                PHP Code:
                if (preg_match("/^.*(Yahoo|MSNbot|Googlebot)/i"$_SERVER['HTTP_USER_AGENT'])) {
                $show['robot'] = true;

                The conditional is presently as follows. Only hole is the archive, and I'll wait for people to find it.

                HTML Code:
                <if condition="(TIMENOW - $post[dateline] > 86400) OR is_member_of($bbuserinfo, 2, 6, 7) OR in_array($GLOBALS[forumid], array(2, 5, 27, 25)) OR $show['robot']">

                Comment


                • #9
                  Have found that PM also uses the postbit template. I would like to display the message without a delay if it's a PM. How do I do this? Current version is 3.7.3. Will start a new thread in the proper forum if necessary.

                  Comment

                  widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                  Working...
                  X