Этот мод автоматически обновляет ленту активности через заданный промежуток времени.
Создайте новый файл auto-refresh.tpl
Вставьте в него код:
PHP:
{include file='header_global.tpl'}
{* SHOW ACTIONS AUTO REFRESH IN HOME BY AFLATON *}
{section name=actions_loop loop=$actions max=10}
<div id='action_{$actions[actions_loop].action_id}' class='portal_action{if $smarty.section.actions_loop.first}_top{/if}'>
<table cellpadding='0' cellspacing='0'>
<tr>
<td valign='top'><img src='./images/icons/{$actions[actions_loop].action_icon}' border='0' class='icon' alt='' /></td>
<td valign='top' width='100%'>
{assign var='action_date' value=$datetime->time_since($actions[actions_loop].action_date)}
<div class='portal_action_date'>{lang_sprintf id=$action_date[0] 1=$action_date[1]}</div>
{assign var='action_media' value=''}
{if $actions[actions_loop].action_media !== FALSE}{capture assign='action_media'}{section name=action_media_loop loop=$actions[actions_loop].action_media}<a href='{$actions[actions_loop].action_media[action_media_loop].actionmedia_link}'><img src='{$actions[actions_loop].action_media[action_media_loop].actionmedia_path}' border='0' width='{$actions[actions_loop].action_media[action_media_loop].actionmedia_width}' class='recentaction_media' alt='' /></a>{/section}{/capture}{/if}
{lang_sprintf assign=action_text id=$actions[actions_loop].action_text args=$actions[actions_loop].action_vars}
{$action_text|replace:"[media]":$action_media|choptext:50:"
"}
</td>
</tr>
</table>
</div>
{/section}
Создайте новый файл auto-refresh.php
Вставьте в него код:
PHP:
<?php
/* $Id: auto-refresh.php By:aFlaTon $ */
$page = "auto-refresh";
include "header.php";
// Get actions feed - Has code in it that is preventing direct caching
$actions_array = $actions->actions_display(0, $setting['setting_actions_actionsperuser']);
$smarty->assign_by_ref('actions', $actions_array);
include "footer.php";
?>
Загрузите на сервер в соответствующие папки.
Откройте home.tpl
Найдите:
PHP:
{* SHOW ACTIONS *}
{section name=actions_loop loop=$actions max=10}
<div id='action_{$actions[actions_loop].action_id}' class='portal_action{if $smarty.section.actions_loop.first}_top{/if}'>
<table cellpadding='0' cellspacing='0'>
<tr>
<td valign='top'><img src='./images/icons/{$actions[actions_loop].action_icon}' border='0' class='icon' alt='' /></td>
<td valign='top' width='100%'>
{assign var='action_date' value=$datetime->time_since($actions[actions_loop].action_date)}
<div class='portal_action_date'>{lang_sprintf id=$action_date[0] 1=$action_date[1]}</div>
{assign var='action_media' value=''}
{if $actions[actions_loop].action_media !== FALSE}{capture assign='action_media'}{section name=action_media_loop loop=$actions[actions_loop].action_media}<a href='{$actions[actions_loop].action_media[action_media_loop].actionmedia_link}'><img src='{$actions[actions_loop].action_media[action_media_loop].actionmedia_path}' border='0' width='{$actions[actions_loop].action_media[action_media_loop].actionmedia_width}' class='recentaction_media' alt='' /></a>{/section}{/capture}{/if}
{lang_sprintf assign=action_text id=$actions[actions_loop].action_text args=$actions[actions_loop].action_vars}
{$action_text|replace:"[media]":$action_media|choptext:50:"
"}
</td>
</tr>
</table>
</div>
{/section}
Замените на:
PHP:
{literal}
<script type="text/javascript">
function Ajax(){
var xmlHttp;
try{
xmlHttp=new XMLHttpRequest();// Firefox, Opera 8.0+, Safari
}catch (e){
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
}catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}catch (e){
alert("Ваш браузер не поддерживает эту веб-страницу...");
return false;
}
}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState == 4)
{
document.getElementById('auto').innerHTML=xmlHttp.responseText;
}
}
xmlHttp.open("GET","auto-refresh.php",true);
xmlHttp.send(null);
}
window.onload=function(){
setInterval('Ajax()', 2000);
}
</script>
{/literal}
<div id="auto"></div>