Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Full Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Sitewide Announcement. Details »»
Sitewide Announcement.
Version: 1.00, by Michael Morris Michael Morris is offline
Developer Last Online: Jun 2009 Show Printable Version Email this Page

Version: 3.0.3 Rating:
Released: 07-07-2004 Last Update: Never Installs: 6
 
No support by the author.

This was one of my first hacks, but I've learned so much since then so as to completely invalidate the old code. Not that it didn't work, but it's clumsy.

This template mod (there is no code to hack) generates an announcement in the variable of $announcement that you can then put in you're header or you're navbar if you're so inclined. The announcement changes based on the usergroup but also on whether or not registered users have posted or posted recently.

The key to the code goes in the PHPINCLUDE_START template. You can put this at the very start or the very end of you're template so long as you don't drop it into the middle of something else.

PHP Code:
// #####################################################
// #####            START ANNOUNCMENTS             #####
// #####################################################

eval('$announcement = "' fetch_template('announcement_all') . '";');

if (empty(
$announcement)) //If it's empty we'll get our usergroup announcements
    
{
    if (
is_member_of($bbuserinfo1))  // Guests go first.
        
{
        eval(
'$announcement = "' fetch_template('announcement_guest') . '";');
        }
    else if (
is_member_of($bbuserinfo3)) // Pending Registrant
        
{
        eval(
'$announcement = "' fetch_template('announcement_pending') . '";');
        }
    else if (
is_member_of($bbuserinfo5) OR is_member_of($bbuserinfo6) OR is_member_of($bbuserinfo7)) // Staff (Supermods, Admins & Mods)
        
{
        eval(
'$announcement = "' fetch_template('announcement_staff') . '";');
        }
    else if (
$bbuserinfo['posts'] == 0// User has never posted. Encourage them.
        
{
        eval(
'$announcement = "' fetch_template('announcement_noposts') . '";');
        }
    else if (
TIMENOW $bbuserinfo['lastpost'] > 1209600// User hasn't posted in 14 days.
        
{
        eval(
'$announcement = "' fetch_template('announcement_noposts14days') . '";');
        }
    else 
// All others
        
{
        eval(
'$announcement = "' fetch_template('announcement_registered') . '";');
        }  
    } 
Now create 7 new templates - the contents of which will be the messages the users receive. Leave announcement_all blank - it's an emergency announcment that, when active, suppresses the other 6. I use it to warn users about an hour ahead of time that I'm going to turn the boards off.

announcement_all
announcement_guest
announcement_pending
announcement_staff
announcement_noposts
announcement_noposts14days
announcement_registered

Ok, that's it and ready to run. You can plug $announcement into your header or the like, though you might want to frame it in a table or layer. You can turn that framing table or layer off when the $announcement is empty like so...

<if condition="!empty($announcement)">
<table><tr><td>$announcement</td></tr></table>
</if>

Now, you can of course do all of the above with raw template conditionals HOWEVER, this approach has the advantage that the $announcement templates are easier to read and modify by someone with very little HTML experience. So, this approach comes in handy for making modification easy for someone else.

However, for the curious, here is the SAME system, entirely as a template conditional done in HTML.

HTML Code:
<if condition="is_member_of($bbuserinfo, 1)">
TEXT OF THE GUEST MESSAGE
<else /><if condition="is_member_of($bbuserinfo, 3)">
TEXT OF THE PENDING USER'S MESSAGE
<else /><if condition="is_member_of($bbuserinfo, 5) OR is_member_of($bbuserinfo, 6) OR is_member_of($bbuserinfo, 7)">
TEXT OF THE STAFF MESSAGE
<else /><if condition="$bbuserinfo['posts'] == 0">
TEXT OF THE MESSAGE TO USERS WITH 0 POSTS
<else /><if condition="(TIMENOW - $bbuserinfo['lastpost'] > 1209600)">
TEXT OF THE MESSAGE TO USERS WITHOUT A POST IN THE LAST 14 DAYS
<else />
TEXT OF THE MESSAGE TO ALL REMAINING USERS.
</if></if></if></if></if>
Does it work? I think so (Not so sure about the subtraction in an <if> tag on that last conditional). But digging through that anytime you want to change one of those can be a pain.

Anyway, if you absolutely must do some hacking, you can perform the following hack to optimize this template modification.

In your global.php file look for this code
PHP Code:
// identify where we are
define('VB_AREA''Forum'); 
Directly after it add the following:

PHP Code:
$globaltemplates array_merge($globaltemplates,
        array(
            
'announcement_all',
            
'announcement_guest',
            
'announcement_pending',
            
'announcement_staff',
            
'announcement_noposts',
            
'announcement_noposts14days',
            
'announcement_registered'
               
)
); 
What that does is cache these 7 templates before they called, resulting in fewer MySQL queries (anytime you fetch an uncached template you cause another query to occur).

I'll leave you with EN World's contents of each of these messages to give you some ideas on what to put in each one in order to encourage folks to post and join you're community.

ANNOUNCMENT_GUEST
HTML Code:
<b>Welcome to EN World, one of the busiest <i>Dungeons &amp; Dragons</i> and 
d20 System fan sites on the internet. You will need to <a href="register.php">join EN World</a> for 
free before you can post messages or use many of the site's features, but you are welcome to read the
boards and news without joining. Please feel free to join and participate in the friendly discussions 
of all things D&amp;D and d20!</b>
ANNOUNCEMENT_NOPOSTS
HTML Code:
Welcome!!  You're seeing this message because you have successfully completed your registration but you've never posted. We'd love to hear from you.  <a href="newreply.php?do=newreply&noquote=1&p=1828845">Click here</a> to say Hello and maybe even post a few details about yourself<br />
<br />
Oh, and welcome to EN World.
ANNOUNCEMENT_NOPOSTS14DAYS
HTML Code:
Hello.  You're seeing this message because you haven't posted in the last 14 days. While participation in the forums isn't required, it is encouraged. We'd love to hear your comments and opinions on all things gaming related.
ANNOUNCEMENT_PENDING
HTML Code:
Welcome to EN World!  You have registered a new account, but you still
 need to verify your email address. Please check your email for details on how to do this, or 
 <a href="register.php?$session[sessionurl]do=requestemail">click here</a> to be sent a new verification 
 email. If you did not receive the email then it's possible it was blocked by your email client. 
 In this case you can either disable your blocker software or enter a new email address in 
 <a href="profile.php?$session[sessionurl]do=editpassword">your profile</a>
ANNOUNCMENT_REGISTERED
HTML Code:
<b>Welcome to EN World!  Please consider becoming a <a href="http://www.enworld.org/forums/subscriptions.php?">community supporter</a>.  A community supporter is somebody who has donated to EN World in order to help cover the costs of very server-intensive, and thus expensive features (in particular, the search feature). The features available only to community supporters are Search, Private Messaging, Custom User Titles, Who's Online and EN World's in-built RPG. Note that you can also get these features separately.</b>
Well, I think that's all. I hope this helps someone.

Supporters / CoAuthors

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 07-08-2004, 05:07 AM
SnowBot's Avatar
SnowBot SnowBot is offline
 
Join Date: Jul 2003
Location: Manchester UK
Posts: 631
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Screenshots please :0
Reply With Quote
  #3  
Old 07-08-2004, 06:16 AM
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Location: Knoxville TN
Posts: 774
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, these are two of the three messages we have (the third is a reminder to users awaiting email confirmation about what they need to do to activate their account fully - since it's annoying to log out and make up a dummy account, then delete that account after the screen shot, I'll skip it).
Reply With Quote
  #4  
Old 07-08-2004, 10:52 AM
The Realist's Avatar
The Realist The Realist is offline
 
Join Date: Oct 2001
Location: UK
Posts: 842
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Where in $phpinclude_start does your code go, it does not say in the instructions?
Reply With Quote
  #5  
Old 07-08-2004, 04:00 PM
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Location: Knoxville TN
Posts: 774
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by The Realist
Where in $phpinclude_start does your code go, it does not say in the instructions?
At the very start.
Reply With Quote
  #6  
Old 07-08-2004, 10:37 PM
Erwin's Avatar
Erwin Erwin is offline
 
Join Date: Jan 2002
Posts: 7,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You could do this with just conditionals in the header template.
Reply With Quote
  #7  
Old 07-08-2004, 10:38 PM
Jolten Jolten is offline
 
Join Date: Mar 2004
Posts: 749
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Erwin
You could do this with just conditionals in the header template.
Actually I had already
Reply With Quote
  #8  
Old 07-10-2004, 10:01 PM
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Location: Knoxville TN
Posts: 774
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Erwin
You could do this with just conditionals in the header template.
Using conditionals implies I know what variables are available for conditionals. I never have found such a list. This hack was born out of the miserable users hack - I borrowed the first line of that hack (the is member of check) to build this one.
Reply With Quote
  #9  
Old 07-10-2004, 10:05 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Michael_Morris
Using conditionals implies I know what variables are available for conditionals. I never have found such a list. This hack was born out of the miserable users hack - I borrowed the first line of that hack (the is member of check) to build this one.
You sorta just need to learn what varibles are avaible there are tons apon tons.

But specficly you can use

<if condition="$bbuserino[usergroupid] == X">

Or

<if conditon="is_member_of($bbuserinfo, X)">
Reply With Quote
  #10  
Old 10-30-2004, 09:09 AM
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Location: Knoxville TN
Posts: 774
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Bumping this up after a long dormancy. I complete rewrote the first message here, so the replies between this post and the start probably don't make much sense.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:46 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04683 seconds
  • Memory Usage 2,331KB
  • Queries Executed 24 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (6)bbcode_html
  • (3)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete