Advertisement

expand COM_CONTENT_SAVE_SUCCESS="Article saved." Topic is solved

For Joomla! 4.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Post Reply
hgh-esn
Joomla! Apprentice
Joomla! Apprentice
Posts: 19
Joined: Sun Jun 27, 2010 10:42 am

expand COM_CONTENT_SAVE_SUCCESS="Article saved."

Post by hgh-esn » Mon Sep 23, 2024 5:21 pm

How can I expand the message

COM_CONTENT_SAVE_SUCCESS="Article saved."

to something like this?

COM_CONTENT_SAVE_SUCCESS="Article saved at $Timestamp."

Reason: When editing an article, I often saved it by the "save-button" and the message will remain at top.
Sometimes it would be very useful to have the time of the last save being displayed in the message.

Is there an easy way to change it - e.c. via an override?

Advertisement
SharkyKZ
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3103
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: expand COM_CONTENT_SAVE_SUCCESS="Article saved."

Post by SharkyKZ » Tue Sep 24, 2024 8:28 am

Creating a language override is not enough, you need to pass the timestamp and for that you need to write some PHP code. A complex solution is a MVC override plugin that overrides the controller where the message is generated. A simpler but less reliable way is to manipulate the message queue. This should be done during onAfterDispatch or later event:

Code: Select all

$app = $this->getApplication();
// Retrieve messages and clear the message queue.
$messages = $app->getMessageQueue(true);

foreach ($messages as $k => $message)
{
	// Match and replace the message in question.
	if ($message['message'] === $app->getLanguage()->_('COM_CONTENT_SAVE_SUCCESS'))
	{
		$message['message'] =  $app->getLanguage()->_(sprintf('PLG_SYSTEM_EXAMPLE_SAVE_SUCCESS', $timestamp));
	}

	// Repopulate the message queue.
	$app->enqueueMessage($message['message'], $message['type']);
}
This may work from a template override but is not recommended.

hgh-esn
Joomla! Apprentice
Joomla! Apprentice
Posts: 19
Joined: Sun Jun 27, 2010 10:42 am

Re: expand COM_CONTENT_SAVE_SUCCESS="Article saved."

Post by hgh-esn » Tue Sep 24, 2024 3:51 pm

Hello SharkyKZ, thank you for your answer and the quick solution. But I still have more questions.

1. I have studied this: http://joomla-templates.de/template-overrides, but unfortunately I cannot identify the correct file in which the message is displayed. I also don't have enough background knowledge to know how to implement your solution there. Can you help me with that?

More questions.

2. Isn't the override dangerous because, if I have understood correctly, the original files are no longer accessed and any updates to the Joomla core no longer take effect?

3. In that sense, overring is more of a testing thing. The better long-term solution seems to me to be modifying the Joomla core.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44750
Joined: Sat Apr 05, 2008 9:58 pm

Re: expand COM_CONTENT_SAVE_SUCCESS="Article saved."

Post by Webdongle » Wed Sep 25, 2024 3:19 am

Searching it in language override might show you the file and location?
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

hgh-esn
Joomla! Apprentice
Joomla! Apprentice
Posts: 19
Joined: Sun Jun 27, 2010 10:42 am

Re: expand COM_CONTENT_SAVE_SUCCESS="Article saved."

Post by hgh-esn » Wed Sep 25, 2024 1:31 pm

... sorry I tried it in "language override" for every "site/administrator" and all languages (GB/DE) with no success.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44750
Joined: Sat Apr 05, 2008 9:58 pm

Re: expand COM_CONTENT_SAVE_SUCCESS="Article saved."

Post by Webdongle » Wed Sep 25, 2024 2:34 pm

hgh-esn wrote: Wed Sep 25, 2024 1:31 pm ... sorry I tried it in "language override" for every "site/administrator" and all languages (GB/DE) with no success.
language override 01.jpg
You do not have the required permissions to view the files attached to this post.
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

hgh-esn
Joomla! Apprentice
Joomla! Apprentice
Posts: 19
Joined: Sun Jun 27, 2010 10:42 am

Re: expand COM_CONTENT_SAVE_SUCCESS="Article saved."

Post by hgh-esn » Wed Sep 25, 2024 7:34 pm

... that is easy, the language-file isn't the problem.

I'm looking for the php-file, from which the display happens.

hgh-esn
Joomla! Apprentice
Joomla! Apprentice
Posts: 19
Joined: Sun Jun 27, 2010 10:42 am

Re: expand COM_CONTENT_SAVE_SUCCESS="Article saved."

Post by hgh-esn » Sat Nov 09, 2024 9:03 pm

SharkyKZ wrote: Tue Sep 24, 2024 8:28 am ....

foreach ($messages as $k => $message)
{
// Match and replace the message in question.
if ($message['message'] === $app->getLanguage()->_('COM_CONTENT_SAVE_SUCCESS'))
{
$message['message'] = $app->getLanguage()->_(sprintf('PLG_SYSTEM_EXAMPLE_SAVE_SUCCESS', $timestamp));
}

// Repopulate the message queue.
$app->enqueueMessage($message['message'], $message['type']);
}[/code]...
Hello SharkyKZ,

I want to inform you, that I now have a little Plugin running, that does the job.

I thank You for the code, because it is a central part of my plugin.
The output is now like this:Image

Advertisement

Post Reply

Return to “Joomla! 4.x Coding”