• Welcome to the Chevereto user community!

    Here users from all over the world gather around to learn the latest about Chevereto and contribute with ideas to improve the software.

    Please keep in mind:

    • ๐Ÿ˜Œ This community is user driven. Be polite with other users.
    • ๐Ÿ‘‰ Is required to purchase a Chevereto license to participate in this community (doesn't apply to Pre-sales).
    • ๐Ÿ’ธ Purchase a Pro Subscription to get access to active software support and faster ticket response times.
  • Chevereto Support CLST

    Support response

    Support checklist

    • โš ๏ธ Got a Something went wrong message? Read this guide and provide the actual error. Do not skip this.
    • โœ… Confirm that the server meets the System Requirements
    • ๐Ÿ”ฅ Check for any available Hotfix - your issue could be already reported/fixed
    • ๐Ÿ“š Read documentation - It will be required to Debug and understand Errors for a faster support response

I need help with adding alert/notice box to the site

JakeSully

๐Ÿ‘ฝ Chevereto Freak
Hi,

Does anyone know any good css based alert/notice customization?

I would like to add bar or box or something in the top that tells user a important message when they view the site.

So I can add up coming maintenance and such.

I hope this is possible to be done easy without much advanced coding.
 
A simple alert box:

Step 1 - Add some custom CSS (dashboard -> settings -> theme) - Just copy & paste everything

Code:
/* The alert message box */
.alert {
    padding: 10px; /* adjust this one to get a thicker box */
    border-radius: 5px; /* remove this line if you want a square box without rounded corners */
    background-color: #f44336; /* Red */
    color: white;
    margin-bottom: 15px;
    margin: auto;
    max-width: 810px; /* adjust this one for box length */
    #margin-top: 50px;  /* uncomment "#" and adjust px for more air*/
}

/* The close button */
.closebtn {
    margin-left: 15px;
    color: white;
    font-weight: bold;
    float: right;
    font-size: 22px;
    line-height: 20px;
    cursor: pointer;
    transition: 0.3s;
}

/* When moving the mouse over the close button */
.closebtn:hover {
    color: black;
}

Step 2. Insertion on page (dashboard -> settings -> banners)

Place this code where you want it to be displayed, typically before or after "call to action"

Code:
<div class="alert">
  <span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span>
  Simple CSS alert Box - > Put your message here.
</div> <div id="powered-by" class="footer">Alertbox by <a href="https://myimg.io" rel="generator">MYIMG</a> image hosting</div>


You could also insert the alertbox directly to the theme index. But if you are not comfortable customizing core files this is the easiest way.
 
Last edited:
Updated the CSS code. I've shortened the box and added a description in the CSS code snippet on how to adjust it.
 
Agree, noticed this alert thingy needs new updates. Since code doesen't show on every browser now for some weird reason :/

@tomsit are you able to do some updates to this? so it will appear again on the site.
 
I found the problem. It shows when i disable AdBlock. Please fix it for showing itself when AdBlock is enabled.
 
Sorry, I have no idea how to "fix" it.
well it worked well when you first gave code to us, but after few chrome updates and so on. It begun to stop showing up on the site, so either it's browser problem or chevereto have had some changes.

So if you do find any solution it would be great to have it, unless some 1 else finds a solution.
 
well it worked well when you first gave code to us, but after few chrome updates and so on. It begun to stop showing up on the site, so either it's browser problem or chevereto have had some changes.

So if you do find any solution it would be great to have it, unless some 1 else finds a solution.
It is still working for me.
 
I have modified the code a little bit to add persistence when close button is clicked.
With little js code, we can keep the alert box hidden once visitor closes it.


Step 1 - Add some custom CSS (dashboard -> settings -> theme) - Just copy & paste everything
[CODE lang="css" title="css" highlight="30-32"]/* The alert message box */
.alert {
padding: 10px; /* adjust this one to get a thicker box */
border-radius: 5px; /* remove this line if you want a square box without rounded corners */
background-color: #f44336; /* Red */
color: white;
margin-bottom: 15px;
margin: auto;
max-width: 820px; /* adjust this one for box length */
#margin-top: 50px; /* uncomment "#" and adjust px for more air*/
}

/* The close button */
.closebtn {
margin-left: 15px;
color: white;
font-weight: bold;
float: right;
font-size: 22px;
line-height: 20px;
cursor: pointer;
transition: 0.3s;
}

/* When moving the mouse over the close button */
.closebtn:hover {
color: black;
}

.hide {
display: none;
}[/CODE]

Step 2 - Add some custom javascript (dashboard -> settings -> theme) - Just copy & paste everything

[CODE lang="javascript" title="js"]document.addEventListener("DOMContentLoaded", function() {
let dismissed = sessionStorage.getItem("dismissed");
let dismissButton = document.getElementById("dismiss");
let alertDiv = document.getElementById("warning");

if(!dismissed){
alertDiv.classList.remove("hide");
}

dismissButton.addEventListener("click", function(){
alertDiv.classList.add("hide");
sessionStorage.setItem("dismissed", true);
});
});[/CODE]

Step 3. Insertion on page (dashboard -> settings -> banners)
[CODE lang="html" title="Alert box html"]<div class="alert hide" id="warning">

<span id="dismiss" class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span>

<span class="fas fa-exclamation-triangle"></span> Your message here.

</div>[/CODE]

Optional: If you just want to show the alert box to logged in users, use the following code, and paste it inside chevereto theme file on your installation, wherever you want to show it.
For example, if you just want to show the alert box on user profiles. Copy /app/themes/Peafowl/views/user.php to app/themes/Peafowl/overrides/views/user.php

Now open app/themes/Peafowl/overrides/views/user.php to edit and search for:
[CODE lang="php" title="banner"]<?php CHV\Render\show_banner('user_before_listing', get_list()->sfw ?? true); ?>[/CODE]

Paste the code below after above line:
[CODE lang="php" title="show alert only to logged in users"]<?php if (CHV\Login::isLoggedUser()) {
?>
<div class="alert hide" id="warning">
<span id="dismiss" class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span>
<span class="fas fa-exclamation-triangle"></span> Your message here.
</div>
<?php
} ?>[/CODE]
 
Last edited:
It is still working for me.
i can confirm it is very glitchy, since banner does not show on all mobile browsers, but then all of sudden it start's showing and another time it disappears again and so on, same on pc's browser too.
 
i can confirm it is very glitchy, since banner does not show on all mobile browsers, but then all of sudden it start's showing and another time it disappears again and so on, same on pc's browser too.
I could not replicate your findings. I checked the banner on phone and desktop. Chrome and Firefox shows the banner just fine.
Maybe it is one of your extension? Try turning off any adblocker you may have.
 
I could not replicate your findings. I checked the banner on phone and desktop. Chrome and Firefox shows the banner just fine.
Maybe it is one of your extension? Try turning off any adblocker you may have.
Nope i can confirm there is something with the coding that isn't working properly. At leas the old one, unless you did some changes to improve it.
 
Nope i can confirm there is something with the coding that isn't working properly. At leas the old one, unless you did some changes to improve it.
On my website both old and new one is working. I tested it on various browsers and it is working fine on safari, chrome, firefox and Microsoft edge. Both Android and Desktop.

359_kLYoOmLsuw.png
 
Last edited:
Back
Top