Forums

Get Joomla article ID to a global variable?

ColinBuckley1964 16 Sep, 2021
Hi

I have created a form and I am 99% ready to deploy it live, but its that last 1% that is driving me nuts!
Basically, I have a set or articles that are each an event and I want to use just one booking form for all events. Simple, but on each event article there are 8 custom Joomla fields some of which I read into the form to populate certain fields. This is all working.

Reading the custom fields into an array using a read data action.



Turning on the debugger, I was able to determine the order of the fields in the array.

Populating fields in the form with the data returned in the array is achieved by using the “Values & Placeholder” option in the advanced settings.

The construct of the value 
{var:read_data_39.6.ReadCustomFields.value}
read_data_39 - The ID of the “Read Data”
6 - Is the index element of the returned array. IE the field I want.
ReadCustomFields - Is the model name used in the “Read Data”

My problem is the 546 (ringed in yellow) in the data read (first image). This is the articleID of the test article I am using. I want to replace 546 with the articleID (programmatically) of the event article of the article being used.
Back to the title of this post. Is it possible to get the articleID into a global variable that can used in the Data Read?

I have tried a block of PHP before the data read using the following two lines of code, neither have worked.

$ID = JRequest::getInt('id');
And
$ID = (JRequest::getVar('option')==='com_content' && JRequest::getVar('view')==='article')? JRequest::getInt('id') : 0;


Now stumped! Any help would be greatly appreciated.
Cheers
Colin
GreyHead 17 Sep, 2021
Hi Colin,

Normally ChronoForms adds the page URL info to the form data so the value should be available in {data:id} The Debugger should let you see if it is there.

Bob
ColinBuckley1964 17 Sep, 2021
Thanks for this Bob.

99% there, more 99.5%!!!
So simple in the end!!
Just replace the value 546 with {data:id}


I wont be the first to say this but CF7 needs some good documentation!
Never mind buy you a coffee, I'll buy you a pint!

Cheers and thanks for the quick response.
Colin
You need to login to be able to post a reply.