Welcome, Guest
Username: Password: Remember me

TOPIC: Create New => Run Function

Create New => Run Function 02 Jul 2013 00:38 #7796

  • jcbenton
  • jcbenton's Avatar
  • Offline
  • Premium Member
  • Posts: 125
  • Thank you received: 9
  • Karma: 3
I have a component I made earlier this year with jCook v2.0. I came back to update/upgrade the component to add some features. Well, the structure has changed and I was wondering if someone could point me in the right direction.

Before:

com_name > admin > tables > the_item.php

Within this file was this:
	/**
	* Overrides JTable::store to set modified data and user id.
	*
	* @access	public
	* @param	boolean	$updateNulls	True to update fields even if they are null.
	*
	* @return	boolean	True on success
	*/
	public function store($updateNulls = false)
	{
         .....
        }


I inserted my code that needed to run after a new item was created and life was good. In v2.5.4 this no longer exists. I am assuming it has been moved?

Ideas?
--
Jerry Benton
The administrator has disabled public write access.

Create New => Run Function 02 Jul 2013 00:52 #7797

  • jcbenton
  • jcbenton's Avatar
  • Offline
  • Premium Member
  • Posts: 125
  • Thank you received: 9
  • Karma: 3
I may have answered my own question. Is it now in the FORK for each item?


www.j-cook.net/index.php/forum/added-fun...ctionality-for-forms
--
Jerry Benton
The administrator has disabled public write access.

Create New => Run Function 02 Jul 2013 20:40 #7809

  • jcbenton
  • jcbenton's Avatar
  • Offline
  • Premium Member
  • Posts: 125
  • Thank you received: 9
  • Karma: 3
Well I am at a loss. I have reviewed the Forks documentation. Reviewed MVC (again). I can't figure out the new structure or where to place my function.

Basic Structure:

Pages >
>> Backend
>>> Item
>>>> View Item page
>>>> Create item page

When I create an item I need to fire off some custom code. So if you could please tell me where I would place this code, I would appreciate it.

Also, when I create an item and make a user the "Created By", the item always saves as me, the person creating the item. My other component correctly saved as the user I was selecting. (jCook v2.0)
--
Jerry Benton
The administrator has disabled public write access.

Create New => Run Function 03 Jul 2013 22:42 #7841

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Table::store() > Model::prepareTable()

I do nit understand the problem with Created by... For me it works very good.
Did you downloaded recently ?
Coding is now a piece of cake
The administrator has disabled public write access.

Create New => Run Function 03 Jul 2013 22:44 #7842

  • jcbenton
  • jcbenton's Avatar
  • Offline
  • Premium Member
  • Posts: 125
  • Thank you received: 9
  • Karma: 3
Yes, I downloaded it yesterday. I looked at some of the code. It appears that there are checks for the assigned user's ACL permissions and if they are not set a certain way, it changes it to the admin creating the record. I have to go back, edit the record, and change it again. Then it works.
--
Jerry Benton
The administrator has disabled public write access.

Create New => Run Function 03 Jul 2013 22:47 #7843

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
If you want to execute after store(), then it is still possible.

Create this store() function in the table file. (Same than before)
Write ALL your customs in fork files.

Copy the original function from the Joomla native table class
libraries/table/table.php
public function store($updateNulls = false)
{
  return parent::store($updateNulls);

  // FORK AFTER
}
Coding is now a piece of cake
Last Edit: 03 Jul 2013 22:49 by admin. Reason: added return ... in code
The administrator has disabled public write access.

Create New => Run Function 03 Jul 2013 22:48 #7844

  • jcbenton
  • jcbenton's Avatar
  • Offline
  • Premium Member
  • Posts: 125
  • Thank you received: 9
  • Karma: 3
Ok thank you. I will look at it over the weekend.
--
Jerry Benton
The administrator has disabled public write access.
Time to create page: 0.099 seconds

Get Started