Hooks help

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
bescott53

Hooks help

Post by bescott53 » 2013-02-28 23:58

Hello everyone, I am still trying to learn my way round appgini and would like to take the data from my contacts form once it has been submitted or edited to copy fields (RefNum, Title, FirstName, LastName, LastVisit) into my Visits table fields (ContactRefNum, Title, FirstName, LastName, LastVisit). I have tried the following in the hooks file but it does not seem to be working? The first two lines are good and they update great thanks to this board..Any help would be appreciated.

$NextVisitTS = strtotime($data['LastVisit']) + $data['x631Status'] * 30 * 86400;
$data['NextVisit'] = date('Y-m-d', $NextVisitTS);
$query = "INSERT INTO Newport_Visits
(ContactRefNum, Title, FirstName, LastName, LastVisit)
VALUES
('RefNum', 'Title', 'FirstName', 'LastName', 'LastVisit')";

bescott53

Re: Hooks help

Post by bescott53 » 2013-03-02 15:37

I have had a quick look through this (PHP is totally new to me) and I can see that there is info being stored in members tables when data is being input. The last 3 lines would not be sufficient I dont think. What I really want is once someone enters or updates data in the Contacts table, some of the key fields (above) are also copied into a new record of the visits table (along with anywhere else it needs to go too)

I would appreciate any pointers to get me going.

Johnk
AppGini Super Hero
AppGini Super Hero
Posts: 68
Joined: 2013-01-09 03:47
Location: Cairns, Australia

Re: Hooks help

Post by Johnk » 2013-03-03 03:09

bescott53, I'm with you. Although Ahamad has put several examples on the web site, I think they may need a revisit if Appgini is to become a programming buzzword. I've only done a little PHP using very basic code and I'm not alone there. Despite that, I've written some pretty powerful scripts in my time. The code in Ahmad's examples is often far too advanced for me to even understand and if you read other threads here, you will see that I've also asked for some basic help. - Basic is always the best place to start,

I have tried several hooks but nothing works. I'm missing that "basic" ingredient, but can't figure out what it is. Rightly or wrongly I'm looking at hooks as an "Include" files which is added before an update or after it. That I can understand. What I can't understand is why my simple code that works in a normal PHP script refuses to work in a hook.

I'm repeating myself I know, but Hooks need a chapter in the "manual" with absolute basic examples and not examples taken from a complex working script. Your question is a perfect example and one that will help me and others: How do you get a field in Appgini to update another field using Hooks? I could write a hundred simple questions like that if Ahamad or some other kind user could answer them. Then maybe we could start updating the manual I've already started. http://forums.appgini.com/phpbb/viewtopic.php?f=4&t=7

Post Reply