Custom register page with single pages

Permalink 1 user found helpful
I have modified the config/site_theme_paths.php to pull my custom page from /single_pages. Styling is good but the form doesn't work. There are no errors generated and displayed and if the form is filled out correctly it just redisplays the page.

I am assuming that the core location is somehow pulling some vital code into the page.

tallacman
View Replies: View Best Answer
Mnkras replied on at Permalink Reply
Mnkras
can you explain a little more what you did? did you just copy /concrete/single_pages/register.php to /single_pages/register.php and make some changes?
tallacman replied on at Permalink Reply
tallacman
Yes. Just a straight duplication of the core file with a div added for styling. This is the first three lines
[code]
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); ?>
<h2 class="dot-underline italic-head"><?php echo t('Site Registration')?></h2>
<div class="ccm-form wedding-library">
[code]
tallacman replied on at Permalink Reply
tallacman
It is a 5.4.x install upgraded to 5.4.0.5. I was wondering if the upgrade folder was giving me problems, somehow.
kirkroberts replied on at Permalink Reply
kirkroberts
Same problem as the original poster.

I copied /concrete/single_pages/register.php to /single_pages/register.php so I could customize the form. When attempting to use the page the page simply reloads (with /register/do_register in the address bar) and nothing happens. No errors. Nothing (that I can see).

Seems that the issue is tied to using a custom theme for the register page (in config/site_theme_paths.php).

Does anyone know the answer to this? I'm going to keep looking.
Proteus replied on at Permalink Reply
Proteus
Is the problem that a user doesn't actually get registered when the form is submitted?

I find that custom single pages, even with completely copy-paste code, can behave differently than the default ones (for instance, if you log in with the wrong password, the site does not say "Wrong Password", as in the default login page—the custom login page is just refreshed).

This kind of behavior can be deceptive.
kirkroberts replied on at Permalink Reply
kirkroberts
Got it!
In c5's core theme the view.php file includes this code:
<?php  if (isset($error) && $error != '') { ?>
   <?php  
   if ($error instanceof Exception) {
      $_error[] = $error->getMessage();
   } else if ($error instanceof ValidationErrorHelper) { 
      $_error = $error->getList();
   } else if (is_array($error)) {
      $_error = $error;
   } else if (is_string($error)) {
      $_error[] = $error;
   }
      ?>
      <ul class="ccm-error">
      <?php  foreach($_error as $e) { ?><li><?php echo $e?></li><?php  } ?>
      </ul>

If you include that in your own theme's view.php before
print $innerContent

then you'll get error reporting on your register page and others that use view.php.
Proteus replied on at Permalink Reply
Proteus
Thanks! Will definitely have to try that.
kirkroberts replied on at Permalink Best Answer Reply
kirkroberts
Update!

The code can be a lot simpler, and also should be in a different place.

Here's the code:
if (isset($error) && $error->has()) {
    $error->output();
}


Put it on your register.php page NOT your theme's view.php file. Turns out that other single pages (for instance, in the profile pages) include this code.

Let's see if I encounter some other issue with this now...
hursey013 replied on at Permalink Reply
hursey013
I'm trying to figure this out. The code you pasted, which goes in register.php - does that need to go in the core or do I make a new register.php in /single_pages/ and also does it matter where within register.php the code goes?
kirkroberts replied on at Permalink Reply
kirkroberts
Sorry for the late reply.
You should copy /concrete/single_pages/register.php to /single_pages/register.php.
The code can go anywhere, but it makes the most sense to have it near the top of the page near the form.
hursey013 replied on at Permalink Reply
hursey013
Hey Kirk - I placed the code:
if (isset($error) && $error->has()) {
    $error->output();
}
within my /single_pages/register.php and I'm still not seeing any error messages - did I miss a step somewhere? Thanks for your help - not having feedback when people login in with the wrong password and stuff has been a big annoyance - would love to get it resolved.
kirkroberts replied on at Permalink Reply
kirkroberts
The top of one of my register pages looks like this:
<?php  defined('C5_EXECUTE') or die("Access Denied."); ?>
<h1><?php echo t('Forum registration')?></h1>
<div class="ccm-form">
   <?php  if (isset($error) && $error->has()) {
        $error->output();
    } else if (isset($message)) { ?>
        <div class="message"><?php echo $message?></div>
        <script type="text/javascript">
        $(function() {
            $("div.message").show('highlight', {}, 500);
        });
        </script>
    <?php  } ?>
<?php  
if($success) { // more code...

It shows error messages.

You say "when people login"... that would be on login.php, not register.php. Make sure the same code is at the top of login.php. Of course, you should copy login.php to /single_pages, *not* update the core.

The core should have this built-in, shouldn't it? Perhaps core themes have this in the view.php file? Doesn't seem consistent, so you might get two duplicate error messages if you just put it in your view.php.
hursey013 replied on at Permalink Reply
hursey013
Wow, I'm an idiot - all this time and I was putting the code in the wrong page... I pasted you snippet into the login.php and it worked perfectly - thank you.
kirkroberts replied on at Permalink Reply
kirkroberts
No worries... I've done the same sort of thing too many times to mention. Glad you got it working!
AngusHume replied on at Permalink Reply
AngusHume
I tried all the samples here and could not get it to work unfortunately. Still no validation. Then I found another post which seems to work. Yay.

http://www.concrete5.org/community/forums/usage/theme-for-registrat...