How do I replace Registration link with a button?
Permalink Browser Info Environment
Hi,
I have managed to get the Login block working as a Trade Only sign in to a website I am creating for a client. The login works and the register link goes to my styled register page to collect the input details to create user.
Last little thing I was to do is change the register link text for a button. I have attached a screen of what currently is there, I want a same styled button underneath Trade Login, simply saying 'Register'.
I feel a button for each option is better.
Here is the code from my view.php
Thanks
Nick
I have managed to get the Login block working as a Trade Only sign in to a website I am creating for a client. The login works and the register link goes to my styled register page to collect the input details to create user.
Last little thing I was to do is change the register link text for a button. I have attached a screen of what currently is there, I want a same styled button underneath Trade Login, simply saying 'Register'.
I feel a button for each option is better.
Here is the code from my view.php
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); $c = Page::getCurrentPage(); $u = new User(); $loginURL= $this->url('/login', 'do_login' ); if ($u->isRegistered() && $hideFormUponLogin) { ?> <?php if (Config::get("ENABLE_USER_PROFILES")) { $userName = '<a href="' . $this->url('/profile') . '">' . $u->getUserName() . '</a>'; } else { $userName = $u->getUserName(); } ?> <span class="sign-in"><?php echo t('Currently logged in as <b>%s</b>.', $userName)?> <a href="<?php echo $this->url('/login', 'logout')?>"><?php echo t('Sign Out')?></a></span> <?php } else { ?> <form class="login_block_form" method="post" action="<?php echo $loginURL?>">
Viewing 15 lines of 40 lines. View entire code block.
Thanks
Nick
Type: | Discussion |
---|---|
Status: | Archived |
Thanks Mike, worked a treat ;o)
Best Regards
Nick
Best Regards
Nick
Good news.
Best Wishes,
Mike
Best Wishes,
Mike
Hi Mike,
Sorry, I spoke too soon. I have the register button sitting below the Trade LogIn button, but where the Trade Log in points to a trade area on successful log in. The Regsiter button also clicks through to the Trade Area, which it should not, it is meant to go to my Register page.
Here is my code.
Previously the text link went to the register page and trade login button when successful details were entered took you to a Trade Area.
Now they both hit the same place?
Any ideas?
Many Thanks
Nick
Sorry, I spoke too soon. I have the register button sitting below the Trade LogIn button, but where the Trade Log in points to a trade area on successful log in. The Regsiter button also clicks through to the Trade Area, which it should not, it is meant to go to my Register page.
Here is my code.
Previously the text link went to the register page and trade login button when successful details were entered took you to a Trade Area.
Now they both hit the same place?
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); $c = Page::getCurrentPage(); $u = new User(); $loginURL= $this->url('/login', 'do_login' ); if ($u->isRegistered() && $hideFormUponLogin) { ?> <?php if (Config::get("ENABLE_USER_PROFILES")) { $userName = '<a href="' . $this->url('/profile') . '">' . $u->getUserName() . '</a>'; } else { $userName = $u->getUserName(); } ?> <span class="sign-in"><?php echo t('Currently logged in as <b>%s</b>.', $userName)?> <a href="<?php echo $this->url('/login', 'logout')?>"><?php echo t('Sign Out')?></a></span> <?php } else { ?> <form class="login_block_form" method="post" action="<?php echo $loginURL?>">
Viewing 15 lines of 39 lines. View entire code block.
Any ideas?
Many Thanks
Nick
Hello,
One this I noticed is that you placed in a way that likely caused a php error. It like should be inside that if statement.
Notice the bracket there at the end? Let's start with that and see where it gets us.
Also, make sure to have "Public Registration" enabled in the dashboard.
Best Wishes,
Mike
One this I noticed is that you placed in a way that likely caused a php error. It like should be inside that if statement.
Notice the bracket there at the end? Let's start with that and see where it gets us.
Also, make sure to have "Public Registration" enabled in the dashboard.
Best Wishes,
Mike
Hi Mike,
Thanks for looking at this, I am not really up to date with PHP ;o(
But I stuck your amended code into the page and I am still not getting that button up.
Here is exactly the code I have in there
Plus, yes I have public registration enabled ;o)
Thanks
Nick
Thanks for looking at this, I am not really up to date with PHP ;o(
But I stuck your amended code into the page and I am still not getting that button up.
Here is exactly the code I have in there
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); $c = Page::getCurrentPage(); $u = new User(); $loginURL= $this->url('/login', 'do_login' ); if ($u->isRegistered() && $hideFormUponLogin) { ?> <?php if (Config::get("ENABLE_USER_PROFILES")) { $userName = '<a href="' . $this->url('/profile') . '">' . $u->getUserName() . '</a>'; } else { $userName = $u->getUserName(); } ?> <span class="sign-in"><?php echo t('Currently logged in as <b>%s</b>.', $userName)?> <a href="<?php echo $this->url('/login', 'logout')?>"><?php echo t('Sign Out')?></a></span> <?php } else { ?>
Viewing 15 lines of 41 lines. View entire code block.
Plus, yes I have public registration enabled ;o)
Thanks
Nick
Hi Mike,
I have been tinkering around with this and your suggestions.
This is the final code I put in that view.php for the login and I get a Registration Button alright.
But the really odd thing is that the Register Button when clicked it takes you to the login page, which I don't want. The link in the php ech View is right, but it seems the view.php code above is creating a duplicate login button in the new Register Button.
Do I need to add some code elsewhere is the block?
Thanks
Nick
I have been tinkering around with this and your suggestions.
This is the final code I put in that view.php for the login and I get a Registration Button alright.
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); $c = Page::getCurrentPage(); $u = new User(); $loginURL= $this->url('/login', 'do_login' ); if ($u->isRegistered() && $hideFormUponLogin) { ?> <?php if (Config::get("ENABLE_USER_PROFILES")) { $userName = '<a href="' . $this->url('/profile') . '">' . $u->getUserName() . '</a>'; } else { $userName = $u->getUserName(); } ?> <span class="sign-in"><?php echo t('Currently logged in as <b>%s</b>.', $userName)?> <a href="<?php echo $this->url('/login', 'logout')?>"><?php echo t('Sign Out')?></a></span> <?php } else { ?> <form class="login_block_form" method="post" action="<?php echo $loginURL?>">
Viewing 15 lines of 40 lines. View entire code block.
But the really odd thing is that the Register Button when clicked it takes you to the login page, which I don't want. The link in the php ech View is right, but it seems the view.php code above is creating a duplicate login button in the new Register Button.
Do I need to add some code elsewhere is the block?
Thanks
Nick
Thanks Mike, that worked perfectly.
Thanks again for all your great input.
Kind Regards
Nick
Thanks again for all your great input.
Kind Regards
Nick
Heh, finally. Glad to hear we got it sorted out. I should have realized that button would submit the form if I didn't explicitly set it to type="button". Lesson learned.
Best Wishes,
Mike
Best Wishes,
Mike
Hi Mike,
I think I broke it!...
The client wanted to have the Register button in red and Log In button in Blue. So I thought it would be easy to call in Bootstrap colours on the above and realised I am not so clever.
Sorry to drag up again, but wonder if you can help me ;o)
To recap the block is the standard Login block used, clicking Login with a valid email and password allows entry to a hidden section on website. Click to Register, takes you to the personalised 'Register' page I have created and held in 'single pages''
Here is the view.php for that block with what I have done.
I also attach a screenshot of how my mess looks, with the description below I hope this helps ;o)
The Blue Log In button for some reason has two buttons over the top of each other, but it correctly allows log in when the right details are entered in fields and clicked.
The Red Register button looks quite right, but when clicked it goes wrongly to the login page and not register.php
Thanks
Nick
I think I broke it!...
The client wanted to have the Register button in red and Log In button in Blue. So I thought it would be easy to call in Bootstrap colours on the above and realised I am not so clever.
Sorry to drag up again, but wonder if you can help me ;o)
To recap the block is the standard Login block used, clicking Login with a valid email and password allows entry to a hidden section on website. Click to Register, takes you to the personalised 'Register' page I have created and held in 'single pages''
Here is the view.php for that block with what I have done.
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); $c = Page::getCurrentPage(); $u = new User(); $loginURL= $this->url('/login', 'do_login' ); if ($u->isRegistered() && $hideFormUponLogin) { ?> <?php if (Config::get("ENABLE_USER_PROFILES")) { $userName = '<a href="' . $this->url('/profile') . '">' . $u->getUserName() . '</a>'; } else { $userName = $u->getUserName(); } ?> <span class="sign-in"><?php echo t('Currently logged in as <b>%s</b>.', $userName)?> <a href="<?php echo $this->url('/login', 'logout')?>"><?php echo t('Sign Out')? ></a></span> <?php } else { ?>
Viewing 15 lines of 42 lines. View entire code block.
I also attach a screenshot of how my mess looks, with the description below I hope this helps ;o)
The Blue Log In button for some reason has two buttons over the top of each other, but it correctly allows log in when the right details are entered in fields and clicked.
The Red Register button looks quite right, but when clicked it goes wrongly to the login page and not register.php
Thanks
Nick
Code <?php defined('C5_EXECUTE') or die(_("Access Denied.")); $c = Page::getCurrentPage(); $u = new User(); $loginURL= $this->url('/login', 'do_login' ); if ($u->isRegistered() && $hideFormUponLogin) { ?> <?php if (Config::get("ENABLE_USER_PROFILES")) { $userName = '<a href="' . $this->url('/profile') . '">' . $u->getUserName() . '</a>'; } else { $userName = $u->getUserName(); } ?> <span class="sign-in"><?php echo t('Currently logged in as <b>%s</b>.', $userName)?> <a href="<?php echo $this->url('/login', 'logout')?>"><?php echo t('Sign Out')? ></a></span>
Viewing 15 lines of 42 lines. View entire code block.
Hello, take a look at the bottom part of this code. Instead of using the form helper $form->submit we're replacing it with a basic input type="submit" and the bottom button for register had bbtn not btn. Hopefully that will give you some insight into the issue.
Best Wishes,
Mike
Hi Mike,
Thanks for the speedy reply.
The bbtn comes from the bootstrap button style name I copied and pasted, they were like that, I took out the extra 'b' and the whole thing did not work at all.
Still really puzzled ;o(
Nick
Thanks for the speedy reply.
The bbtn comes from the bootstrap button style name I copied and pasted, they were like that, I took out the extra 'b' and the whole thing did not work at all.
Still really puzzled ;o(
Nick
Sorry Mike,
Been tinkering with this all day, cannot get it right. Sorry to ask again, but I really have no idea here on what I am to be changing to get this right.
I have now added the styling for those two divs nurseryregbutt and nurserytradebutt, so they are now sitting away from the left.
But that is the best of my limited ability.
Regards
Nick
Been tinkering with this all day, cannot get it right. Sorry to ask again, but I really have no idea here on what I am to be changing to get this right.
I have now added the styling for those two divs nurseryregbutt and nurserytradebutt, so they are now sitting away from the left.
But that is the best of my limited ability.
Regards
Nick
Hello,
You were placing a button around an submit button. You cannot do this in HTML.
You need to change this to simply be an html submit button with not <button> around it. Get rid of the form->sbumit etc and just have this
Hope that makes a bit more sense.
Best Wishes,
Mike
You were placing a button around an submit button. You cannot do this in HTML.
<button> <?php echo $form->submit('some_button', t('Update')) ?> </button>
You need to change this to simply be an html submit button with not <button> around it. Get rid of the form->sbumit etc and just have this
<input class="btn btn-primary" type="submit" />
Hope that makes a bit more sense.
Best Wishes,
Mike
Hi Mike,
Thanks for the reply, sorry for the panicky post. I did a little tinker after some more coffee, right after I posted and came up with this....
Which seemed to work also...
I will also try your suggestion now.
Best Regards
Nick
Thanks for the reply, sorry for the panicky post. I did a little tinker after some more coffee, right after I posted and came up with this....
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); $c = Page::getCurrentPage(); $u = new User(); $loginURL= $this->url('/login', 'do_login' ); if ($u->isRegistered() && $hideFormUponLogin) { ?> <?php if (Config::get("ENABLE_USER_PROFILES")) { $userName = '<a href="' . $this->url('/profile') . '">' . $u->getUserName() . '</a>'; } else { $userName = $u->getUserName(); } ?> <span class="sign-in"><?php echo t('Currently logged in as <b>%s</b>.', $userName)?> <a href="<?php echo $this->url('/login', 'logout')?>"><?php echo t('Sign Out')?></a></span> <?php } else { ?> <form class="login_block_form" method="post" action="<?php echo $loginURL?>">
Viewing 15 lines of 40 lines. View entire code block.
Which seemed to work also...
I will also try your suggestion now.
Best Regards
Nick
Attention: Since there has been no activity on this issue for two weeks, this issue has been automatically archived.
To re-open this issue, reply to this message.
To re-open this issue, reply to this message.
Often people style anchor links("<a href=") with css to make the into buttons. If you prefer not to go down that route you can do this(requires javascript)
Just replace the register link with that and you should now have a button.
Best Wishes,
Mike