Email this article

Discussion and education for beginner / novice programmers interested in embarking on the development process to take advantage of the extensible nature of the Joomla! CMS.
Locked
yevpak
Joomla! Apprentice
Joomla! Apprentice
Posts: 23
Joined: Mon Jun 12, 2006 10:20 am
Contact:

Email this article

Post by yevpak » Mon Jun 16, 2008 8:00 pm

Hi,

I am not sure if this is the right place to post such question but from what I see my issue falls in the sphere of coding...

Anyhow, we all know the wonderful three button which can be activated for all content items: print, pdf and email. My question is about the email functionalty. Is there a way to modify the email form so that in the "subject" joomla will capture and display the name of content item from which the user clicked on the "email" button, and also is it possible to include in the "message" field some default text, for example a signature?

I would greatly appreciate your help.

If there already are answers to these questions on the forum please send me a link.

THANKS

blixz
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Mon Dec 17, 2007 4:20 pm

Re: Email this article

Post by blixz » Mon Jun 16, 2008 10:51 pm

Hi,

If you're using Joomla 1.5 (I tried it in 1.5.3) you can do what you want by editing the file:
folder where you have installed joomla/components/com_mailto/views/mailto/view.html.php
The method you want to change is: getData

This is where you can change the default values:
Starts in line 47 (Joomla 1.5.3):
// Load with previous data, if it exists
$mailto = JRequest::getString('mailto', '', 'post');
$sender = JRequest::getString('sender', '', 'post');
$from = JRequest::getString('from', '', 'post');
$subject = JRequest::getString('subject', '', 'post');

The second parameter in the getString is the default value. For example, if you want to change the default subject to say "Interesting article", change the $subject line to:
$subject = JRequest::getString('subject', 'Interesting article', 'post');

I know you want the subject to contain the name of the content item. There is no really easy way to do that. Unless I'm missing something, the way to do that would be to get the id of the article from the url and then get the title of the article using the id (if you move your mouse over the send email icon you'll see an url similar to this:

Code: Select all

http://localhost/joomla153/index.php?option=com_mailto&tmpl=component&link=aHR0cDovL2xvY2Fs
that link parameter is the actual link (encoded in base64) to the article you want to email (that's what shows up in the email, a link to the article and not the article itself). After decoded that link contains the article id).

If you look in the getData method the link is decoded there. The rest, I leave it to you :P
(I don't think that getting the title of the article using the id in the link parameter in the url is a very elegant solution, but the only other one I can think of, and that one is far better, would be to change the component that displays the articles and the email link (com_content) to include another parameter in the url with the article title.)

About adding a signature to the body of the message, that's way easier, just edit this file:
folder where you have installed joomla/components/com_mailto/controller.php
The method to look for is Send:
Edit this line:
$body = JMailHelper::cleanBody($body);

If you want to add as a signature, "This is my signature", change that line to this:
$body = JMailHelper::cleanBody($body)."\n\nThis is my signature";

And that's it! Hope it helps.

Consider having a look here: http://www.joomladevuser.com. The tutorial about component development is not complete yet (but it is almost complete). I think it would help you understand how components work in Joomla 1.5.

Best,
Rui

yevpak
Joomla! Apprentice
Joomla! Apprentice
Posts: 23
Joined: Mon Jun 12, 2006 10:20 am
Contact:

Re: Email this article

Post by yevpak » Mon Jun 16, 2008 11:00 pm

Thanks for such comprehensive answer! But I am using Joomla 1.0.15. Does it change anything in what you wrote?

blixz
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Mon Dec 17, 2007 4:20 pm

Re: Email this article

Post by blixz » Tue Jun 17, 2008 10:03 am

Yes, it will definitely be different, but the idead is the same:

Check the frontend code for the mailto component (com_mailto) and see where the subject and email body fields are initialized, and change it there.

I don't have Joomla 1.0 installed so I can't really tell you more than this...

User avatar
bas123
Joomla! Intern
Joomla! Intern
Posts: 67
Joined: Fri May 09, 2008 2:49 pm

Re: Email this article

Post by bas123 » Thu Jul 17, 2008 1:53 pm

blixz wrote:if you move your mouse over the send email icon you'll see an url similar to this:

Code: Select all

http://localhost/joomla153/index.php?option=com_mailto&tmpl=component&link=aHR0cDovL2xvY2Fs
that link parameter is the actual link (encoded in base64) to the article you want to email (that's what shows up in the email, a link to the article and not the article itself). After decoded that link contains the article id).

If you look in the getData method the link is decoded there. The rest, I leave it to you :P
This may be helpful to me in debugging my problem, but I need additional help!
I am having a situation using mxcomment which replaces the email icon with it's own.

When using this component, it sends an email with a duplicate folder path in the URL string...

Code: Select all

http://www.website.com/community//community/index.php?view=article&id=50
note the duplicated "community//"

The link should be:

Code: Select all

http://www.website.com/community/index.php?view=article&id=50
I am asking here, because the developer of the mxcomment component has failed to respond to several posts and other requests for help

I have searched my entire site (particularly the files within the component and plugin) to find the file which generates the URL but cannot find it...

Can you help me figure this out?

Thanks
Listen... and Keep to the point! :)


Locked

Return to “Joomla! Coding 101”