Jump to content

landitus

Members
  • Posts

    181
  • Joined

  • Last visited

Posts posted by landitus

  1. I'm doing a custom login/register in the front end, and flash messages are really useful to inform the user about the process of user registration. I was used to using Codeigniter with their flash message system. I've seen very few messages in the forum where $session->message is used but I haven't seen a full implementation. I've tried my own with some degree of success, but the flash messages persist in a different way that I've expected. It's like there is a "delay". Maybe I'm doing something wrong.

    The header.inc has a standard notices loop:

    <?php if($notices) :?>
         <?php foreach($notices as $notice) :?>
                <?php $class = $notice->className(); ?>
                <div class="notification <?= $class; ?>">
                    <p><?= $notice->text ;?></p>
                </div>
         <?php endforeach ;?>
    <?php endif ;?>
    

    This is my register.php:

    When submitting the form with errors, the first time no error message are displayed. The second time I submit it with errors, then the error message appears. This is what I describe as the "delay".

    <?php
    
    include("./helpers/form_helpers.php");
    
    /**
     * Register template
     *
     */
    
    $out = "";
    $errors = "";
    
    // create a new form field (also field wrapper)
    $form = $modules->get("InputfieldForm");
    $form->action = "./";
    $form->method = "post";
    $form->attr("id+name",'register-form');
    
    // Name
    // $field = $modules->get("InputfieldText");
    // $field->label = "Name";
    // $field->attr('id+name','name');
    // $field->required = 1;
    // $form->append($field); // append the field to the form
    
    // Email
    $field = $modules->get("InputfieldEmail");
    $field->label = "E-Mail";
    $field->attr('id+name','email');
    $field->required = 1;
    $form->append($field); // append the field
    
    // Password
    $field = $modules->get("InputfieldPassword");
    $field->label = __("Contraseña");
    $field->attr("id+name","password");
    $field->required = 1;
    $form->append($field);
    
    // Submit
    $submit = $modules->get("InputfieldSubmit");
    $submit->attr("value",__('Crear cuenta'));
    $submit->attr("id+name","submit");
    $submit->attr("class","btn btn--primary");
    $form->append($submit);
    
    // Form submitted: process form
    if($input->post->submit) {
    
        // user submitted the form, process it and check for errors
        $form->processInput($input->post);
    
        // here is a good point for extra/custom validation and manipulate fields
        if($sanitizer->email($form->get("email")->value) != '') {
    
            // Email should be unique
            if(!isUniqueUserEmail($form->get("email")->value)){
                $form->email->error(__("El e-mail ingresado ya se encuentra registrado"));
            }
        }
    
        if($form->getErrors()) {
           // the form is processed and populated but contains errors
    
           // Render Form
           $session->error(__('There are errors in the form'));
           $out .= $form->render();
    
        } else {
    
            // Sanitize inputs
            //$full_name = $sanitizer->text($input->post->name);
            $email = $sanitizer->email($input->post->email);
            $password = $input->post->password;
    
            // Generate username from email
            $username = $sanitizer->email($input->post->email);
    
            // Create New User
            $u = new User();
            $u->of(false);
            $u->name = $username;
            $u->pass = $password;
            $u->email = $email;
            $u->addRole("guest");
            $u->addRole("member");
            $u->save();
            $u->of(true);
    
            // Create hash
    
            // Email the user with confirmation e-mail
    
            // Redirect to login page and display success Message
            $session->message(__('User registration sucessfull'));
            $session->redirect('/login');
    
        }
    
    
    } else {
        // Form not submitted: render out form without processing
        $out .= $form->render();
    }
    
    include("./partials/header.inc"); ?>
    
    <div class="container container--narrow">
        <div class="page">
            <h1>Nuevo usuario</h1>
            <?= $out ;?>
        </div><!-- .page -->
    </div><!-- .container -->
    
    
    <?php include("./partials/footer.inc"); ?>
    
    

    On a successful submission, the next page displays the correct message, but also the error message "There are errors in the form". It's like the error message get's carried over.

    I appreciate any help to sort this out.

  2. I think this could be a bug. I'm using an Options field to create an array of radio fields. This field is required. Each option activates a conditional field and this works perfectly. I added a required if condition to this conditional fields, on a template level, and this is displayed correctly with the red *. But the fields are not validated and the page saves nonetheless. I figured since the red asterisk is on, I've configured the fields conditions correctly, right?

    post-72-0-84753700-1442004248_thumb.png

    post-72-0-57940800-1442004259_thumb.png

    post-72-0-14112700-1442004306_thumb.png

  3. I've been experiencing some weird issues with PW on my local machine (using MAMP). Since upgrading to version 5.2.3, I get logged out of the admin or on the front end unexpectedly and randomly. It happens while editing pages and when visiting password protected areas. I would like to provide more information if it helps to figure this out. Seems pretty broad and can't figure out what to do. It's pretty annoying since it happens pretty often.

  4. The Pro fields are looking great! Thanks Ryan.

    I was wondering what would be the best way to store a running event scorecard. This is a table with 2000+ rows and 15 columns of data, where each runner has its race time and more. This data would then be displayed in an html or a js enhanced data table. The site is a running magazine and there will be a lot of score tables.

    I guess I would just store and xls or json file in PW and then get into the datatables plugin. But maybe there's a more efficient way with the Pro fields?

  5. I'm having (for the first time) a similar problem. The thing is I have 2 Page fields in one template which no matter what I select, their values won't get saved. The page is saved and there's a notification, but nothing is saved on those 2 fields. The rest of the page (text fields) are working ok. The crazy thing is that those same 2 fields are present on another template and they work fine!  This ocurrs only on the production website. Everything works ok locally. I'm using PW 2.3.1

    What could this be? I'm using the Date Archiver module, but both templates use it! I'm lost!!

  6. If you don't need the page to be saved when the button is clicked, then I think the route you are taking is fine. If you did need the page to be saved, then you'd want your button to be a submit button, and a second (save) hook to be called after the ProcessPageEdit::processInput and to silently do its thing (no redirect). Another route you could take is to setup a separate page with a template that does what you want, and then have your button link to that instead. But the way you've done it is already more compartmentalized (less parts to consider) so I wouldn't change it unless it creates issues with other modules hooking into ProcessPageEdit at some point down the road (which is possible). 

    I'm am trying to accomplish a Save and notify button which Ryan's mention that has to have a second save hook. I'm starting with the code for the button (the same Mackski) but I have no idea how to attach this button to save action. How would you implement such hook? 

  7. Is it possible to add pagination limit after merging to PageArrays? I'm querying pages for an event calendar where there are two conditions:

    • Events that are starting in the future
    • Events that started in the past but are ending in the future (aka are current)

    I've coded the following but I want to limit the results to trigger the pagination, but my code is not working.

    What can I do?

    $events = $pages->find("template=event, date>=today, sort=date");
    $events = $events->append($pages->find("template=event, date<=today, date_end>=today,sort=date"));
    $events = $events->find("limit=15");
    
  8. Thanks statestreet! Actually, what I'm looking for is to avoid adding another select, because I want to avoid confusions with the users. It looks from the example taken from TinyMCE that new "style formats" can be added to the Format's select. Take a look at the screenshot attached.

    It would be better to just have one select for styling, in my case. Let me know if you can accomplish this! 

    post-72-0-54207900-1391731536_thumb.png

  9. This is just what I was looking for! But, is it possible to have one the pages under the protected section be available for guests view/access? 

    Parent [template=parent] > No guest access [lock icon]

    --- Child 1 [template=child] > No guest access

    --- Child 2 [template=child] > Guest access [unlock icon] 

    --- Child 3 [template=child] > No guest access

    I see this is not a common behaviour to replicate in the admin, and may need some template coding instead. My first idea was to give the child template no restrictions, and then in the child.php template, do some access checking. This way the parent is protected, but each children can be set to public via a checkbox in the page edit screen. This could work, right?

    The only caveat is that I would like to keep the lock icon coding after the page name in the tree. This is, I would like to keep the unlock icon next to the pages with guest access. Maybe there's a hook available for this in the admin?

    Any help will be appreciated!!!

  10. dear land ,,

    and u.needs to turner off debug modee

    WillyC,  that's great!!!!! I didn't realize that cause I'm in the DEV environment all the time. Perfect! At least for the client it won't be a problem as it's on the server with debug off. This is a relief. 

    Notifications still annoys me while developing. The new debug tools ui is such a good example I'm keen on replicating the collapsible UI this for notifications. But guess is not such a priority as the client won't be flooded with messages. Either way, I stand by the notion the notifications UI is better as one line of text as it pushes the page down. It would a better UI IMHO :) 

    • Like 1
  11. I've just upgraded a new site I'm building and I'm pleased to say it all went smoothly. All modules worked perfectly and I'm still testing it with joy! :)

    I'm loving the improvements on the new default Theme. I'm a designer myself so I'm hard to please. I haven't been following the new theme discussion lately but I wish to point out some things I came across.

    Notifications

    I found the notices/notifications very annoying as they push the page down depending on the quantity of such notifications. ProcessWire is quite verbose and the new design reminded me more of it. Kind of made it a little bit more annoying as well. Even more with intensive editing/usage.

    I wonder if it could be a way to have like 2 levels of "verbosity": one more suitable for an editor and one for and admin. Maybe the editor just wants to see 1 notification for "page saved" or one with the errors in case they are any. The admin would see "field x saved, field x saved..." just like it today. I can see this setting an improvement to the UI and to the UX of content editors as wells. Also, the phrasing could be more user-friendly to editors/not techie people, just by removing the word "Session:" or using the fields titles instead of the names. Maybe it can be configured and haven't noticed it.  

    Edited:

    As WillyC pointed out, this only happens with debug mode on so it's not a problem for the client. My critique should focus on the UI pattern and not the notification system, then.  :)

    Also, it could be possible to condense all notifications in one phrase and make it collapsible (like the Debug mode tools) with an arrow or gears icon that let's admins/anyone see all the notifications (fields saved, etc) related to the event (either saved-green/error-red). This would solve the annoying push down of the page when saving 10 images for example (this is a worst case scenario which I can see has been addressed already). But modifying 10 field gives you 10/11 green bands which is the same effect. Other solutions might be to place notifications where they were.

    I guess there is a reason for this new change, but wanted to simply express my opinion on it. I found a client of mine panicking when seeing 10 green notifications over the screen. It almost seemed like an error, even though they were all successful notifications. I guess that the top notification/pushing down the page pattern is better suited for just for one line of text. Having a collapsible icon seems like a good solution to accommodate and further extend this UI pattern.

    Let me know what you guys think!

    Otherwise, everything looks sharp, fresher and more user-friendly so I'm very happy about it!! Congrats to everyone involved!

    Edited

    I made some quick concepts to see what it would look like. Certainly this is easier said than done (what isn't?). It looks simple but I maybe there are some situations/notifications I'm not considering. The idea, in fact is to simplify it to two possible messages (Success/Error) and make less intrusive. Each message can be expanded to see what has changed or which fields have errors. When having an error notification, one can simply scroll/scan the form to see which fields have errors anyway, so it's not necessary to expand the notification banner. 

    This is just an idea and maybe it can be built upon it.

    post-72-0-82819900-1391234106_thumb.png

    post-72-0-36059300-1391237549_thumb.png

    • Like 8
  12. Thanks kongondo!! This module is just what I needed. I will check it out! I've been working on my own version of an admin table, so this is a lifesaver

    I definitely think that PW should have these tables by default with search and filtering. It would be cool to have them generated via the admin ui, with options as which templates to list or from which parent or a custom search (just like the Page field options). It would complement the site tree in a nice way. Blogs and other kinds of data are better displayed as a table. This module looks neat!

    • Like 1
  13. It is working fine for me on stable and dev versions of PW. That description field is stored directly in the alt field in the RTE. Do you have any unusual TinyMCE settings that could be causing it?

    Nope, just a content_css stylesheet.

    Same for links that have a class added and if reopened in link modal and changed the link lost the class added before. This is ever since. And with image too. Think there was some thread about it.

    Oh! I'm sad to hear that  :( . Is this difficult to fix? I tried to look in the forums and haven't found the same issue. 

    I'm confused, @adrian, do you mean PW v2.3.1? Or a different stable version?

  14. I'm having a weird issue with images in TinyMCE.

    1. When adding images to the images field (the default one), I add a description.
    2. Then I add the image to the body field via TinyMCE.
    3. Then save and the image has the correct alt text. So far so good...
    4. But, if I reopen the same image with the image button, the description is gone from the modal window. If I re-save, the image is displayed without the description.

    Looks like the image it's not retaining the original description value when editing. Is this a bug?

    • Like 1
×
×
  • Create New...