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.

Moderators: ooffick, dam-man

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

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

Postby 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
Admin-Help-Pages, Dynamic-Menu-Links, Admin-Menu-Manager, Access-Manager, Redirect-on-Login, Pages-and-Items, module Admin-Messages, module Logged-in-Users, plugin load module in article, plugin pure css tooltip and more...

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

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

Postby 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: 1188
Joined: Sat Feb 11, 2006 8:32 am
Location: Tilburg, Holland
Contact:

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

Postby 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
Admin-Help-Pages, Dynamic-Menu-Links, Admin-Menu-Manager, Access-Manager, Redirect-on-Login, Pages-and-Items, module Admin-Messages, module Logged-in-Users, plugin load module in article, plugin pure css tooltip and more...

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

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

Postby 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: 1188
Joined: Sat Feb 11, 2006 8:32 am
Location: Tilburg, Holland
Contact:

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

Postby 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
Admin-Help-Pages, Dynamic-Menu-Links, Admin-Menu-Manager, Access-Manager, Redirect-on-Login, Pages-and-Items, module Admin-Messages, module Logged-in-Users, plugin load module in article, plugin pure css tooltip and more...

User avatar
carsten888
Joomla! Ace
Joomla! Ace
Posts: 1188
Joined: Sat Feb 11, 2006 8:32 am
Location: Tilburg, Holland
Contact:

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

Postby 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
Admin-Help-Pages, Dynamic-Menu-Links, Admin-Menu-Manager, Access-Manager, Redirect-on-Login, Pages-and-Items, module Admin-Messages, module Logged-in-Users, plugin load module in article, plugin pure css tooltip and more...

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

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

Postby 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" />


Return to “Joomla! 2.5 Coding”

Who is online

Users browsing this forum: No registered users and 6 guests