Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

nuMessage() / PHP Topic is solved

Questions related to using nuBuilder Forte.
Post Reply
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

nuMessage() / PHP

Unread post by toms »

Hi,

I'd like to display a message with PHP. I thought I could call

Code: Select all

nuMessage("Hello"); 
in the AS event, but the passed parameter o is empty. What am I doing wrong?
nuMessage.PNG
You do not have the required permissions to view the files attached to this post.
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: nuMessage() / PHP

Unread post by admin »

toms,

If you want to set a message with Javascript (which takes an Array of Strings) use...

Code: Select all

nuMessage(['Hello World']) - which takes an Array of Strings.
http://wiki.nubuilder.net/nubuilderfort ... #nuMessage


If you want to set a Message with PHP (which takes a String) use...

Code: Select all

nuDisplayError('Hello World'); - which takes a String.
http://wiki.nubuilder.net/nubuilderfort ... splayError

If nuDisplayError() is called in the Before Save or Before Delete, it will stop the record being Saved or Deleted.

Otherwise, it will just return a message...


Steven
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: nuMessage() / PHP

Unread post by toms »

Steven,

Actually I just want to show an info message in PHP, nuDisplayError() is not suitable since it will then not save the record.
I was wondering why I could call the js function nuMessage() from php (but, as already mentioned, no parameter is passed).
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: nuMessage() / PHP

Unread post by admin »

toms,

If nuDisplayError() is used in After Save or After Delete, a message will now appear.

Please see if this now works for you.

(You'll need the latest from Github.)

Steven
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: nuMessage() / PHP

Unread post by toms »

Steven,

It works all fine. I just think that the function's name is a bit misleading since, in this case, it shows only an ordinary message and not an error message.

Just as an idea for the (far) future : A function nuDisplayMessage() could be created with different types of messages.

Something like that:
msg3.png
message_types.jpg
You do not have the required permissions to view the files attached to this post.
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: nuMessage() / PHP

Unread post by admin »

toms,

Hopefully, nuDisplayError() isn't so confusing to the developer if they read the wiki.

http://wiki.nubuilder.net/nubuilderfort ... splayError - I updated it yesterday.

If you mean a message might be misleading to a User, then that could be considered the developer's fault.

But the string passed to nuDisplayError can be HTML.

So you could do something like this...

Code: Select all

nuMessage(["<img id='nulogo' width='40px' src='graphics/numessage.png' style='position:absolute;left:2px;top:2px'>","That is now finished!"])
numessage.png and nuerror.png are available in nuBuilder Forte's graphics directory.

Steven
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: nuMessage() / PHP

Unread post by toms »

admin wrote:opefully, nuDisplayError() isn't so confusing to the developer if they read the wiki.
I mean if nuDisplayError() is not always intended to display an error message, then the name is misleading. But that's a matter of opinion.

While nuMessage() can be used in Javascript,
I just want to show an info message in PHP
Is there an easy way to call nuMessage() from PHP code? I've tried using echo but without success.
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: nuMessage() / PHP

Unread post by admin »

toms,

I don't understand your question.
Is there an easy way to call nuMessage() from PHP code?
nuMessage() is a Javacript function.

Steven
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: nuMessage() / PHP

Unread post by toms »

My question was:
Is there an easy way to call nuMessage() from PHP code? I've tried using echo but without success.
A possible solution to use nuMessage() in PHP:

Code: Select all

$j = "nuMessage([\"<img id=\'nulogo\' width=\'40px\' src=\'graphics\/numessage.png\' style=\'position:absolute;left:2px;top:2px\'>\",\"That is now finished!\"])";

nuAddJavascript($j);

EDIT: The message is not showing up in AS (PHP) :x
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: nuMessage() / PHP

Unread post by admin »

toms,

nuAddJavascript() adds Javascript to a Browse Form or an Edit Form as it loads the Form.

It will only work with Before Save and Before Edit.

http://wiki.nubuilder.net/nubuilderfort ... Javascript

Steven
Post Reply