1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.1 How pre-check "stay logged in" in logged in template?

Discussion in 'XenForo Questions and Support' started by Marcus, Oct 24, 2011.

  1. Marcus

    Marcus Well-Known Member

    How can I pre-check "stay logged in" in the logged in template? It is the checked="checked" html statement.

    If not done by css, how would you do that with javascript: with jquery once the user clicks on "register or login" is the best guess, agreed?
  2. Fuhrmann

    Fuhrmann Well-Known Member

  3. Marcus

    Marcus Well-Known Member

    Yes this is exactly how I have it now. I want a solution that does not change the template. As there is no template hook I could add a javascript to the bottom of all my pages for not logged in users that activates the checked attribute once a user clicks on the "register or login" link. Or it just adds the checked attribute everytime. I don't know if this can be a performance issue.
  4. Fuhrmann

    Fuhrmann Well-Known Member

    I make it work here, but i dont know, as you said, if this can be a performance issue. But that's it:


    class LoginChecked_Listener
        public static function 
    template_post_render ($templateName, &$content, array &$containerDataXenForo_Template_Abstract $template)
            if (
    $templateName == 'PAGE_CONTAINER')
    $content str_replace('<input type="checkbox" name="remember"''<input type="checkbox" name="remember" checked="checked" '$content);

    Maybe there is another easy way to do it. But works, anyway.
    Digital Doctor likes this.
  5. Marcus

    Marcus Well-Known Member

    I did only see your post now. I have created a javascript that adds the checked attribute to this input field once you click on "register or sign in" in a custom template added after template hook body. All other template hooks in PAGE_CONTAINER are above this field.

    It is interesting to know what is the faster approach.
  6. Fuhrmann

    Fuhrmann Well-Known Member

    That's nice. Would like to know this too.

Share This Page