vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Programming Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=188)
-   -   Using PHPINCLUDE_START. (Last Lesson - #7 - Added 12-16-4) (https://vborg.vbsupport.ru/showthread.php?t=71313)

Michael Morris 12-14-2004 09:47 PM

Lesson #6 added. Sorry for the long delay - been getting back into the swing of classes and also having trouble coming up with new ideas for lessons.

Michael Morris 12-16-2004 10:15 PM

Bump - Lesson 7 added.

darnoldy 12-26-2004 07:46 PM

Michael-

Tried to apply your lesson on announcements but have not succeeded. Somewhere I'm missing something. Hope you can help!

1. created new templates:
newsflash_all
newsflash_guest
newsflash_noposts
newsflash_pending
newsflash_staff
newsflash_subexpiring

2. Added the following to phpinclude_start:
PHP Code:

// ##################################################### 
// #####+++++++++++ +START NEWSFLASHES+++++++++++++##### 
// ##################################################### 

eval( '$newsflash = "' .fetch_template ('newsflash_all' ) . '";' ); 

if (empty( 
$newsflash )) //If it's empty we'll get our usergroup newsflashs 
{
    if ( 
is_member_of ($bbuserinfo ,1))   // Guests 
    
{
        eval( 
'$newsflash = "' .fetch_template ('newsflash_guest' ) . '";' ); 
    } 
    else if ( 
is_member_of ($bbuserinfo ,3)) // Pending Registrant 
    
{
        eval( 
'$newsflash = "' .fetch_template ('newsflash_pending' ) . '";' ); 
    } 
    else if ( 
is_member_of ($bbuserinfo ,4)// Mods 
        
OR is_member_of ($bbuserinfo ,5)// Supermods 
        
OR is_member_of ($bbuserinfo ,6)) // Admins 
    
{
        eval( 
'$newsflash = "' .fetch_template ('newsflash_staff' ) . '";' ); 
    } 
    else if ( 
$bbuserinfo ['posts' ] == 0)// User has never posted. Encourage them. 
    
{
        eval( 
'$newsflash = "' .fetch_template ('newsflash_noposts' ) . '";' ); 
    } 
    else if ( 
1209600 )// Placeholder for subscription expiration notice 
    
{
        eval( 
'$newsflash = "' .fetch_template ('newsflash_subexpiring' ) . '";' ); 
    } 


3. Called the appropriate template by inserting:
HTML Code:

$newsflash
in the forum_home template.

it doesn't display the content of the newsflash template. What did I miss?

--DON

Michael Morris 12-26-2004 11:01 PM

You don't have a default - so it could be working silently in the background.

I don't see anything straight off, but check things one line at a time. First check to make sure the insert to your forumhome template is working correctly. To do this put $newsflash in the template and then set it to a value straight out in the PHPINCLUDE_START template

PHP Code:

$newsflash 'test'

If that works, put a value in your newsflash_all statement and check to make sure the eval statement syntax is correct.

(Note - if you have multiple styles it's important to put these templates into either one grand parent of all your styles or into each style individually - fetch template can't call up a template that doesn't exist in the current style).

If that works check your conditionals, one at a time, to insure they work.

If you have any other problems check with me.

darnoldy 12-27-2004 02:33 AM

Michael-
Quote:

Originally Posted by Michael Morris
check your conditionals

okay, I found *where* its not working:

PHP Code:

eval( '$newsflash = "' .fetch_template ('newsflash_all' ) . '";' ); 

if (empty( 
$newsflash )) //If it's empty we'll get our usergroup newsflashs 
{
    
$newsflash 'test-true';



The first statement will pass the contents of 'newsflash_all' properly.

The If statement tests false--with 'newsflash_all' as empty as I can make it.

I don't know enough php to know if this is a mal-formed statement, or something else.


--don

Michael Morris 12-27-2004 02:50 AM

Try this

PHP Code:

trim($newsflash

That will remove unnecessary spaces.

Hence

PHP Code:

eval( '$newsflash = "' .fetch_template ('newsflash_all' ) . '";' );
trim($newsflash);

if (empty( 
$newsflash )) //If it's empty we'll get our usergroup newsflashs
{
    
$newsflash 'test-true';



If $newsflash has even a single space, it isn't empty. If it's nothing but spaces are there trim will removed them and leave it null.

wirewolf 01-12-2005 11:39 AM

Michael, great tutorial. I've added the "Annoucements" and the "My Links". Both are working. I added one other conditional for those interested. I have a few members whose email keeps bouncing. So I created a new usergroup (Bounced Email), and added these members to it. Then created a new annoucement (announcement_bouncedmail) and added it to the array of annoucements in phpinclude_start. See below (XX is the number of this new group):
Quote:

else if (is_member_of($bbuserinfo, XX)) // Bounced Mail
{
eval('$announcement = "' . fetch_template('announcement_bouncedmail') . '";');
}
How do I know if it works? I have a couple of "test" users accounts invisible to the other members. One has an email address that I know will bounce. After logging myself off and clearing cookies, I logged on as this test user, and there was the "Bounced Email" message. Part of this message is for these users to correct (update) their email address(s). I changed the permissions for this group so they can't post until they fix their email problem. If they fail to visit the forum after awhile, and after repeated attempts to contact them, I'll just delete the users' accounts.

BTW, these messages have had the desired effect. Especially for the "noposts" and the "noposts14days". Quite a few of my users that have not posted or not posted in awhile, and have visited the forum, have gotten the message and made a post. In part of my nopost and nopost14days messages I put in a link to my "Indroduction" forum as a suggestion, and it's worked!

I also created new phrases for insertion into the different announcement templates. Makes it easier to make message changes later on.

One question. I have two new required profile fields on registration (forces new registrants, but not old members). Part of the messages for members (all old exsisting members) that I have now is for them to check these new fields in the UserCP, but it does not force them to fill these out. I guess I could create another usergroup for those members that have not filled out these fields and include it in the phpinclude_start as another annoucement or is there a way do include the conditional for these "$post[fieldX]'s" into the annoucement templates I have now? I was looking at Revan's "Newbie Lock mod" and thinking of adapting it for this purpose. But his mod forces the user to a particular forum, not reguired profile fields. It's never easy! :rolleyes:
Thanks, wirewolf

Sooner95 01-20-2005 04:53 PM

Nice stuff, good work.. Added the My Links to my site, works great.. thx!

Michael Morris 01-21-2005 03:21 AM

Quote:

Originally Posted by wirewolf
Michael, great tutorial. I've added the "Annoucements" and the "My Links". Both are working. I added one other conditional for those interested. I have a few members whose email keeps bouncing. So I created a new usergroup (Bounced Email), and added these members to it. Then created a new annoucement (announcement_bouncedmail) and added it to the array of annoucements in phpinclude_start. See below (XX is the number of this new group):
How do I know if it works? I have a couple of "test" users accounts invisible to the other members. One has an email address that I know will bounce. After logging myself off and clearing cookies, I logged on as this test user, and there was the "Bounced Email" message. Part of this message is for these users to correct (update) their email address(s). I changed the permissions for this group so they can't post until they fix their email problem. If they fail to visit the forum after awhile, and after repeated attempts to contact them, I'll just delete the users' accounts.

BTW, these messages have had the desired effect. Especially for the "noposts" and the "noposts14days". Quite a few of my users that have not posted or not posted in awhile, and have visited the forum, have gotten the message and made a post. In part of my nopost and nopost14days messages I put in a link to my "Indroduction" forum as a suggestion, and it's worked!

I also created new phrases for insertion into the different announcement templates. Makes it easier to make message changes later on.

One question. I have two new required profile fields on registration (forces new registrants, but not old members). Part of the messages for members (all old exsisting members) that I have now is for them to check these new fields in the UserCP, but it does not force them to fill these out. I guess I could create another usergroup for those members that have not filled out these fields and include it in the phpinclude_start as another annoucement or is there a way do include the conditional for these "$post[fieldX]'s" into the annoucement templates I have now? I was looking at Revan's "Newbie Lock mod" and thinking of adapting it for this purpose. But his mod forces the user to a particular forum, not reguired profile fields. It's never easy! :rolleyes:
Thanks, wirewolf

I'm in the middle of switching the servers at ENWorld - when I'm done with that (hopefully by this time next week) I'll take a closer look at your questions and answer them if I can.

@Sooner95 - thx.

wirewolf 03-01-2005 07:11 PM

Hi Michael.
This is a weird one. I've had "My Links" installed on my site (vb v.3.0.7) for awhile. Today I noticed something strange happening with the "My Links". If I view a post, any post, while logged in, select the "View Single Post" link, close that window, refresh the original post, I then see the list of "My Links" in the post. This happens with any post, no matter who posted it, not just mine. If I go to the edit box for that post and hit the Save Changes button, the post reverts back to normal.
I asked one of my members that uses "My Links" also, to log in to the forum, pick out any post, and repeat the same sequence. He PM'd me and reported , in dis-believe, that he too saw his "Links" in the post. I had to go and open the edit box for that post, hit save changes, and the post reverted back to normal.
Best way is to see some screen shots.
Any clues to this one?
BTW, checked the code in phpinclude_start, it's fine.


All times are GMT. The time now is 02:40 AM.

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.01124 seconds
  • Memory Usage 1,796KB
  • 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_html_printable
  • (5)bbcode_php_printable
  • (3)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
  • (10)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