Creating condition statements

Discussion forum for MOD Writers regarding MOD Development.
Locked
tonyjms2005
Registered User
Posts: 184
Joined: Fri Feb 08, 2008 6:52 pm

Creating condition statements

Post by tonyjms2005 »

Hello

I am wondering if it is possible to create a conditioning statement for a new user's first login for example:

Code: Select all

<!-- IF S_FIRST_LOGIN -->
Can anyone help with this as I believe I must add some coding to the functions files.

Thanks

Antony
Tribute to Them

http://tributetothem.com/phpbb3/index.php

Let their memory Live. Forever!
User avatar
A_Jelly_Doughnut
Former Team Member
Posts: 34457
Joined: Sat Jan 18, 2003 1:26 am
Location: Where the Rivers Run
Contact:

Re: Creating condition statements

Post by A_Jelly_Doughnut »

In virtually any file in phpBB, you can call

Code: Select all

$template->assign_vars(array(
 'S_SOME_BOOL' => (!empty($use_pcre)) ? true : false,
));
This would create the condition <!-- IF S_SOME_BOOL -->
A Donut's Blog
"Bach's Prelude (Cello Suite No. 1) is driving Indiana country roads in Autumn" - Ann Kish
tonyjms2005
Registered User
Posts: 184
Joined: Fri Feb 08, 2008 6:52 pm

Re: Creating condition statements

Post by tonyjms2005 »

Thanks, just one other question, is there a condition statement already in place in phpbb3 to represent 0 posters.

Thanks

Antony
Tribute to Them

http://tributetothem.com/phpbb3/index.php

Let their memory Live. Forever!
ChaosBringer
Registered User
Posts: 412
Joined: Mon Apr 19, 2004 11:30 pm
Contact:

Re: Creating condition statements

Post by ChaosBringer »

Do you mean a function that returns all the users with 0 posts?

I think the correct place to look would be
acp_inactive
acp_prune


What exactly are you trying to do?

01000001 01101100 01101100 00100000 01111001 01101111 01110101 01110010 00100000 01100010 01101001 01101110 01100001 01110010 01111001 00100000 01100001 01110010 01100101 00100000 01100010 01100101 01101100 01101111 01101110 01100111 00100000 01110100 01101111 00100000 01110101 01110011 00100001
tonyjms2005
Registered User
Posts: 184
Joined: Fri Feb 08, 2008 6:52 pm

Re: Creating condition statements

Post by tonyjms2005 »

Hi

Thanks for the reply

Basically I have been creating step by step tips and instructions on my site.

But I only want certain objects visible to zero posters.

For example:

Code: Select all

<!-- IF_S_ZERO_POSTER -->some object<!-- ENDIF -->
I know how to implement this on the template but the coding for the function is a bit out of my depth :oops:

Thanks

Antony
Tribute to Them

http://tributetothem.com/phpbb3/index.php

Let their memory Live. Forever!
ChaosBringer
Registered User
Posts: 412
Joined: Mon Apr 19, 2004 11:30 pm
Contact:

Re: Creating condition statements

Post by ChaosBringer »

um...something like

Code: Select all

$template->assign_var( 'S_USER_ZERO_POSTS', ( !empty( $user->data['user_posts'] ) && ( $user->data['user_posts']  == 0 ) ) ? true : false );

? :P

01000001 01101100 01101100 00100000 01111001 01101111 01110101 01110010 00100000 01100010 01101001 01101110 01100001 01110010 01111001 00100000 01100001 01110010 01100101 00100000 01100010 01100101 01101100 01101111 01101110 01100111 00100000 01110100 01101111 00100000 01110101 01110011 00100001
tonyjms2005
Registered User
Posts: 184
Joined: Fri Feb 08, 2008 6:52 pm

Re: Creating condition statements

Post by tonyjms2005 »

hi

I tried that but I get this error:

Code: Select all

Notice: Undefined variable: template in /misc/39/000/169/186/5/user/web/tributetothem.com/test area/phpBB3/includes/functions.php on line 4643

Fatal error: Call to a member function assign_var() on a non-object in /misc/39/000/169/186/5/user/web/tributetothem.com/test area/phpBB3/includes/functions.php on line 4643
Any ideas?

Thanks

Antony
Tribute to Them

http://tributetothem.com/phpbb3/index.php

Let their memory Live. Forever!
ChaosBringer
Registered User
Posts: 412
Joined: Mon Apr 19, 2004 11:30 pm
Contact:

Re: Creating condition statements

Post by ChaosBringer »

that doesnt go in functions.php it goes in the file you are trying to use it in

example ( in index.php ) etc...because functions.php doesnt have $user set as a global or $template either only inside different functions which give it local scope to that specific function. Where exactly are you trying to add this code to?

01000001 01101100 01101100 00100000 01111001 01101111 01110101 01110010 00100000 01100010 01101001 01101110 01100001 01110010 01111001 00100000 01100001 01110010 01100101 00100000 01100010 01100101 01101100 01101111 01101110 01100111 00100000 01110100 01101111 00100000 01110101 01110011 00100001
User avatar
imkingdavid
Former Team Member
Posts: 2673
Joined: Sun Jul 26, 2009 7:59 pm
Location: EST
Name: David King

Re: Creating condition statements

Post by imkingdavid »

Yeah in my index.php I use:

Code: Select all

if($user->data['user_posts'] < 1)
{
    $template->assign_var('S_NO_POSTS', true);
}
 
And that works fine. Then in the template file (.html) that you want it in, just put

Code: Select all

<!-- IF S_NO_POSTS -->
Code to show 0 posters
<!-- ENDIF -->
Don't forget to smile today. :)
Please do NOT contact for support via PM or email.
tonyjms2005
Registered User
Posts: 184
Joined: Fri Feb 08, 2008 6:52 pm

Re: Creating condition statements

Post by tonyjms2005 »

Hi

Excellent works a treat, thanks :)

Antony
Tribute to Them

http://tributetothem.com/phpbb3/index.php

Let their memory Live. Forever!
Munkeyboi
Registered User
Posts: 28
Joined: Tue Dec 15, 2009 11:08 am
Contact:

Re: Creating condition statements

Post by Munkeyboi »

Hey, i'm very sorry to hijack this thread, but i think i would like something very similar, but am utterly new at all this.


I would like to create conditional statements in memberlist.php and perhaps view topic.

IF a users ID is in a certain table, then return yes, else no.

This is so i can put user status on their profile, ie Is user chatting: Yes/no, are they viewing pictures in the Gallery: Yes/No. Are they playing games in the arcade: Yes/No. etc etc

if you could help me, i'd be very grateful.
Thank you
ChaosBringer
Registered User
Posts: 412
Joined: Mon Apr 19, 2004 11:30 pm
Contact:

Re: Creating condition statements

Post by ChaosBringer »

Munkeyboi wrote:Hey, i'm very sorry to hijack this thread, but i think i would like something very similar, but am utterly new at all this.


I would like to create conditional statements in memberlist.php and perhaps view topic.

IF a users ID is in a certain table, then return yes, else no.

This is so i can put user status on their profile, ie Is user chatting: Yes/no, are they viewing pictures in the Gallery: Yes/No. Are they playing games in the arcade: Yes/No. etc etc

if you could help me, i'd be very grateful.
Thank you
There is a couple of ways you can go about this, but i think the simplest one is creating a function that inputs the info in the database then calling that function in every page kinda like $user->setup( ) does.

first you would add a new field to the users table

like if your in arcade.php you would do
member_currently_in( 'Arcade' )

and the function would be something like

function member_currently_in ( $page = '' )
SQL code to update users table and set current_page to the page value
returns

then in those two pages, you would simple add u.user_page to the rows of user data, and then add the variable..

01000001 01101100 01101100 00100000 01111001 01101111 01110101 01110010 00100000 01100010 01101001 01101110 01100001 01110010 01111001 00100000 01100001 01110010 01100101 00100000 01100010 01100101 01101100 01101111 01101110 01100111 00100000 01110100 01101111 00100000 01110101 01110011 00100001
Locked

Return to “[3.0.x] MOD Writers Discussion”