Custom comment system

Status
Not open for further replies.

sunnyjey

Active Member
Hi, I'm developing the comment system. (yes, I'm aware of comment plugin, but im looking for more versatile feature). I have a list A and list B.

I have placed Form B as my comment system into the Outro of Form A using Fabrik content plugin. Now I want to link the Form B with rowID of List A. I have created a custom field form_A_id in Form B.

How do i grab the {rowid} of current List A (displayed in detail view of URL) to link Form B with the List A. I guess, I need to use PHP form onLoad to grab rowid.

I tried database element with dropdown option, but not able to figure out how to filter to the current rowid in the url.

Read hundreds of Fabrik forum posts still by head started aching, but no use.

Anyhelp will be highly appreciated.
 
I tried following code in Php form plugin:

Code:
$rowid= JArrayHelper::getValue($formModel->formData,'rowid','');
if (!empty($rowid)) {
   $db = JFactory::getDBO();
   $query = $db->getQuery(true);
   $query->update('mytable_contact')
   ->set("job_id = '$rowid'")
   ->where("id = $rowid");
   $db->setQuery($query);
   $db->query();
}

But, it gives rowid of the submitted form from List B instead of List A .
 
To get anything from the URL, use JInput ...

Code:
$app = JFactory::getApplication();
$foo = $app->input->get('foo', 'your default');

if you are going to use the value in a query, make sure you sanitize it. Either provide the type ...

Code:
$foo = $app->input->get('foo', 0, 'int');

... or cast it ...

Code:
$foo = (int) $app->input->get('foo', '0');

-- hugh
 
Thank you Hugh. But, somehow Im not able to generate rowid.

Plugin's settings :
do : php
in : both
on : both
process script : onBeforeProcess
PHP file : none
Require once : No

Code:
$app = JFactory::getApplication();
$jobid = (int) $app->input->get('rowid', '0');
$formModel->updateFormData( 'mytable___job_id', $jobid , true );

The form is outputting default value '0' in place of rowid from the current URL page.
 
What is an example URL of the page you are doing this on? Is it a normal Fabrik component link, like index.php?option=com_fabrik&view=details&rowid=123 (or the SEF'ed equivalent)?

-- hugh
 
Ah, you are running this onLoad. In which case $formModel->updateFormData() won't do anything. That only works on submission.

What might work would be having an eval'ed default on the job_id element, that returns the input->get().

-- hugh
 
I tried with an eval'ed default on the job_id element:

$input->get(mytable___id)

AND

$formModel->getElementData('mytable___id')

But no use.

Is it possible to get 'rowid' of current fabrik detail page with the help of database join with WHERE clause ?
 
Hmm... I'm literally getting headache for this.:eek:

Let us start with the basic:

Table 1: mytable_job
Table 2: mytable_comments

I then placed {fabrik view=form id=X } in outro of Form of Job List (X = Form ID)

I then created a job_id 'field' element in Table 2 to use as join value for Table 1

Then placed following code in default of job_id and enabled Eval

Code:
$app = JFactory::getApplication();
$jobid = (int) $app->input->get('rowid', '0');
$formModel->data['mytable_comments___job_id_raw']=$jobid;

Also tried:

Code:
$app = JFactory::getApplication();
$jobid = (int) $app->input->get('rowid', '0');
$formModel->data['mytable_job___id_raw']=$jobid;

View attachment 17249 View attachment 17249

But no use. What is going wrong.

PS: Somehow I am not getting Popup of Jdump even after enabling the plugin.
PS: I have added my website and other details in NOTES of my-site at Fabrik Profile
 
no, my code would be for setting fields in a php "onLoad" plugin.

Not sure about your setup:
"mytable_job___id" sounds like the primary key (table= mytable_job, column=id) which will be set automatically (autoincrement)
"mytable___job_id" (as in post #4) sounds more reasonable.

If you want to set a default in a new record:
Did you try to set the default directly with
{fabrik view=form id=X my-table___job_id=[rowid]}

If you are using the element Default with eval=yes you must return the value:
$myapp = JFactory::getApplication();
return (int) $myapp->input->get('rowid', '0');
 
If you want to set a default in a new record:
Did you try to set the default directly with
{fabrik view=form id=X my-table___job_id=[rowid]}

This was the first thing I had tried. But whenever, I used to put [rowid] in content plugin, the Content LIST of same Form used to disappear. Then I started exploring the other options.

But, after your message, I deleted entire LIST and re-created with [rowid] through content plugin syntax and voila it worked !!

Thank you Hugh and Troester for your help. Because of this error I read hundreds of Forum Threads and now enriched with the knowledge.
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top