Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: Yes-U-Can - heinäkuu 26, 2014, 10:36:42 IP

Otsikko: Help find this link in file
Kirjoitti: Yes-U-Can - heinäkuu 26, 2014, 10:36:42 IP
Can someone help me and tell me on which file i can find the "register an account" link in the shot,, want to route it different but i am new to smf and i just can't locate it..Thank you in advance
Otsikko: Re: Help find this link in file
Kirjoitti: Sir Osis of Liver - heinäkuu 27, 2014, 12:52:18 AP
It's in the kick_guest template in Login.template.php -



// Show the message or default message.
echo '
<p class="information centertext">
', empty($context['kick_message']) ? $txt['only_members_can_access'] : $context['kick_message'], '<br />
', $txt['login_below'], ' <a href="', $scripturl, '?action=register">', $txt['register_an_account'], '</a> ', sprintf($txt['login_with_forum'], $context['forum_name_html_safe']), '
</p>';



Bear in mind there are other register links elsewhere that do the same thing.
Otsikko: Re: Help find this link in file
Kirjoitti: Yes-U-Can - heinäkuu 27, 2014, 01:37:05 IP
Lainaus käyttäjältä: Krash - heinäkuu 27, 2014, 12:52:18 AP
It's in the kick_guest template in Login.template.php -



   // Show the message or default message.
   echo '
         <p class="information centertext">
            ', empty($context['kick_message']) ? $txt['only_members_can_access'] : $context['kick_message'], '<br />
            ', $txt['login_below'], ' <a href="', $scripturl, '?action=register">', $txt['register_an_account'], '</a> ', sprintf($txt['login_with_forum'], $context['forum_name_html_safe']), '
         </p>';



Bear in mind there are other register links elsewhere that do the same thing.




Thank you , Thank you  Krash..
Yes,  i am aware of the others.  but i am still learning the coding from smf :)  ex: action=register
Thanks again for that.
Otsikko: Re: Help find this link in file
Kirjoitti: Sir Osis of Liver - heinäkuu 27, 2014, 03:57:50 IP
Don't know exactly what you're trying to do, but there's a simple way to redirect all register links without having to find/edit each one.
Otsikko: Re: Help find this link in file
Kirjoitti: Yes-U-Can - heinäkuu 27, 2014, 10:05:05 IP
Hello Krash, i wanted to redirect that link and the others i did find to my register.php page from our site, as that is what i prefer as  site requires more input information when registering..Not long ago we added SMF to register in site with same password , same username etc etc with main site..I'm still working on it, have a bits more work to do..If you like to help me ,


Can you post it up how you say it's alot easier to do it with them links..Thank i really do appreciate anyone that helps me out.
Thanks again
Otsikko: Re: Help find this link in file
Kirjoitti: Mstcool - heinäkuu 28, 2014, 02:40:11 AP
You can download a menu mod and add ur new register button and remove the default one. :P
Otsikko: Re: Help find this link in file
Kirjoitti: Illori - heinäkuu 28, 2014, 05:28:24 AP
Lainaus käyttäjältä: Mstcool - heinäkuu 28, 2014, 02:40:11 AP
You can download a menu mod and add ur new register button and remove the default one. :P

that does not fix all the links in various other places.
Otsikko: Re: Help find this link in file
Kirjoitti: Mstcool - heinäkuu 28, 2014, 08:54:03 AP
Thats true but I was just talking about changing the menu link. :p
Otsikko: Re: Help find this link in file
Kirjoitti: Arantor - heinäkuu 28, 2014, 08:56:25 AP
Eh, you'd hijack action=register to point to the other place if you were going down that route, minor tweak to index.php.
Otsikko: Re: Help find this link in file
Kirjoitti: Sir Osis of Liver - heinäkuu 28, 2014, 02:10:01 IP
Lainaus käyttäjältä: ‽ - heinäkuu 28, 2014, 08:56:25 AP
Eh, you'd hijack action=register to point to the other place if you were going down that route, minor tweak to index.php.

Couldn't get that to work. >:(

You can also create a new function in Register.php that's just a redirect, like this:



/// Register redirect
function RegisterRedirect()
{
header( 'Location: http://www.simplemachines.org' ) ;
}



... then change the action in index.php to this:



'register' => array('Register.php', 'RegisterRedirect'),


Otsikko: Re: Help find this link in file
Kirjoitti: Arantor - heinäkuu 28, 2014, 02:14:20 IP
Cannot recommend that.

Either use redirectexit('http://site.com'); or use the header with an exit statement to prevent further execution since browsers can choose to ignore Location headers.
Otsikko: Re: Help find this link in file
Kirjoitti: Sir Osis of Liver - heinäkuu 28, 2014, 02:17:09 IP
Will play with that tonight.  What's the syntax to just redirect the action in index.php?
Otsikko: Re: Help find this link in file
Kirjoitti: Arantor - heinäkuu 28, 2014, 02:18:20 IP
You just do an intercept on $_GET['action'] before the main checking goes and use redirectexit like I just said.
Otsikko: Re: Help find this link in file
Kirjoitti: Sir Osis of Liver - heinäkuu 28, 2014, 11:15:08 IP
Ok, you mean like this -

index.php



// The main controlling function.
function smf_main()
{
global $modSettings, $settings, $user_info, $board, $topic, $board_info, $maintenance, $sourcedir;

/// Register redirect
if (isset($_GET['action']) && $_GET['action'] == 'register')
{
redirectexit('http://www.simplemachines.org');
}



Then using new function would be like this -

index.php



'register' => array('Register.php', 'RegisterRedirect'),



... and Register.php




/// Register redirect
function RegisterRedirect()
{
redirectexit('http://www.simplemachines.org');
}



Both werk gud!

Thx.
Otsikko: Re: Help find this link in file
Kirjoitti: Arantor - heinäkuu 29, 2014, 04:49:25 AP
Yup, both ways work, and sometimes one will be better than the other.