Welcome, Guest
Username: Password: Remember me

TOPIC: Execute extra on form submit

Execute extra on form submit 29 Oct 2012 22:57 #4837

  • jcbenton
  • jcbenton's Avatar
  • Offline
  • Premium Member
  • Posts: 125
  • Thank you received: 9
  • Karma: 3
Hello,

I am almost done with this component. I just need to add some code, but I need to know where to add it.

User Collection View:

- clicks on a link that allows the user to edit 1 field.
- user enters data, clicks save.

Now I need to run some extra PHP code, but just for that form. What and where is that controller?


Second item:

I have multiple Collection layouts for the same table. So, it is something like this:

Active | Expired | Trial

What I need to do is modify the SQL select for each one so that I can display the records correctly. For example:
SELECT FROM this_table WHERE expire_date < date('now')
This is for active licenses.


Can someone point me in the right direction to make these modifications?

Thanks :)
--
Jerry Benton
Last Edit: 29 Oct 2012 23:20 by jcbenton.
The administrator has disabled public write access.

Re: Execute extra on form submit 29 Oct 2012 23:56 #4841

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
I think what you need is listquery() - either that or prepareQuery()

It'll be in the controller for the collection you're working on...

Use $query->where etc to adapt the queries as required.

Sorry if a bit vague. Too tired to check ATM but can do tomorrow if this doesn't help.

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: Execute extra on form submit 29 Oct 2012 23:57 #4842

  • jcbenton
  • jcbenton's Avatar
  • Offline
  • Premium Member
  • Posts: 125
  • Thank you received: 9
  • Karma: 3
Ok, what file? :)

Go to bed. I will look at this tomorrow as well.
--
Jerry Benton
The administrator has disabled public write access.

Re: Execute extra on form submit 30 Oct 2012 00:03 #4843

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Whatever the name of the controller for the layouts you're using...

Actually, you could just add a filter on the grid. Filter by the field holding expired, active etc... Then, you could even pass it in the URL if you wanted. That way, you technically have one layout...

Sure,

I'll take a look tomorrow. Btw are you using enum field or a fk for your different 'states' ( active etc)?

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: Execute extra on form submit 30 Oct 2012 00:06 #4844

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
components/com_yourcomponent/controllers/your_controller.php or
administrator/components/ com_yourcomponent/controllers/your_controller.php
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: Execute extra on form submit 30 Oct 2012 00:07 #4845

  • jcbenton
  • jcbenton's Avatar
  • Offline
  • Premium Member
  • Posts: 125
  • Thank you received: 9
  • Karma: 3
State is based on current date.

If timestamp < today it is expired.

I have an integer field for the "Trial". 1 = trial and 0 = no trial.

So to list trial licenses I just have to add:
WHERE trial='1'

For Active I need to add:
WHERE now() < expire_date

And for Expired:
WHERE now() > expire_date
--
Jerry Benton
The administrator has disabled public write access.

Re: Execute extra on form submit 30 Oct 2012 00:08 #4846

  • jcbenton
  • jcbenton's Avatar
  • Offline
  • Premium Member
  • Posts: 125
  • Thank you received: 9
  • Karma: 3
Thanks. I will look at them tomorrow. I need to go sleep :)
--
Jerry Benton
The administrator has disabled public write access.

Re: Execute extra on form submit 30 Oct 2012 08:37 #4851

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Did you get this sorted?
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: Execute extra on form submit 01 Nov 2012 11:12 #4883

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
models/xxxxs.php

function prepareQuery()
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: JoomGuy

Re: Execute extra on form submit 01 Nov 2012 11:25 #4887

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Sorry @admin & @jcbenton - I told you to look in the controller, not the model!!!

That was silly but, I did say it was late!

Hope you got or get it sorted
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.
Time to create page: 0.072 seconds

Get Started