[Solved] About Displaying Error Message

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
Dakin Quelia
Registered User
Posts: 303
Joined: Thu Feb 14, 2008 10:07 pm
Location: Belgium
Name: Daniel Chalsèche
Contact:

[Solved] About Displaying Error Message

Post by Dakin Quelia »

Hello,

I'd like displaying Error Message when an url doesn't match page or the page doesn't exist.

How do that?

Thanks per advance. :)

Best regards
Last edited by Dakin Quelia on Sun Aug 26, 2018 6:31 am, edited 1 time in total.
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: [Question] About Displaying Error Message

Post by david63 »

Withou more information of what you are doing and where you are doing it it is impossible to answer your question.
David
Remember: You only know what you know and - you don't know what you don't know!

I now no longer support any of my extensions but they will start to become available here
User avatar
Dakin Quelia
Registered User
Posts: 303
Joined: Thu Feb 14, 2008 10:07 pm
Location: Belgium
Name: Daniel Chalsèche
Contact:

Re: [Question] About Displaying Error Message

Post by Dakin Quelia »

By example, my route to my page : www.monsite.com/test exists and display the content.

If the page doesn't exist (with or without /) it displays a error message in my template file.
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: [Question] About Displaying Error Message

Post by 3Di »

If you are using a controller for that route you have to use exceptions.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
Ger
Registered User
Posts: 2108
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: [Question] About Displaying Error Message

Post by Ger »

Do you mean something like this? https://github.com/GerB/cmbb/blob/maste ... #L107-L110
If an article does not exist, the controller helper throws a 404 not found error.
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

Like my work? Buy me a coffee to keep it coming. :ugeek:

-Don't PM me for support-
User avatar
Dakin Quelia
Registered User
Posts: 303
Joined: Thu Feb 14, 2008 10:07 pm
Location: Belgium
Name: Daniel Chalsèche
Contact:

Re: [Question] About Displaying Error Message

Post by Dakin Quelia »

Like this !

An error in template file. :)
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: [Question] About Displaying Error Message

Post by 3Di »

Code: Select all

{% if S_ERRORS %}
<fieldset>
	<legend>{{ lang('MY_AWESOME_EXT_ERRORS') }}</legend>
	<p class="error">
		{{ ERRORS_MSG }}
	</p>
</fieldset>
{% endif %}
and define an array of errors in the PHP side of things.

Code: Select all

$errors = array();

Code: Select all

				if (empty($blah))
				{
					$errors[] = $language->lang('BLAH_IS_EMPTY');
				}

Code: Select all

			$template->assign_vars(array(
				'S_ERRORS'						=> ($errors) ? true : false,
				'ERRORS_MSG'					=> implode('<br /><br />', $errors),
				// etc..
typed on the fly.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
Dakin Quelia
Registered User
Posts: 303
Joined: Thu Feb 14, 2008 10:07 pm
Location: Belgium
Name: Daniel Chalsèche
Contact:

Re: [Question] About Displaying Error Message

Post by Dakin Quelia »

Thank you, very much. :)
Post Reply

Return to “Extension Writers Discussion”