vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   Dynamic Announcements: Programmable Forum Home Announcement/Message with conditionals (https://vborg.vbsupport.ru/showthread.php?t=64189)

Logician 04-20-2004 10:00 PM

Dynamic Announcements: Programmable Forum Home Announcement/Message with conditionals
 
This hack allows you to post powerful dynamic announcements (changing according to different conditions) on forum home page. It differs from vbulletin's default announcements in 2 ways:
  • The announcement is displayed in forum home page, not inside thread view. So visitors will read them on home page without clicking any links.
  • The Hack's announcements are not static: ie. they can be powerfully programmed to display themselves according to many conditions.

This hack is the VB3 version of my Dynamic Forum Home Announcement Hack and it is a bit more improved in that it is now able to display your announcement as it was before AND also in DHTML popup box as well which ever you prefer better or even both. (DHTML poupup announcement is not technically a popup so popup killers can not kill it either.)

Basic Usage : You can set a text in your Admin CP and it's displayed in forum home to all users.

Advanced Usage : With conditionals you can set different texts/notifications/messages/announcements and they will be displayed if your pre-configured condition applies. This allows you to create powerful announcements/private messages/texts which address their receipt only if a certain condition is met. Some examples:

You can set to show an announcement in forum home IF:
  1. user is X
  2. user's usergroup is Y
  3. his profile field Z is X
  4. user has X posts or has more than Y posts but less than Z posts
  5. his last visit time was X days ago
  6. today is X, hour is between Y and Z, day is wednesday, month is Y, week is month's 2nd week, today is user's birthday
  7. User is invisible/visible
  8. his timeset is set to A
  9. etc.

It's tested in vb versions from v.3.0.0 to 3.0.9 and works fine with all of them. It will work for all future 3.0.x versions too. For vb2 version click here.

Here is a Screenshot from a general table announcement.
Here is a Screenshot from a popup announcement.

Some Features:
  • It's Admin CP integrated (Screenshot)
  • Smiley, BBCode, HTML, IMG tags are supported in announcements.
  • You can address your users with their usernames inside announcements (Use $bbuserinfo[username] variable)
  • Announcements are displayed directly in Forum Home so users are forced to read them.
  • The Conditionals help you to design powerful and ever changing announcements/private messages/forum home notifications.
  • Poupup announcement can not be killed by popup killer software

If you install the hack, click INSTALL, thank you..

Hacks of the hack:
* Hack 1: Puts the announcement into header instead of forum home page so that announcement appears in all forum pages.
* Hack 2: Integrates announcement with vBA_CMPS portal hack.
* Hack 3: Popup announcement will popup once in every XX hours.


Logician \\=^))

Logician 04-21-2004 11:17 AM

How To Use - Conditionals Help

After you installed the hack:

Basic Usage:

If you want to display an announcement to ALL users, simply login to Admin CP/Choose VB Settings/Dynamic Forum Announcements and enter your announcement as a plain text into the box. You can use smilies and all other bbcode in your announcements. This text will be dragged to your forum home regardless of whoever the page visitor is. You can use the poup box if you want to display the annnoucement as popup and the other box if in a table in forum home.

Advanced Usage:
You can use "conditionals" to set announcements displayed if a certain condition applies. If you are using my WebTemplates Hack , you should be already familiar with the term "conditional". In Webtemplates conditionals could be used to put different texts/HTML codes which will be parsed if certain condition appied in your non-vb pages. It's the same concept and their usage is same. Here is its format:

[[(your conditional)]] Your Announcement [[/(your conditional)]]

Conditional Rules:
  • Conditionals are covered inside [[ ]] tags
  • Conditional itself is in paranthesis ( )
  • Announcements are written in between the conditional tags
  • Opening and closing conditional are exactly same except closing conditional has a / right before (
  • If you are trying to check if a X equals to Y use DOUBLE equation mark not single. eg. Correct: X==Y Incorrect:X=Y
  • You can design as many conditional as you like. If more than 1 condition applies at the same time, the conditional which is above (=higher priority) is parsed.
  • If you write a plain text without a conditional together with other conditionals, this text is considered "default announcement" and displayed if no conditions applies.
Some examples will help you understand the rules better. Here are some conditionals and the announcement texts which explains what that conditional do:

* [[($bbuserinfo[userid]==32)]] Show this announcement if page visitor's user id is 32 [[/($bbuserinfo[userid]==32)]]

* [[($bbuserinfo[usergroupid]==5)]] Show this announcement if page visitor's usergroupid is 5 (=if he is a Super Mod) [[/($bbuserinfo[usergroupid]==5)]]

* [[($bbuserinfo[usergroupid]==1)]] Show this announcement if page visitor is a guest [[/($bbuserinfo[usergroupid]==1)]]

* [[($bbuserinfo[userid]>1)]] Show this announcement if page visitor is NOT a guest [[/($bbuserinfo[userid]>1)]]

* [[($bbuserinfo[usergroupid]==5 OR $bbuserinfo[usergroupid]==6 OR $bbuserinfo[usergroupid]==7)]] Show this announcement if page visitor's a Super Mod OR a Mod OR an Admin [[/($bbuserinfo[usergroupid]==5 OR $bbuserinfo[usergroupid]==6 OR $bbuserinfo[usergroupid]==7)]]

* [[($bbuserinfo[posts]<10)]] Show this announcement if page visitor has less than 10 posts [[/($bbuserinfo[posts]<10)]]

* [[($bbuserinfo[lastvisit] and $bbuserinfo[lastvisit]<strtotime(-30 days))]]Show this announcement if page visitor has not visited your board for 30 days[[/($bbuserinfo[lastvisit] and $bbuserinfo[lastvisit]<strtotime(-30 days))]]

* [[($bbuserinfo[joindate]>strtotime("-2 weeks") AND $bbuserinfo[joindate]<strtotime("-4 weeks"))]]Show this announcement if page visitor registered in a date between 2 weeks to 4 weeks from now[[/($bbuserinfo[joindate]>strtotime("-2 weeks") AND $bbuserinfo[joindate]<strtotime("-4 weeks"))]]

You can use conditionals together too. Here is an example:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[[($bbuserinfo[userid]==32)]] Announcement 1 [[/($bbuserinfo[userid]==32)]]
[[($bbuserinfo[usergroupid]==3)]] Announcement 2 [[/($bbuserinfo[usergroupid]==3)]]
Announcement 3
-=-=-=-=-=-=-=-=-=-=-=-=-=-=
If you set this text as your announcement, the hack will:
Show Announcement 1, if user's userid = 32
Show Announcement 2, if user's usergroupid = 3 (=email confirmation waiting members)
show Announcement 3, For ALL other users

What if user 32 is also from user groupid 3? He will be displayed Announcement 1 because even if he matches both conditional 1 and conditional 2, conditional 1 (which is above) has a higher priority.

Hope this document helps you to understand the term conditional. Needless to say my hack's conditional syntax is different than vb3's default conditional syntax and this is because I use my syntax for a long time (before vb3 was up).

If you need more help to design a "conditional", before asking me please read this document carefully for a few times, try to form it by yourself and if they all fail, ask in the hack's thread giving details about exactly what conditional you tried to form and what text (format) have you tried (and failed). You are welcomed to ask them in thread but my apologies in advance if I'm too busy to answer all questions. Thank you.

lasto 04-21-2004 11:22 AM

sounds good logician - i used the one on vb2 so will be using this as well

[high]* lasto clicks install :)[/high]

Red Blaze 04-21-2004 01:37 PM

This will totally help me out! Thank you! Will install tonight. :)

EDIT: I was reading over the txt file, and it says add 4 new templates... I only see 3 there. o.o;

announcement, announcement_headercode, and announcement_popup. Or did I miss something.

Logician 04-21-2004 01:59 PM

Quote:

Originally Posted by Sonikku
EDIT: I was reading over the txt file, and it says add 4 new templates... I only see 3 there. o.o;

announcement, announcement_headercode, and announcement_popup. Or did I miss something.

Yes they are 3, not 4. I corrected the .txt file, thx for the heads up.

AlexanderT 04-21-2004 02:09 PM

wow complex hack ;) Will definitely give it a closer look!

Logician 04-21-2004 02:23 PM

Quote:

Originally Posted by AlexanderT
wow complex hack ;) Will definitely give it a closer look!

Actually not so complex. But I guess I fail to narrate it simply :)

To put it in a more simple way I can tell it this way:

If you put a text inside the box 1 in this admin cp settings, this text appears in your forum home like this. If you enter a text in the second box, then it appears like this. ;)

Zelda-King 04-21-2004 05:54 PM

I tried out an ! conditional. Say for example I use "[[($bbuserinfo[usergroupid]!==6)]]", the message tries to load (if you're usergroup 6) but cannot (works for everyone else of course). I get a perpetual browser alert saying about 'transferring data from domain.com'.

Also, I suppose we can use multi-conditionals for one announcement like [[($bbuserinfo[usergroupid]==5 || $bbuserinfo[usergroupid]==6 || $bbuserinfo[usergroupid]==7)]]?

Tests...

SaN-DeeP 04-21-2004 06:17 PM

mod screenshots seems quit impressive :)
i will TRY this for sure.

thnx for nice HACK..

Zelda-King 04-21-2004 06:54 PM

Tested it. Multi conditionals DO work... at least for two. Doesn't seem to want to work for three when I use the NOT condition.

Example of what I'm trying to do;

[[($bbuserinfo[usergroupid]!==8 || $bbuserinfo[usergroupid]!==13 || $bbuserinfo[userid]!==1)]]For people not userid 1 or usergroups 8 or 13[[/($bbuserinfo[usergroupid]!==8 || $bbuserinfo[usergroupid]!==13 || $bbuserinfo[userid]!==1)]]

Logician 04-21-2004 07:57 PM

Quote:

Originally Posted by Zelda-King
Doesn't seem to want to work for three when I use the NOT condition.

Your syntax is wrong. Not is NOT !== it is !=
so correct syntax is
[[($bbuserinfo[usergroupid]!=8 AND $bbuserinfo[usergroupid]!=1 AND $bbuserinfo[usergroupid]!=13)]]
your announcement here
[[/($bbuserinfo[usergroupid]!=8 AND $bbuserinfo[usergroupid]!=1 AND $bbuserinfo[usergroupid]!=13)]]

Zelda-King 04-21-2004 08:05 PM

Hmm, forgot that one. Let me try that on my first issue right now...

Update: Everything works fine, yes. So it was my fault. The hack's fine. I like everything except the DHTML function. The presentation needs touching up and I don't suppose there's a way of making it not pop up EVERY time one goes to Forum Home?

Boofo 04-21-2004 08:35 PM

Can we also use the built-in conditionals for vB3 with this?

Logician 04-21-2004 09:21 PM

Quote:

Originally Posted by Boofo
Can we also use the built-in conditionals for vB3 with this?

nope

Boofo 04-21-2004 09:27 PM

Are you planning on releasing a version that does?

Logician 04-21-2004 09:43 PM

Quote:

Originally Posted by Boofo
Are you planning on releasing a version that does?

Nope. I'm happy with my own conditional syntax, use it in many of my hacks and it is older than vb3's conditional syntax anyway. So I don't plan to create a new syntax in my hacks.

Besides my to-do (ie to-port) list is too long and I can barely find time to port my vb2 hacks into vb3. I believe I can not spend time for such add-on features.

M.C. 04-21-2004 09:58 PM

can`t wait to check it out ;) Sounds really cool to me ;)

Pitman 04-21-2004 11:09 PM

When I get to step 2 (After uploading the edited options.php) I get the following parse error:

Quote:

Parse error: parse error in /home/*****/public_html/forums/admincp/options.php on line 116
The code that is on line 115-117 of my options.php is:

Code:

                {
                        $xml .= "\t<setting varname=\"$set[varname]\" displayorder=\"$set[displayorder]\"" . iif($set['advanced'], '],' advanced="1"') . ">\r\n";
                        if ($set['optioncode'] != '')


Boofo 04-21-2004 11:47 PM

Quote:

Originally Posted by Logician
Nope. I'm happy with my own conditional syntax, use it in many of my hacks and it is older than vb3's conditional syntax anyway. So I don't plan to create a new syntax in my hacks.

Besides my to-do (ie to-port) list is too long and I can barely find time to port my vb2 hacks into vb3. I believe I can not spend time for such add-on features.

Ok, well, thanks. That answered my question.

Red Blaze 04-22-2004 03:05 AM

Installed and works Great! :)
[high]* Red Blaze clicks install[/high]

ixian 04-22-2004 03:30 AM

This is the kind of hack that sneaks up on you. At first, you don't think you'd have much use for it, until you realize what it can really do.

Posting a message just for people waiting for email confirmation alone is worth the time to install this. I get tons of new users who don't know to do that, or put in fake email addresses, then email me when they can't post. I'm giving them a special popup that reminds them from now on until they confirm:)

I can also leave private messages for admins and such. I love this hack.

Red Blaze 04-22-2004 03:52 AM

lol Same reason I use it for ixian. And for admins since we're gonna run a SC Tournament soon. Thanks again Lugician, this came in handy big time, I believe I got use to the conditionals. :)

BTW: This adds a query, right? I've noticed that it went from 12 to 13. ^^;

ixian 04-22-2004 04:27 AM

I do love this hack so.

It works fine on my forum home page. Now I am trying to figure out how to get it to work with vbAdvanced's index.php. Because that would be, you know, boss.

Edit - Figured it out! See below for solution

ixian 04-22-2004 04:56 AM

BTW, here's my conditional to give a popup to users who haven't confirmed their email registration yet, in case any one else wants to use it. It provides a link to edit their profile/email (in case they didn't read and used a fake email address) and to have the activation email re-sent.

PHP Code:

[[($bbuserinfo[usergroupid]==3)]][SIZE=4][B]IMPORTANTREAD THIS[/B][/SIZE]

Hello [b]$bbuserinfo[username][/b]! You are seeing this message because you have not yet confirmed your registration via the email we sent youYou will not be able to post or use other features of the site until you do. Please click the activation link in the email you were sent, or visit <a href="register.php?$session[sessionurl]do=requestemail">this page</ato resend the activation 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> Thanks for coming by! This message will dissappear once you confirm your registration.[[/($bbuserinfo[usergroupid]==3)]] 

That's the standalone version of course, I'm using it with the conditionals to display different messages to different groups, as outlined in Logicians excellent tutorial. Have fun.

ixian 04-22-2004 05:17 AM

Aha!!! I have it working for vbadvanced! Now it shows up all throughout your site, assuming you are using it:)

Mini-mod for vba:

Install hack as normal, confirm it works.

Edit vbadvanced's index.php

Find:

PHP Code:

'bbcode_quote'
); 

Add under

PHP Code:

// Logician Hack: Dynamic Forum Announcements Hack
$globaltemplates[] = 'dfh_announcement';
$globaltemplates[] = 'dfh_announcement_headercode';
$globaltemplates[] = 'dfh_announcement_popup';
// Logician Hack: Dynamic Forum Announcements Hack 


Find

PHP Code:

######################### News ######################### 

Add ABOVE

PHP Code:

// Logician Hack: Dynamic Forum Announcements Hack
if ($vboptions['dynamic_fha'] OR $vboptions['dynamic_popup']) {require_once('./includes/functions_bbcodeparse.php');}

if (
$vboptions['dynamic_fha'])
{
eval(
'$dynamic_fha = "' addslashes($vboptions['dynamic_fha']) . '";'); 
$dynamic_fha=str_replace("\\'""'"$dynamic_fha);
$dfh_announcement_announcementtopaste dynamic_a($dynamic_fha);
if (
trim($dfh_announcement_announcementtopaste)) {eval('$dfh_announcement = "' fetch_template('dfh_announcement') . '";');}
}

if (
$vboptions['dynamic_popup'])
{
eval(
'$dynamic_popup = "' addslashes($vboptions['dynamic_popup']) . '";'); 
$dynamic_popup=str_replace("\\'""'"$dynamic_popup);
$dfh_announcement_popuptopaste dynamic_a($dynamic_popup);
if (
trim($dfh_announcement_popuptopaste)) 
    {
    eval(
'$dfh_announcement_headercode = "' fetch_template('dfh_announcement_headercode') . '";');
    eval(
'$dfh_announcement_popup = "' fetch_template('dfh_announcement_popup') . '";');
    }
}

// Logician Hack: Dynamic Forum Announcements Hack 

Now, edit your vbAdvanced INDEX template.

Find:

</head>

Add ABOVE

$dfh_announcement_headercode

Find:

$header
$navbar

CHANGE TO:

$dfh_announcement_popup
$header
$navbar
$dfh_announcement


Or put the two announcement bits wherever you want them to appear. Don't forget to do this for all your styles.

I may add this to the add-on hack section, but it's such a little mod - no code changes, just figuring out where the code goes in vba's scheme of things - it may not be worth the bother.

Enjoy, and thanks again Logician for a great hack!

Logician 04-22-2004 06:34 AM

Quote:

Originally Posted by Pitman
When I get to step 2 (After uploading the edited options.php) I get the following parse error:

Make sure you applied STEP 1 correctly.

Logician 04-22-2004 06:39 AM

Quote:

Originally Posted by Sonikku
BTW: This adds a query, right? I've noticed that it went from 12 to 13. ^^;

Actually no. It shouldnt add any queries because the announcement comes with vb settings so no additional database connection is made.

Quote:

Originally Posted by ixian
Aha!!! I have it working for vbadvanced! Now it shows up all throughout your site, assuming you are using it

Thx for sharing it ixian.

MrNase 04-22-2004 02:37 PM

Very nice :)

I'll use that to remind my users of activating their account :)

thank you logician.

[high]* MrNase click install[/high]

gmarik 04-22-2004 02:45 PM

REally advanced

Sketch 04-22-2004 02:50 PM

The default vbAdv install as $index_header not $header -- I believe. But I got it. ;) Nice hacks all around.

ixian 04-22-2004 03:18 PM

Quote:

Originally Posted by Sketch
The default vbAdv install as $index_header not $header -- I believe. But I got it. ;) Nice hacks all around.

Oops. Sorry bout that:)

Shouldn't matter anyway, since by that step you can stick the bits wherever you want them to appear, you don't need to follow the instructions to the letter:)

Pitman 04-22-2004 07:15 PM

Quote:

Originally Posted by Logician
Make sure you applied STEP 1 correctly.

Lol, I did, there is only 2 instances of what to search for and replace, I did it exactly as the instructions say

ixian 04-22-2004 09:26 PM

Quote:

Originally Posted by Pitman
Lol, I did, there is only 2 instances of what to search for and replace, I did it exactly as the instructions say


"Lol", you obviously didn't, because this hack is working for the rest of us. You must have missed something. Go over it again, line by line.

dsotmoon 04-22-2004 10:29 PM

Quote:

login Admin CP, choose VB settings, click Forum Home Page Options and find "Dynamic Forum Home Announcements" box.

The dynamic forum announcement box isnt showing up in my adminCP although the welcome box is showing fine on forum home, what did i do wrong? or what part of the hack do i need to redo?

dsotmoon 04-22-2004 10:34 PM

duh! nevermind, it works great, i was confused.

Logician 04-23-2004 05:51 AM

Quote:

Originally Posted by Pitman
Lol, I did, there is only 2 instances of what to search for and replace, I did it exactly as the instructions say

If you are sure you did it correctly, then your problem is more likely related to your text editor. Always use notepad or a similiar text editor to apply hacks, not HTML software like Dreamweaver or Frontpage. They tend to change certain lines in PHP scripts without letting you know and this can cause parse errors.

lasto 04-23-2004 07:42 AM

weirdest thing mine dont appear under one another likes yours do.When i went to do the code for one of them (the green popup) it said it was a duplicate entry and would`nt allow it so in my options i have 2 seperate otions - one for the box and one for the popup.

Is this cause i had the old hack of yours on vb2 and just upgraded the board to vb3

Logician 04-23-2004 08:33 AM

Quote:

Originally Posted by lasto
weirdest thing mine dont appear under one another likes yours do.When i went to do the code for one of them (the green popup) it said it was a duplicate entry and would`nt allow it so in my options i have 2 seperate otions - one for the box and one for the popup.

Is this cause i had the old hack of yours on vb2 and just upgraded the board to vb3

yes. you need to delete the old record before installing this one. To do it add:
PHP Code:

$debug=1

to your config.php file right before ?> and upload the file. Now login to your admin cp, choose settings and then the settings of my hack. You'll see the link to remove it. After you removed it, you can also remove the debug line from your config.php, upload it back and then install the hack.

lasto 04-23-2004 01:49 PM

cheers for help once again - worked fine :)

Highlander 04-24-2004 05:04 AM

i cant wait for VB Templates :D ,, i did the change last week to vb3.0 .. and must leave the exisitng webtepmaplte section alone :(

.. my dreams come trough .. if you manage to port webtemplates :D

you are my hero :D

..EDIT:
uhh sorry..thought i was posting in your annhouncment Thread :) .. delete this post..


All times are GMT. The time now is 10:44 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01728 seconds
  • Memory Usage 1,884KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (6)bbcode_php_printable
  • (16)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete