how to set a warning message JError::raiseWarning(500, JText

For Joomla! 2.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Note: All 1.6, 1.7 and 3.5 releases have reached end of life and should be updated to 3.x.

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
Locked
User avatar
carsten888
Joomla! Ace
Joomla! Ace
Posts: 1224
Joined: Sat Feb 11, 2006 8:32 am
Contact:

how to set a warning message JError::raiseWarning(500, JText

Post by carsten888 » Wed Jan 05, 2011 6:01 pm

all of these 1.5 methods for setting a message don't seem to work on 1.6:
http://docs.joomla.org/Display_error_me ... nd_notices
http://docs.joomla.org/JError

I want to set a warning message like:

Code: Select all

JError::raiseWarning(500, JText::_('COM_BANNERS_NO_BANNERS_SELECTED'));
how to do this in 1.6?
http://www.pages-and-items.com my extensions:
User-Private-Page, Redirect-on-Login, Admin-Help-Pages, Dynamic-Menu-Links, Admin-Menu-Manager, plugin load module in article, plugin pure css tooltip and more...

User avatar
Bakual
Joomla! Ace
Joomla! Ace
Posts: 1038
Joined: Sun Dec 13, 2009 9:00 pm
Location: Switzerland
Contact:

Re: how to set a warning message JError::raiseWarning(500, J

Post by Bakual » Thu Jan 06, 2011 8:00 am

JError::raiseWarning(500, JText::_('YOUR_STRING'));

still works. I just tested it in my component. It shows me the red message bar as expected.
You're sure your template supports showing the messages?

User avatar
carsten888
Joomla! Ace
Joomla! Ace
Posts: 1224
Joined: Sat Feb 11, 2006 8:32 am
Contact:

Re: how to set a warning message JError::raiseWarning(500, J

Post by carsten888 » Thu Jan 06, 2011 8:11 am

You're sure your template supports showing the messages?
yes, joomla's default ruck milkyway.

I added the above code in the php of the template. no message.

In the backend in some view-template it works fine.
http://www.pages-and-items.com my extensions:
User-Private-Page, Redirect-on-Login, Admin-Help-Pages, Dynamic-Menu-Links, Admin-Menu-Manager, plugin load module in article, plugin pure css tooltip and more...

User avatar
Bakual
Joomla! Ace
Joomla! Ace
Posts: 1038
Joined: Sun Dec 13, 2009 9:00 pm
Location: Switzerland
Contact:

Re: how to set a warning message JError::raiseWarning(500, J

Post by Bakual » Thu Jan 06, 2011 9:15 am

I tested it in the view class (view.html.php) like this:

Code: Select all

<?php
defined('_JEXEC') or die('Restricted access');

jimport( 'joomla.application.component.view');


class MycomponentViewMyview extends JView
{
	function display($tpl = null)
	{
JError::raiseWarning(500, JText::_('YOUR_STRING'));
...
more view specific code
...
}
also using rhuk_milkway for my tests.

User avatar
carsten888
Joomla! Ace
Joomla! Ace
Posts: 1224
Joined: Sat Feb 11, 2006 8:32 am
Contact:

Re: how to set a warning message JError::raiseWarning(500, J

Post by carsten888 » Thu Jan 06, 2011 12:50 pm

I confirm that it works in the view-class and in the views template, but not from within the actual template index.php (ruck milkyway).

I would actually like to use it from the 'onAfterRender' event in a system plugin. Just thinking about this, obviously the content is aalready rendered so the message code can not be added to the output anymore. I will test with different events.
OK! got it working with the 'onAfterInitialise' event. Great! just what I needed.

solved (sort of).
http://www.pages-and-items.com my extensions:
User-Private-Page, Redirect-on-Login, Admin-Help-Pages, Dynamic-Menu-Links, Admin-Menu-Manager, plugin load module in article, plugin pure css tooltip and more...

User avatar
carsten888
Joomla! Ace
Joomla! Ace
Posts: 1224
Joined: Sat Feb 11, 2006 8:32 am
Contact:

Re: how to set a warning message JError::raiseWarning(500, J

Post by carsten888 » Fri Jan 07, 2011 1:38 pm

mwaa!
turns out that it does not work when a user logs out.

in system plugin:

Code: Select all

function onAfterInitialise(){
		JError::raiseNotice('SOME_ERROR_CODE', 'chickensoup');
	}
the above code will display the message on each page, but when a user logs out, the Joomla 404 page is shown with the error (white page with big red block). Not just the page after logging out with the message (as I want it).

Also when logging in, the message is shown twice.

Feels quite buggy this.

I just want to display a message after a user logs out.
http://www.pages-and-items.com my extensions:
User-Private-Page, Redirect-on-Login, Admin-Help-Pages, Dynamic-Menu-Links, Admin-Menu-Manager, plugin load module in article, plugin pure css tooltip and more...

User avatar
C0nw0nk
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 248
Joined: Tue Jun 15, 2010 1:12 am
Location: United Kingdom, London
Contact:

Re: how to set a warning message JError::raiseWarning(500, J

Post by C0nw0nk » Wed Jun 15, 2011 6:04 pm

Thanks i had a problem were my components had errors to display to users for example (Field required)

But i was missing this bit of code from my custom template

Code: Select all

<jdoc:include type="message" />


Locked

Return to “Joomla! 2.5 Coding”