Author Topic: [Mod] Category Message Box  (Read 9115 times)

0 Members and 1 Guest are viewing this topic.

Rembrandt

  • Guest
[Mod] Category Message Box
« on: September 21, 2013, 06:41:19 AM »
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.

Demo

Required: [Mod]Additional Category fields

1.) Creating a new table field in the database "cat_message":
Code: [Select]
ALTER TABLE 4images_categories ADD cat_message TEXT NOT NULLAlternatively, 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'], 05));
  
$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(namevaluedays) {
    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">
  <
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>
  <
class="message_text">{cat_message}</p>
</
div>
{endif 
user_token}
{endif 
cat_message}


7.) insert in templates/your templates/style.css :
Code: [Select]
.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

Offline Jan-Lukas

  • Addicted member
  • ******
  • Posts: 1.297
    • View Profile
    • Discover the New World of Kindersurprise
Re: [Mod] Category Message Box
« Reply #1 on: October 09, 2013, 08:21:54 PM »
Perfekt  :lol:

Danke
Danke Harald




Rembrandt

  • Guest
Re: [Mod] Category Message Box
« Reply #2 on: October 09, 2013, 09:28:22 PM »
Fein,... noch etwas zur Gültigkeitsdauer der COOKIES, in diesen Mod habe ich die Dauer auf 30 Tage gestellt ('{message_token}',30)).
Das bedeutet wenn der User nach dreißig Tagen die Seite wieder besucht erscheint wiederum das Nachrichtenfenster.
Wenn du die Zeit verlängern oder verkürzen möchtest dann kannst du das im link, Step 6.) im Mod, ändern:
Code: [Select]
<a  href="Javascript:createCookie('4images_catmessage_{cat_id}','{message_token}',30);" alt="delete"><img style="border:none;"src="{template_url}/images/no.png"></a>

mfg Andi