Page 1 of 1

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

Posted: Wed Jan 05, 2011 6:01 pm
by carsten888
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?

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

Posted: Thu Jan 06, 2011 8:00 am
by Bakual
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?

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

Posted: Thu Jan 06, 2011 8:11 am
by carsten888
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.

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

Posted: Thu Jan 06, 2011 9:15 am
by Bakual
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.

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

Posted: Thu Jan 06, 2011 12:50 pm
by carsten888
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).

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

Posted: Fri Jan 07, 2011 1:38 pm
by carsten888
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.

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

Posted: Wed Jun 15, 2011 6:04 pm
by C0nw0nk
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" />