[How to] Add message counter to Mosets Tree
Hi, in this post i will show you how to start counting messages sent through contact forms in your Mosets Tree Joomla directory.
This little feature can help you and your customers to track number of messages of every listing on the site.
1. Make custom field
Go to Mosets Tree Component, then to Custom Fields (On the left)
2. Create new Custom Field
For Field type choose “Number”
For showing options of the field at the bottom Choose Yes for Published and Hidden, and for everything else choose no. This way your field will be visible only in the backend.
Now Save the Custom Field, and find what is it’s “id number”. You can see this when you hover custom field name and look at the status bar. This is the number at the end of the address “…&cfid=64″. Here it is ” 64″.
3. Set the value to Zero
Now you must set value of this field to “0(zero)” for all your listings.
To do this you need to log in to your cPanel, and go to phpMySql. Now run following query
DELETE FROM `jos_mt_cfvalues` WHERE cf_id = 64; INSERT INTO jos_mt_cfvalues (`cf_id`, `link_id`, `value`) SELECT '64', link_id, '0' FROM jos_mt_links;
where you should change “64″ with the id of your Custom field ID number.
4. Start counting messages
Now when you have custom field it is time to start counting all your messages.
To do this you will need to add extra piece of code to send_contact() function in your mtree.php file in your /public_html/components/com_mtree folder. Function is located somewhere around line 2855.
So, if you found it scroll down until the end of the function wher you should see
mosRedirect( "index.php?option=$option&task=viewlink&link_id=$link_id&Itemid=$Itemid", $_MT_LANG->CONTACT_EMAIL_HAVE_BEEN_SENT);
Right before this line you should paste:
$sql = "UPDATE jos_mt_cfvalues SET value = value +1 WHERE link_id ='$link_id'AND cf_id =64"; mysql_query($sql);
where you should change “64″ with id number of your custom field that will store number of messages.
That’s it.
Now you will be able to see number of messages sent to the owner of each listing by going to that listing in back end.
By changing the visibility options of your customfield you can display it in front (summary, details,…)
Enjoy
DELETE FROM `jos_mt_cfvalues` WHERE cf_id = 64; INSERT INTO jos_mt_cfvalues (`cf_id`, `link_id`, `value`) SELECT '64', link_id, '0' FROM jos_mt_links;
Popularity: 27% [?]
Related posts:
- Improve Mosets Tree 2.0 SEO by editing listing title and description
- How to add description to Joomla Marketplace?
- [MS Office] Creating email signature with photo or logo in MS Outlook 2007
- PHP sendmail on Bluehost – setting “from” address
- Seo importance, Joomla site with or without www, .htaccess 301 redirection


12. Dec, 2009 






Hey Toma,
Unfortunately in MT ver. 2.1.3 in mtree.php cannot be find “mosRedirect( “.
Do you have any idea were I have to insert the “$sql = “UPDATE jos_mt_cfvalues SET value = value +1 WHERE link_id =’$link_id’AND cf_id =64″;
2 mysql_query($sql);”
Your support will be really appreciated.
Thanks
Mark