Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: AlaaJ - kesäkuu 05, 2014, 08:38:14 IP

Otsikko: Create a new .php file .
Kirjoitti: AlaaJ - kesäkuu 05, 2014, 08:38:14 IP
Hey , guys I am trying to create another registration page .
I've created it and added it to the monstrous $_REQUEST['action'] array - $_REQUEST['action'] => array($file, $function).

But when I try to access it through this url www.mysite.com/index.php?action=registerdonator

I get this error " Unable to load the 'main' template. "

Any Ideas ?
Otsikko: Re: Create a new .php file .
Kirjoitti: Arantor - kesäkuu 05, 2014, 08:45:45 IP
Well, it's expecting to have a template to display on said page. By default $context['sub_template'] contains 'main' which means it will try to run a template function called template_main() which must have already been loaded by a loadTemplate() call during your action.

Hard to tell you any more without more information.
Otsikko: Re: Create a new .php file .
Kirjoitti: mashby - kesäkuu 05, 2014, 08:47:02 IP
Moved this...Arantor answered better than what I was going to ask. But I'll have a go anyway. How exactly are you coding this?
Otsikko: Re: Create a new .php file .
Kirjoitti: AlaaJ - kesäkuu 05, 2014, 08:50:13 IP
Thank you .
Here is what i did :
I have duplicated the register.php file and created and named the other file register_donator.php which means that they both are the same , but when I try to access the register_donator.php file using index.php?action=registerdonator I get the error .

Please tell me if you need more information .
Otsikko: Re: Create a new .php file .
Kirjoitti: Arantor - kesäkuu 05, 2014, 08:53:01 IP
How you added it to the action array would be useful. Not that it would work properly anyway if you tried to do that, for at least half a dozen other reasons.

Why a separate registration file anyway? So people can donate as soon as they register? People do not generally do that.
Otsikko: Re: Create a new .php file .
Kirjoitti: AlaaJ - kesäkuu 05, 2014, 09:00:30 IP
This is how i added it to the action array :
'activate' => array('register_donator.php', 'Activate'),
'coppa' => array('register_donator.php', 'CoppaForm'),
'registerdonator' => array('register_donator.php', 'registerdonator'),

I also added it here :

elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'registerdonator', 'register', 'register2', 'reminder', 'activate', 'help', 'smstats', 'mailq', 'verificationcode', 'openidreturn'))))



Actually , People have already donated and the donations are off .
This file link will be sent to donators to make them join the donators group without asking for a request .
I have added a code that will add them to a requestable group without the admin approval .
Otsikko: Re: Create a new .php file .
Kirjoitti: Arantor - kesäkuu 05, 2014, 09:40:51 IP
I would explain but I get the distinct feeling you won't listen and will try and bodge it together your own way... there's no possible way that will work currently.

I'm not disputing that you'll get donations. I'm disputing the nature of donate-at-registration, never seen it pulled off successfully before.
Otsikko: Re: Create a new .php file .
Kirjoitti: AlaaJ - kesäkuu 05, 2014, 09:43:23 IP
Can you please explain how to make the other php file work ?
Otsikko: Re: Create a new .php file .
Kirjoitti: AlaaJ - kesäkuu 05, 2014, 10:57:59 IP
I will listen to you , please tell me how to do it .  :(
Otsikko: Re: Create a new .php file .
Kirjoitti: mashby - kesäkuu 05, 2014, 11:04:09 IP
Without providing code bits and file names, can you describe what you are trying to achieve?