Jump to content

Set Up Error Messages On Admin Module Tab Navigation On The Fly


PauloV

Recommended Posts

Hello :blesta:

 

On module tab navigation, how to set up error messages on the fly?
 
Exemple:
 
We have the opensrs module, wen there is an error conecting or getting any data, for exemple we want to display the error message and it dosent display wen navigating on the TABS
 
On the outher hand we have sucessful add the error message wen POST the form like so:
 
$errors[] = "my error message";
$this->Input->setErrors(array('errors' => $errors));
 
but dont work wen loading TABS only POST/Modifying the module options
 
Thanks in advance for any help ;)
Link to comment
Share on other sites

The short answer is you can't. Messages are handled at a higher level and there isn't yet a way to set specific messages from the module.

i have already asked about this feature in this threads http://www.blesta.com/forums/index.php?/topic/3879-allow-module-to-set-message-like-seterrors/ and the answer was http://dev.blesta.com/browse/CORE-1269 , now i'm shaked that is not possible ?!!!!

is really good feature .

Link to comment
Share on other sites

I think i have a solution and I will try on Monday :)

We cannot set error messages but we can send error messages as $var to the .tpl file of the plugin/module :)

 

 

in this case you will need to add html code for success and errors messages .

 

and the probleme in this solution is that some module not using the $var anyelese , so it need to be adjusted in the related module .

 

i have another solution that i have used before , but i don't know hwy i have stopped using it .  my solution was based in the same idea of blesta message , i found blesta add a cookies just for the flash messages , so i have write my own function to store the message in the cookies , and when blesta load, it always fetch the cookies for flash messages nad lood it . it worked like a charm , but i have not understand what was the probleme in that time !!! 

Link to comment
Share on other sites

Thanks for the help naja7host :)

 

Because Im only using the warnings for my Modules/Plugins I will use my internal var "ierror" (internal error lol), and I will add the extra lines of code (untill blesta devs include in core the soltuion)

 

The error messages are very handy, because we dont know if there is a problem wen managing a module/plugin only spending some minutes debugging or seeing logs :)

 

Here is the solution for displaying error messages on Modules/Plugins in Tabs navigations (wen not posting/submiting forms), on the fly:
 
On your module/plugin just add the a var to colect the error message wen not post/submit form like this exemple:
 
 $vars->ierror = "my error message"; //colect and send the error message to .pdt
 
on your .pdt file add on top this code:
 
 
    <?php
        if ($this->Html->ifSet($vars->ierror)){
     ?>
    <div class="error_section">
<article class="error_box error">
<a href="#" class="close">×</a>
<p style="padding:0px 0px 0px 30px; vertical-align: middle;"><?php echo $this->Html->ifSet($vars->ierror); ?></p>
   </article>
</div>
    <?php
        }
    ?>
 
Nad its working on all my modules/plugins, displying the error message directly from the API of my Module/Plugin, insted of going in Tools->Logs to see what went rong :blesta:
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...