Hi!
With this modification, it is possible to display a message in a category.
By clicking on the "Close" button a Chookie is saved and the message no longer appears, even with repeated visit the category.
When a new text written the message window is visible again.
The message box text and buttons are configurable via CSS.
DemoRequired: [Mod]Additional Category fields 1.) Creating a new table field in the database "cat_message":
ALTER TABLE 4images_categories ADD cat_message TEXT NOT NULL
Alternatively, copy the file "install_cat_message.php" from the Attachment in your root, login as Admin and call it to.
2.) Copy the file "no.png" from the Attachment in templates/your template/images
3.) search in lang/your Lang/main.php and insert above "?>" :
(Deutsch)
$lang['cat_message']="Nachricht :";
(English)
$lang['cat_message']="Message :";
4.) search in includes/db_field_definitions.php "?>" and insert above "?>" :
$additional_category_fields['cat_message'] = array($lang['cat_message'], "textarea", 0);
5.) search in categories.php:
//-----------------------------------------------------
//--- Clickstream -------------------------------------
insert above:
if($cat_cache[$cat_id]['cat_message']){
$user_token = "";
$cookie_token ="4images_catmessage_".$cat_id;
$cookie_token = $_COOKIE[$cookie_token];
$message_token = sha1(substr($cat_cache[$cat_id]['cat_message'], 0, 5));
$user_token = ($message_token != $cookie_token) ? 1:0;
$site_template->register_vars(array(
"user_token" => $user_token,
"message_token" => $message_token
));
}
6.) insert in templates/your templates/categroies.html where ever you want:
{if cat_message}
<script type="text/javascript">
function hiddeMsgs(){
document.getElementById('message_box').style.display = 'none';
}
function createCookie(name, value, days) {
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
}
else var expires = "";
document.cookie = name + "=" + value + expires + "; path=/";
hiddeMsgs();
}
</script>
{if user_token}
<div id="message_box" class="message_box">
<p class="message_button">
<a href="Javascript:createCookie('4images_catmessage_{cat_id}','{message_token}',30);" alt="delete"><img style="border:none;"src="{template_url}/images/no.png"></a>
</p>
<p class="message_text">{cat_message}</p>
</div>
{endif user_token}
{endif cat_message}
7.) insert in templates/your templates/style.css :
.message_box{
border:3px solid #000000;
padding:3px;
position:absolute;
width:750px;
background-color:#ddddee;
margin:0px auto;
}
.message_text{
font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif;
font-size: 14px;
font-weight:bold;
color: #000000;
margin:0px 20px 20px 20px;
padding:0;
overflow:visible;
}
.message_button{
text-align:right;
margin:0;
padding:0;
}
mfg Andi