Drupal: .htaccess Access Deny
August 21, 2014 – 7:59 am | No Comment

In this article I will tell how to forbid access to certain resources for some clients. The instructions will include descriptions of different directives.

Read the full story »
CSS Templates

Contain reviews and news about CSS Templates.

Freebies

Contain freebies such as icons, graphics, headers and images for your websites.

Fun Stuff

Contains other fun stuff for entertainment or interesting site showcase.

How-To

Contain technical elaborations on some specific workarounds or common tweak.

Joomla Templates

Contains reviews and news about Joomla templates.

Home » How-To

How to Display Custom Error Messages

Submitted by on December 1, 2009 – 9:19 amNo Comment

Having a Joomla-based web-site, you may need to display a custom error (warning, notice) message. It is very simple and I will tell how you can make so.

In this short tutorial we will deal with the following messages that can be customized:

  • Notice message;
  • Warning message;
  • Error message.

The first thing to know is that all messages are customized by the same method. It would pass number of an error and message for error (warning, notice).

Here is the example:

JError::raiseNotice( 500, Attention! You didn’t register in the system. You will be able to save your order after <a href="index.php?option=com_user&view=register"> registration </a> !’ );

The example creates the following custom notice message for error ‘500’: Attention! You didn’t register in the system. You will be able to save your order after registration.

In fact, you may use this pattern for all custom messages on your site. The only difference for messages is that you should use different classes for notices, warnings and errors. These classes are:

  • JError::raiseNotice
  • JError::raiseWarning
  • JError:raiseError

So, custom warning message will look like:

JError:: raiseWarning( 500, Attention! You didn’t register in the system. You will be able to save your order after <a href="index.php?option=com_user&view=register"> registration </a> !’ );

and custom error message will look like:

JError:: raiseError( 500, Attention! You didn’t register in the system. You will be able to save your order after <a href="index.php?option=com_user&view=register"> registration </a> !’ );

Put this code into the required place and enjoy your result!

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.