Lasted Visited Galleries By Country

ulan
Posts: 1437
Joined: Fri Nov 23, 2018 2:49 pm

Re: Lasted Visited Galleries By Country

Post by ulan »

Array ( [19443] => 19443 [12853] => 12853 [20659] => 20659 )
ulan
Posts: 1437
Joined: Fri Nov 23, 2018 2:49 pm

Re: Lasted Visited Galleries By Country

Post by ulan »

но только на странице с галерей, на индексе и других страницах пустота
admin
Site Admin
Posts: 38004
Joined: Wed Sep 10, 2008 11:43 am

Re: Lasted Visited Galleries By Country

Post by admin »

$cache_id = 'last_items_' . $_SERVER['GEOIP_COUNTRY_CODE'];

$last_items = Cache::get('last_items');

может потому что разные ИД кеша берутся?
Don't forget to run script update
ulan
Posts: 1437
Joined: Fri Nov 23, 2018 2:49 pm

Re: Lasted Visited Galleries By Country

Post by ulan »

хз, все делал по вики
admin
Site Admin
Posts: 38004
Joined: Wed Sep 10, 2008 11:43 am

Re: Lasted Visited Galleries By Country

Post by admin »

вопрос в том что там 2 варианта

один общий и там $last_items = Cache::get('last_items');

другой по странам и там $cache_id = 'last_items_' . $_SERVER['GEOIP_COUNTRY_CODE'];

поэтому не ясно как конкретно у вас сделано
Don't forget to run script update
ulan
Posts: 1437
Joined: Fri Nov 23, 2018 2:49 pm

Re: Lasted Visited Galleries By Country

Post by ulan »

может сами глянете, быстро и понято будет
admin
Site Admin
Posts: 38004
Joined: Wed Sep 10, 2008 11:43 am

Re: Lasted Visited Galleries By Country

Post by admin »

напишите плз какой код в каком темпелйте вы добавили
Don't forget to run script update
ulan
Posts: 1437
Joined: Fri Nov 23, 2018 2:49 pm

Re: Lasted Visited Galleries By Country

Post by ulan »

так вывожу

Code: Select all

<script>

    function updateLastVisited() {
        $.ajax({
            url: "/page/lasted_visited/", cache: false, success: function (html) {
                $("#lasted_visited").html(html);
            }
        });
    }

    function updateCountryViewed() {
        $.ajax({
            url: "/scj/tube/index.php?force_template=viewed_in_country&last_viewed_cache_id=last_items_<?=$_SERVER['GEOIP_COUNTRY_CODE']?>",
            cache: false,
            success: function (html) {
                $("#viewed_in_country").html(html);
            }
        });
    }

    $(document).ready(function () {
        updateLastVisited();
        setInterval(updateLastVisited, 10 * 60 * 1000);
        updateCountryViewed();
        setInterval(updateCountryViewed, 10 * 60 * 1000);
    });

</script>
такой темплейт

Code: Select all

<thumb num=1-40 limit_by_gallery_id=true gallery_id=CACHE_GET_last_viewed_cache_id> 
<li class="swiper-slide">
    <article>
        <a class="ths-preview-link" href="/video/<!--GALLERY_ID-->/<!--SAFE_ALT-->/" target="_blank">
            <figure>
                <img src="<!--THUMB_URL-->" class="lazy" width="320" height="180">
            </figure>
        </a>
        <h3><a href="/video/<!--GALLERY_ID-->/<!--SAFE_ALT-->/"><!--ALT--></a></h3>
        <footer>
            <span class="likes"><?=min(round(100*"<!--RATING_2-->"/("<!--RATING_2-->"+"<!--RATING_1-->"+0.001)), 100)?>%</span>
            <span class="views"><?=number_format("<!--SHOWS-->", 0, '', ' ');?></span>
            <span class="durat"><!--DURATION--></span>
        </footer>
    </article>
</li>
</thumb>
admin
Site Admin
Posts: 38004
Joined: Wed Sep 10, 2008 11:43 am

Re: Lasted Visited Galleries By Country

Post by admin »

а добавляется в кеш как?
Don't forget to run script update
ulan
Posts: 1437
Joined: Fri Nov 23, 2018 2:49 pm

Re: Lasted Visited Galleries By Country

Post by ulan »

admin wrote: Wed Jan 04, 2023 10:20 am а добавляется в кеш как?
как в твоей вики
<?
if ((int) '<!--GALLERY_ID-->') {
$cache_id = 'last_items_' . $_SERVER['GEOIP_COUNTRY_CODE'];
$last_items = Cache::get($cache_id);
$last_items[(int) '<!--GALLERY_ID-->'] = (int) '<!--GALLERY_ID-->';
$last_items = array_slice($last_items, 0, 100);
Cache::set($cache_id, $last_items, 86400);
}
if ((int) '<!--GALLERY_ID-->') {
$last_items = Cache::get('last_items');
$last_items[(int) '<!--GALLERY_ID-->'] = (int) '<!--GALLERY_ID-->';
$last_items = array_slice($last_items, 0, 100, true);
Cache::set('last_items', $last_items, 3600);
}
?>
Post Reply