Welcome, Guest
Username: Password: Remember me

TOPIC: How to capture/use input that isn't saved in db?

How to capture/use input that isn't saved in db? 13 Dec 2012 23:52 #6075

  • gdpodesta
  • gdpodesta's Avatar
  • Offline
  • Senior Member
  • Posts: 75
  • Thank you received: 8
  • Karma: -42
In my component, I'm have a table for "Professors". The table stores all sorts of information about the professor, and in the case of a new record, creates a new Joomla user account. I have this all working just fine in the postSaveHook function with the fields generated from the XML.

To finished, I have to obtain the password for the Joomla user account, so I need an input field for the user to provide it, but the password is not to be stored in the table with the other Professor info, only used in the CreateUser function. The postSaveHook function only provides the data that was saved (and described in the related XML), so if I put such an input on the page, where is it available "in the flow of things" so that I can create the user account with the password that the user provided with the input field, but not have to save in in my table?
The administrator has disabled public write access.

Re: How to capture/use input that isn't saved in db? 14 Dec 2012 07:29 #6076

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Somebody else asked a related question - not quite the same but nevertheless, I think the best solution would be to create a user/profile plugin.

Of course this would be outside of cook however, it could easily be added to your manifest and installed in one go.

The advantage of this approach is that you could create an independant profile and data set for each type of user + you can hook in to login/logout, registrations and all that good stuff.

Search the forum for 'profile plugin'. I have linked to a few relevant posts quite recently as well as the joomla docs for it.

Hope it helps,

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
Last Edit: 14 Dec 2012 08:32 by JoomGuy.
The administrator has disabled public write access.

Re: How to capture/use input that isn't saved in db? 14 Dec 2012 07:37 #6077

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: How to capture/use input that isn't saved in db? 14 Dec 2012 11:08 #6079

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Actually, another way (following your exact route) may be to add the password field to your XML. You don't have to store it in your table but, you can obviously then retrieve it from $data in your model, right?

Never tried this but I can't see a reason why it wouldn't work.

Is the purpose of putting the password field in your form like a 'confirm' password for them to be able to submit your form? I mean, are they already signed in at this point and you just want to check again?

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: How to capture/use input that isn't saved in db? 14 Dec 2012 12:41 #6080

  • gdpodesta
  • gdpodesta's Avatar
  • Offline
  • Senior Member
  • Posts: 75
  • Thank you received: 8
  • Karma: -42
In fairness, that would work for the example I gave, but there are a number of other pages with varying information that is retrieved from API calls and is used on the pages that my component has, but updates a number of other databases in other systems, not the table for my component.

I'm sure I'll figure something out, I just hoped there was a sweet spot where everything on the page is available. My "prime directive" is to do everything the right way for Joomla, MVC, and Cook.
The administrator has disabled public write access.

Re: How to capture/use input that isn't saved in db? 14 Dec 2012 13:10 #6081

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
If the 'extra' data that you want is largely going to be user data (like password that you gave in the example) then I think that the user plugin (login and/or profile) will really be the best way.

If it is not limited to user data then, a series of plugins for other (and your own) component(s) would be the way to go... That way, no matter where you are in your component, you can trigger events, return data, update or whatever you want using the 3rd party or your own data models etc.

hope it helps,
Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: How to capture/use input that isn't saved in db? 14 Dec 2012 16:34 #6085

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
To get your posted var anywhere in your component :

$password = $jinput->get('password', null, 'STRING');
($jinput must be initialized)

You can do that in your controller, when save() returns true.
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: gdpodesta

Re: How to capture/use input that isn't saved in db? 14 Dec 2012 16:47 #6087

  • gdpodesta
  • gdpodesta's Avatar
  • Offline
  • Senior Member
  • Posts: 75
  • Thank you received: 8
  • Karma: -42
I think this is what i was looking for. I used "password" only as an example of data that was being captured on the form, sometimes user input, sometimes API results. In both cases, the data is not being saved in the record being edited, but is necessary at the time of that record update to do various kinds of external updates (DB & API).
The administrator has disabled public write access.

Re: How to capture/use input that isn't saved in db? 14 Dec 2012 16:51 #6089

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
With JInput, you can capturate anything you want coming fro GET or POST, and when you want during the process.
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: gdpodesta
Time to create page: 0.063 seconds

Get Started