_nearestEvents.php 1.94 KB
<?php
/**
 * @var $this SportController
 */
Yii::import('application.controllers.*');
?>
<h2><?php echo Yii::t('site', 'Календарь ближайших событий');?></h2>
<div class="nearest-events">
    <ul class="simple-link-menu">
        <li class="active"><a href="#all"><?php echo Yii::t('site', 'Все');?></a></li>
        <li><a href="#2"><?php echo Yii::t('site', 'Украина');?></a></li>
        <li><a href="#3"><?php echo Yii::t('site', 'Россия');?></a></li>
        <li><a href="#1"><?php echo Yii::t('site', 'Мир');?></a></li>
    </ul>
    <div class="calander-small-list">
        <?php foreach (SportController::getNearestEvents() as $event): ?>
        <div class="calander-small-item">
            <p class="date"><?php echo  Yii::app()->getDateFormatter()->format('d MMMM yyyy', CDateTimeParser::parse($event->start_date, 'yyyy-MM-dd')) . ' - '
                . Yii::app()->getDateFormatter()->format('d MMMM yyyy', CDateTimeParser::parse($event->end_date, 'yyyy-MM-dd'))?></p>

            <p><?php echo $event->i18n->description?></p>
        </div>
        <?php endforeach;?>
    </div>
</div>
<span class="read-more"><?php echo CHtml::link(Yii::t('site','Полный календарь событий'),array('calendarSection/calendar', 'node_id'=>Node::model()->find('data_type= \'calendarSection\'')->id));?> »</span>
<?php
$cs = Yii::app()->getClientScript();
$cs->registerCoreScript('jquery');
$url= CJavaScript::encode($this->createUrl('site/nearestNews'));
$src = <<<JS
    $('.nearest-events').each(function(){
    var block = $(this);
    var content = $('.calander-small-list', block);
    $('.simple-link-menu a').click(function(e){
        e.preventDefault();
        $('.simple-link-menu li').removeClass('active');
        var id = $(this).attr('href').substr(1);
        $(this).parent().addClass('active');
        content.load({$url}+'?country='+id);
    })
    })
JS;
$cs->registerScript('nearestEvents', $src);
?>