We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49499
    • 48 Posts
    I am using the Login extra by Shaun McCormick for our users. On many pages we have multiple login forms—one of them is in a reveal modal and the other is in the website header. Currently, when there is an issue with login information, the output is sent to both [[+error]] placeholders for both forms.

    Is there a way to specify a unique [[+error]] placeholder? Or is there perhaps another way to determine which form was submitted? This would be most helpful, as I would like to put in a condition to have the reveal modal window to remain open if an error message exists for that form. However, the conditional logic is now currently being called any time a form is submitted unsuccessfully anywhere.

    Any suggestions?

    • MODX Version: MODX Revolution 2.3.5-pl (traditional)
    • PHP Version: 5.6.10
    • Database (MySQL, SQL Server, etc) Version: MySQL 5.6.22-log
    • Installed MODX Add-ons: Login

    This question has been answered by patrickappelman. See the first response.

      • 42562
      • 1,145 Posts
        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.
      • discuss.answer
        • 49499
        • 48 Posts
        Thank you, donshakespeare! That got me thinking in the right direction. I actually accomplished this through setting URL parameters in the "action" attribute of the form element.

        <form action="[[~[[*id]]]]?login_source=login_modal" method="post">
        


        I have a function that grabs URL parameters by name:

        <script>
        	function getParameterByName(name) {
        		name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
        		var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        			results = regex.exec(location.search);
        		return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
        	}
        </script>
        


        Then I have the error template include this:

        [[+msg]]
        [[!$login_modal_error:jsToBottom]]
        


        $login_modal_error has the following:

        <script>
        	$(document).ready(function(){
        		var login_source = getParameterByName('login_source');
        		if ( login_source == 'login_modal') {
        			$('#login-modal').foundation('reveal','open');
        		}
        	});
        </script>
        


        There might be a better way to accomplish this, but this works great for me.
          • 42562
          • 1,145 Posts
          Sweet!
            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.