I have not been able to find a solution that was simple to be able to
change the color of the flash box so I came up with this one.

It is a very simple but very effective solution for me and can be used
without having to recode any flash messages that are considered as
"green".  You know, the ones that have the check mark and the message
that the operation worked fine.

Start off with modify style.css and changing the #status_block to:

#status_block {
  margin: 0 auto 0.5em auto;
  padding: 15px 10px 15px 55px;
  background: #cec URL('../images/ok.png') left center no-repeat;
  border: 1px solid #9c9;
  width: 450px;
  font-size: 120%;
  font-weight: bolder;
}


.error {
margin: 0.5em auto 0.5em auto;
padding: 15px 10px 15px 55px;
width: 450px;
background: #C00 URL('../images/error.png') left center no-repeat;
border: 1px solid #600;
font-size: 120%;
font-weight: bolder;
color: #fff;
}


.warning {
margin: 0.5em auto 0.5em auto;
padding: 15px 10px 15px 55px;
width: 450px;
background: #fe4 URL('../images/warning.png') left center no-repeat;
border: 1px solid #cb3;
font-size: 120%;
font-weight: bolder;
}

.notice {
margin: 0.5em auto 0.5em auto;
padding: 15px 10px 15px 55px;
width: 450px;
background: #eef URL('../images/info.png') left center no-repeat;
border: 1px solid #cce;
}

Be sure you have png files for the graphics you want to use.


You can add any others you want or completely rewrite what I have.


Then you change the code where the flash is being display.  I am still
using the master.kid that was created by CRUD.

      <div id="main_content">
        <span py:if="not tg_flash.startswith('%%')">
          <div id="status_block" py:if="tg_flash" class="flash"
py:content="tg_flash"></div>
        </span>
        <span py:if="tg_flash.startswith('%%')">
          <span py:if="tg_flash.startswith('%%warning%%')">
            <div id="warning" py:if="tg_flash" class="warning"
py:content="tg_flash.split('%%')[2]"></div>
          </span>
          <span py:if="tg_flash.startswith('%%error%%')">
            <div id="error" py:if="tg_flash" class="error"
py:content="tg_flash.split('%%')[2]"></div>
          </span>
          <span py:if="tg_flash.startswith('%%ok%%')">
            <div id="flash" py:if="tg_flash" class="flash"
py:content="tg_flash.split('%%')[2]"></div>
          </span>
        </span>
        <div py:replace="[item.text]+item[:]"/>
      </div>


Last you recode the flash statements in your controller by adding %
%warning%%, %%error%%, or %%ok%%.  If you don't use any of these then
the default green box will be used.

Some examples of what I use are:

          flash("%%error%%Unable to destroy.  Child records still
exist.")
          flash("Division was successfully destroyed.")
          flash("%%ok%%Division was successfully created.")
          flash("%%warning%%Serial Number already exists.")

You can extend this anyway you want.

Hope this helps anyone out there who is as frustrated with flash as I
was.

Mel


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to