We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1061
    • 81 Posts
    I'm hiding login form by default and if login has errors I need to show it up to get user understand that he has an error.
    I can't make works a setValue by using a preHooks.


    run
    [[!Login? &tplType=`modChunk` &loginTpl=`PortfolioLoginTpl` &preHooks=`error_login`]]

    tpl
    <div class="collapse" id="login" style="[[+show]]">
            <div class="loginForm">
                <div class="loginMessage">[[+errors]]</div>
                <div class="loginLogin">
                    <form class="loginLoginForm  form-inline" action="[[~[[*id]]]]" method="post">
                    ...
    

    error_login
    <?php
    if ($modx->user->isAuthenticated('web') == false)
        $show = 'display: block';
    else $show = 'display: none';
    
    $hook->setValue('show',$show); // placeholder doesn't get any value in tpl
    $hook->setValues(array('show' => $show)); // tried with array
    
    return true;


    I'm tried to playing with prefix login, doesn't help.

    ---
    MODX 2.3.3
    Login 1.9.0
    PHP 5.4.39 [ed. note: alex_dutch last edited this post 8 years, 10 months ago.]
      • 42562
      • 1,145 Posts
      Same here!
        TinymceWrapper: Complete back/frontend content solution.
        Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
        5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
        • 17301
        • 932 Posts
        Try this

        if ($modx->user->isAuthenticated('web') === false) {
        	$modx->setPlaceholder('show','display: block');
        } else {
        	$modx->setPlaceholder('show','display: none');
        }
        
        return true;
          ■ email: [email protected] | ■ website: https://alienbuild.uk

          The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
          • 42562
          • 1,145 Posts
          $modx->setPlaceholder just does not do anything sad

          Can someone test this?
            TinymceWrapper: Complete back/frontend content solution.
            Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
            5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
            • 42562
            • 1,145 Posts
            I managed to use an external snippet to set the placeholders, and then let my Login.Register preHook handle the values via getValue
              TinymceWrapper: Complete back/frontend content solution.
              Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
              5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
              • 42562
              • 1,145 Posts
              After trying all kinds of variation to setValue/setPlaceholder with a hook, no dice!
              Finally fixed my issue by another way

              [[!spamChecker? &snippetSource=`Register`]]
              <div>
              [[!Register? &submitVar=`registerbtn` &activationResourceId=`198` &placeholderPrefix=`reg.` &preHooks=`spamCheckerHook` &postHooks=`notifyAdmin` ]]
              </div>


              If someone could test filling up a random placeholder with a prehook, I'd like to report that this stuff don't work by default for Login.Register
                TinymceWrapper: Complete back/frontend content solution.
                Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
                5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.