How to store article title in contact form

ernst67

New Member
I've searched the wiki and the forums but I can't find the answer to this.

Here's the situation:

I have successfully installed Fabrik 3.0.6 on Joomla 2.5 and built my first form. The from is a contact-form and is embedded in an article. After submission the data is stored in the DB and an email is sent to the webmaster.
Now in that email, I would like to store the Article ID, or better: the Article Tilte, from which that for was submitted. Just because multiple articles on the site have this contact form embedded.

Could that be done?


Thanks for a fantastic component!
 
I've searched some more, and I can't find any plugin that does this. So it probably has to be done with a PHP validation.. but how....?
 
You can do this with an eval'ed default in a simple field element.

PHP:
return JRequest::getInt('origid', 0);

Note the usually the article ID would be in the 'id' request (query string) variable, but when processing a Fabrik content plugin, we have to reset the 'id' request variable to the Fabrik form/list/viz ID being rendered. So we store the original 'id' from the URL into 'origid' in the global request array, then reset it when we're done processing that content plugin.

-- hugh
 
Thanks for your reply Hugh.

I already made it to eval, field part.

I've set an element field to "eval", the validation to "php" and entered your code, but alas it does not return any value.

The field is the last one in the form, could that be a problem?
 
.. there is something else I noticed.
I was testing with the field set to "hidden". Now, when i test with this field set to visible, and during submission I do fill in some info, it does not get replaced. The field stores the data entered.

Is this maybe a bug?
 
Why are you putting the code I gave you in a validation? I said:

an eval'ed default in a simple field element

So try that (put the code I gave you in the 'default' box for you field element, and set 'eval' to Yes) which should set that element to the article ID when you load a new form on your content page.

If that works, I can give you the code so it saves the article name rather than the ID.

Or (once it is defaulting to the correct ID) you could simply try changing the element type from a field element to a database join, pointing at the J! content table, with key set to 'id' and label set to 'title'. That should automagically then render that element's placeholder in an email template as the article title.

-- hugh
 
Sorry Hugh,

I'm not trying to be stubborn; I just didn't realise it had to be put there, rather than a validation.

I just did exactly like you said, but I keep getting the value 0 as return. The actual article number is 1.

-Ernst
 

Attachments

  • Naamloos.jpg
    Naamloos.jpg
    46.4 KB · Views: 395
OK, now tested some more and it seems that it works if the article is the only article on the page. If the article is part of a blog it doesn't return the correct number, neither if the article is listed on the front page (as the "home" article.

For me this is a workable solution. If you could give a code so it saves the article name rather than the ID, that would be brilliant.

Thanks again
 
Hi Hugh,

I managed on my own, using a database join.
My first join, it took me an hour..

Don't laugh, I'm very proud of myself :)

Thanks again!

Ernst
 
Sorry, had a death in the family, got behind on support.

OK, so you said you had it working as a join element, pointing to the id of the #_content table? So you should have been able to set the 'label' of the join to the title field from the #_articles table? At which point using the {tablename___Article_ID} placeholder in your email template give you the title.

To build a URL, you would use {tablename___Article_ID_raw} to give you the id. Adding _raw to a placeholder name gives your the 'value' rather than the 'label' of the element data. In some cases that are the same (like a simple field element), but for a join element, _raw is the join's value, non-raw is the label.

You can then build the URL by inserting that raw value into some link markup ...

Code:
this is a <a href="/index.php?option=com_content&view=article&id={tablename___Article_ID_raw}">link to some content</a>

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top