Form + email plugin

marioms

Member
Hi guys,

I am struggling a little bit with this project I'm working on. I have checked the email plugin page explanation but I still dont understand how it works or how can it help me with this.

The idea is very simple, registered users must upload their CV (Using a Fabrik form) and at the time of submitting the form, they should receive an email with the following details:

Dear [Username]

Thank you for your CV application to become a member. We shall evaluate all applications by mid January 2016. You will be informed of the outcome of this exercise as soon as it is complete.


File received: (Name of File)
User: (Name of user)
Date: (Date of upload)
Time: (Time of Upload)
Nationality: (Nationality) <- I use easyprofile for user registrations so this field is attached to the user and in the users table.

Regards,

The Team

I am not sure how to develop this in Fabrik, I already created the form but I am struggling with the email part. it would be very helpful if you can give me a hand with this. Thanks!
 
You can do this by making regular Joomla article and use the Fabrik palceholders {tablename__elementname} in the article. Than in the email form plugin you go to options and in 'Article template' you can find a list of all your joomla articles. Pick the article you saved with the Fabrik placeholders. Fill in the 'from'; 'reply-to' and 'subject' and keep the rest of the option tab open.
 
Some of the substitutions are things that might not be in your fabrik table. If that is the case you can use a php plugin or an email template. Make the article as suggested by Hyena and in those places where you need other information insert a special placeholder such as {##_nationality}.

If you use a php plugin you will read in this article from the database. Use php to get the nationality from the database then use a str_replace to replace it in the article. Do this for any other replacements you need. You can access your form data using $formModel->formData['element name']. Then simply use the php mail function to email the result.

If you want to use a template you do your php stuff at the beginning of the template file (reading nationality etc into local variables), then copy the plaintext copy of your article (toggle the editor so you see the html source) into your template (after the closing php tag). In those locations where you want to insert your custom variables change out the custom tags with <?php echo $nationality ?>. No need to manually handle the form data substitutions, Fabrik will do that for you as described above by Hyena.

Hope that helps.
 
Last edited:
Thanks for the answer guys, I am trying to figure all out. I have another question. While doing the form, one of the elements is Nationality, now, this field is related to the user profile table (its not a fabrik table). I want to do something similar to the user element plugin (where when you submit a form, you can see the username of the person who sent that form) but with the Nationality field (like with the username, I want fabrik to retrieve the nationality of that user and show it on the list) any ideas?

Thanks!!
 
Again, use the Calc field, just insert php code to retrieve the value and then return it. For example:

Code:
$db        = &JFactory::getDBO();
$query    = $db->getQuery(true);
$query->select('nationality')
     ->from('#__nations_db')
     ->where("userID=" . $my->id);
$db->setQuery($query);
return $db->loadResult();

I haven't tested this and you will have to insert your own variable and Db names but it should work.
 
Thank you, another question! I have a CV list, and I want to publish it on the menu but I want the user to be able to see ONLY the CV he has submitted on the CV form, is it possible?
 
Yes. Add a 'user' element to the form. Add a pre-filter to the list, which filters on the userid(raw) element = {$my->id}.

-- hugh
 
A simple question, users may try to upload more than one CV document (maybe they forgot to add something) but I dont want them to be deleting stuff around, is there a way in which the user, when uploading a new cv, gets the old document deleted? thanks!
 
No, that option is disabled. When I upload a new file with the same name as the previous one it just appears on the list along with the previous file so I have 2 with the same name.
 
Hi Hugh, sorry for the late reply I got this working.

I have two more questions, I did put the code:

$db = &JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('nationality')
->from('magdb_jsn_users')
->where("id=" . {$my->id});
$db->setQuery($query);
return $db->loadResult();

It works but the only thing that gives back is a number. I have a list of nationalities on another table. I am using easyprofile to generate that. The element in easyprofile is a dropdown connected to a table in the database with a list of nationalities. This are the seetings for the element in easyprofile:

Table: magdb_nationality
Column for Value: nationality_id
Column for Text: nationality

It seems that the value stored on:
$query->select('nationality')
->from('magdb_jsn_users')
is the nationality_id.

Right now on my list, fabrik is showing Nationality = 20. How can I reconstruct the code so it shows the nationality and not the id?

Another question, I used the email plugin so when the user submits a CV it sends an email to the admin. On the email I use some placeholders with information about the form. One of them is a placeholder for the file uploaded so it shows up on the email. The client does not want the file to be a link on the email, right now you can click on it and download it. Is it possible to remove that feature and only show the name of the file?

Thanks!
 
If you find yourself bumping threads needing custom code written for you to meet deadlines for clients, you really should take out a paid support subscription.

You need to join the nationalities table in your query as it's a join element, for which yes, we store the FK (foreign key) value pointing to the row in the joined table, not the "label".

Code:
$myDb = FabrikWorker::getDbo();
$myQuery = $myDb->getQuery(true);
$myQuery
   >select('n.nationality')
  ->from('magdb_jsn_users as u')
  ->join('LEFT', 'magdb_nationality as n ON n.nationality_id = u.nationality')
 ->where("u.id= '{$my->id}'");
$myDb->setQuery($myQuery);
return $myDb->loadResult();

Note that although in a lot of examples from the past on the forums you'll see us using $db and $query, it's best to use something else, to avoid clashing with variables of the same name within the Fabrik code. And although either will work, using FabrikWorker::getDbo() rather than JFactory::getDbo() is slightly preferable.

-- hugh
 
Thanks a lot Hugh, I will ask my boss to get the paid support today for future inquiries. By the way, when a user submits a CV it sends to the admin an email with the document (not attached, the template has the fabrik file placeholder) and it can be clicked (its a link). Any ways to remove that? (show only the name of the document). Thanks!!

Mario
 
The _raw at the end of the placeholder works.

I put the code you gave me for the nationality but when I submit the form it throws me a 500 page error. Thanks!
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top