Hi friends,
I have just started to work on MODx and i am trying to create login form and stuck, need answers to few of my questions
1) I have create design in chunk
2) i want to know how do i link this chunk to snippet, i mean when user click on "Login" button i should get the details in "$_POST" in "process_login" (something like this) snippet.
using [[~[[*id]]]] submits the page to same page i am not getting how to process the input
3) i tried googleing "modx form processing" but what all i get is modx plugins for form processing, but i want to learn myself and then using plugins
Any help would be appreciated.
Thanks
Amit
-
☆ A M B ☆
- 24,524 Posts
If you’re posting the form to the same page then a snippet (uncached!) will have access to the $_POST array. The snippet must be uncached or it won’t be processed on the second (form posting) request as it will have been cached when the form was displayed on the first request.
-
☆ A M B ☆
- 24,524 Posts
No. If the form appears on the page, whether from a chunk or directly in the HTML of the template or resource, when it is posted the snippet will independently be able to access the POST.
Which version of MODx are you using? The snippet must be uncached, in Evo that’s [!Snippet-Name!] and in Revo it’s [[!Snippet-Name]].
There’s no need for the names to match, but you need to set placeholders and use the chunk name in the snippet. You also need placeholder tags in the chunk.
Is there some reason you’re not using the Login package available in Package Management?
-
☆ A M B ☆
- 24,524 Posts
BobRay, if he’s just using his own form/snippet combination, then there’s no placeholders involved. Although I also would think it better to use the Login package, since that’s definitely going to work.
-
☆ A M B ☆
- 24,524 Posts
You mean to actually have the user logged in properly? I don’t use Revo, but what I would recommend that you do is download the Login package and see how it’s done.
As far as generic form handling goes, there shouldn’t be a problem accessing the $_POST array when the form is posted. The only reason I can think of is if the snippet is called cached, in which case the page will be taken from cache and the snippet won’t even exist in the cached page, so there’s nothing to deal with the $_POST values.
Quote from: www.amitpatil.me at May 09, 2011, 02:04 PM
@bobray : Making a login page is not my motto....i just want to learn the flow and want to understand how to process the inputs, linking snippets and chunks etc
Logins are a particular case and not the best example of how snippets and chunks are used. I’d strongly recommend reading the stuff here:
http://rtfm.modx.com/display/ADDON/Login.Login
and here:
http://rtfm.modx.com/display/ADDON/Login.Tutorials
To learn how to use chunks and snippets with forms, the FormIt package is probably the best option:
http://rtfm.modx.com/display/ADDON/FormIt.
If you get both of those working, you’ll know a lot more about how to do things the MODX way than you’d learn trying to roll your own, IMO.
I think that would teach you more than doing your own from scratch.
@Bob : I am also feeling like i need to read more...before starting i have read documentation...but now i think that some concepts are not clear to me...I will definitely go through the links u provided.
many thanks Bob