0

I have a site where registered users can add content in the frontend and when added administrators are sent an email, notifying them of a new article. This is driven by languages constants:

COM_CONTENT_NEW_ARTICLE
COM_CONTENT_ON_NEW_CONTENT
COM_MESSAGES_PLEASE_LOGIN

In the constant COM_MESSAGES_PLEASE_LOGIN, there is a URL link to the message within Joomla, which according to the language file is the following:

Please log in to %s to read your message.

However, I want to update this to show a link to the article within the backend, which I can build from the ID of the article and category etc... However, where are these messages handled from within Joomla? Or where can I change the content within %s shown in the message?

2 Answers 2

0

The email that is sent to you is coming from com_messages and in particular the email is generated from /administrator/components/com_messages/models/messages.php around line 362

However this code is only sending a notification email to you to say that some other process has put a message into your inbox via the com_messages component.

This is the code from 362 to 372 and the last couple of lines is where your change needs to happen

    // Build the email subject and message
    $app      = JFactory::getApplication();
    $linkMode = $app->get('force_ssl', 0) >= 1 ? Route::TLS_FORCE : Route::TLS_IGNORE;
    $sitename = $app->get('sitename');
    $fromName = $fromUser->get('name');
    $siteURL  = JRoute::link('administrator', 'index.php?option=com_messages&view=message&message_id=' . $table->message_id, false, $linkMode, true);
    $subject  = html_entity_decode($table->subject, ENT_COMPAT, 'UTF-8');
    $message  = strip_tags(html_entity_decode($table->message, ENT_COMPAT, 'UTF-8'));

    $subj     = sprintf($lang->_('COM_MESSAGES_NEW_MESSAGE'), $fromName, $sitename);
    $msg      = $subject . "\n\n" . $message . "\n\n" . sprintf($lang->_('COM_MESSAGES_PLEASE_LOGIN'), $siteURL);
0

The file which manages this is:

/var/www/wychavon.gov.uk/public_html/plugins/content/joomla/joomla.php

And have also created a language constant override for 'COM_CONTENT_ON_NEW_CONTENT'

⚠️IMPORTANT to note⚠️ The joomla.php file is part of the core Joomla plugins, but it is not part of a layout, so we can't put it in as an override. There is a backup of the original file and a copy of the new file here:

/var/www/wychavon.gov.uk/public_html/plugins/content/joomla/joomla.backup.php /var/www/wychavon.gov.uk/public_html/plugins/content/joomla/joomla.new.php

Changing core files is definitely NOT recommended and I wouldn't normally do it, but this seemed to be the only way to make this change within the message. There is some potential that this file will be overwritten in the future releases, that's why I've created a joomla.new.php.

The only change that has been made on the file is on line 88 I've changed it from:

'message' => sprintf($lang->_('COM_CONTENT_ON_NEW_CONTENT'), $user->get('name'), $article->title)

to

'message' => sprintf($lang->_('COM_CONTENT_ON_NEW_CONTENT'), $user->get('name'), $article->title, $article->id)

The language constant (COM_CONTENT_ON_NEW_CONTENT) has then been overridden (you will see this in backend > Extensions > Languages > Overrides) from:

A new Article has been submitted by '%1$s' entitled '%2$s.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.