Jump to content

Recommended Posts

Posted

I've been building message and error system.

And I've noticed that PW uses Jquery highlight message system, which is very easy to use.

Some of PW module do this like,

$this->message('message here');
$this->error('error message here');

And it seems like automatically generate markup for the Jquery to handle.(If I understand correctly)

So, are message and error methods only for use inside of class?

If I'm not getting it, please let me know.

Thank you.

Posted

massage and error for admin no ? use them like this u can two

$pages->error('bad man');

$session->message('hi');

wire('pages')->error('bad bad.man');

wire('session')->message('hiho');

work.for any api vrable it does 

  • Like 4
Posted

I've found out that I actually have to put this code below.

<?php if(count($notices)) include($config->paths->adminTemplates . "notices.inc"); ?>

This code is from default.php from admin files.

Posted

LeiHa,

You need to tell us more what you want to achieve.

In your modules, you can generate messages / error-messages like WillyC mentioned. Pw will output them automatically in the admin.

However, if you speak from your own templates aka frontend, I'm not sure what you want to do :)

Posted

I don' think it's a good idea to make your site depend of something like this. If something changes with an upgraade, it will break everything.

  • Like 1
Posted

Sorry about the confusion.

I'm still trying to understand how to implement this in the frontend site.

The message system in admin backend site seems wonderful and I'd like to use it in the frontend.

At first, I thought that I could just use $this->error('some text'); or $this->message('some text'); in the frontend.

Eventually those didn't work of course. And tried to find out how to use this system(I assume Ryan made this. So impressive!!!)

Posted

The system is using jquery ui. You can use the theme roller to create your own theme, and then apply it to the messages on your site, just like Ryan did with the admin.

Posted

Thanks all of you.

I'm starting to understand a bit.

I'll look up Jquery UI roller site and see how things work.

Thank you.

Posted

The notices system actually doesn't have anything to do with jQuery UI other than that the default admin theme makes use of jQuery UI class names when generating the markup for notices. But for your own front-end, you can make use of the $notices API variable to output them however you want. It can be as simple as this:

echo "<ul>";
foreach($notices as $notice) {
  $class = $notice->className();
  $text = $sanitizer->entities($notice->text); 
  echo "<li class='$class'>$text</li>";
}
echo "</ul>";

Then you would want to style the two type of notices in your CSS:

.NoticeMessage { color: green; }
.NoticeError { color: red; }
  • Like 9

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...