» » » Последние альбомы музыки на главной

Последние альбомы музыки на главной

1. Шагаем в Админку -> CMS -> Block -> Add New Block ( новый блог )

2. Вписываем далее:

*Product: phpfox
*Module: group
*Title: Featured Music Albums
*Type: PHP Code
*Controller: core.index-member
*Placement: Block 3.
*Active: Yes
*PHP/HTML Code (Optional):

<?php 

$sSelect = 'ma.*, mat.text_parsed,' . Phpfox::getUserField();
$sJoinCondAlbum = 'ma.album_id = mat.album_id';
$sJoinCondUser = 'ma.user_id = u.user_id';
$sCond = 'ma.view_id = 0 AND ma.is_featured = 1';
$sOrder = 'RAND()';
$db = Phpfox::getLib('database');

$aRows = $db->select($sSelect)
                        ->from(Phpfox::getT('music_album'), 'ma')
                        ->join(Phpfox::getT('music_album_text'), 'mat', $sJoinCondAlbum)
                        ->join(Phpfox::getT('user'), 'u', $sJoinCondUser)
                        ->where($sCond)
                        ->limit('3') // Limit to only 3 albums
                        ->order($sOrder)
                        ->execute('getSlaveRows');

foreach ($aRows as $iKey => $aRow)
{
        $aRows[$iKey]['album_url'] = Phpfox::getLib('url')->makeUrl($aRow['user_name'], array('music', $aRow['name_url']));
        $aRows[$iKey]['creator_url'] = Phpfox::getLib('url')->makeUrl('profile', array($aRow['user_name']));
        $aRows[$iKey]['image_path_parsed'] = Phpfox::getLib('phpfox.image.helper')->display(
                array(
                        'title' => $aRow['name'],
                        'path' => 'music.url_image',
                        'file' => $aRow['image_path'],
                        'suffix' => '_120',
                        'max_width' => '120',
                        'max_height' => '120',
                )
        );
}

$sAddAlbum = Phpfox::getLib('url')->makeUrl('music', array('album'));
$sViewAll = Phpfox::getLib('url')->makeUrl('music', array('browse', 'album'));
?>

<div class="block js_sortable" id="js_block_border_featured_music_album">
        <div class="title js_sortable_header" style="cursor: move; ">
                <?php echo Phpfox::getPhrase('music.featured'); ?>
        </div>
        <div class="content" id="js_block_content_featured_music_album">
                <?php
                if (!count($aRows))
                {
                        ?>
                        <div class="extra_info">
                                <?php echo Phpfox::getPhrase('music.there_are_no_featured_albums'); ?>
                                <ul class="action">
                                        <li><a href="<?php echo $sAddAlbum; ?>"><?php echo Phpfox::getPhrase('music.add_album'); ?></a></li>
                                </ul>
                        </div>
                        <?php
                }
                else
                {
                        $i = 1;
                        foreach($aRows as $aAlbum)
                        {
                        ?>
                                <div class="<?php if (is_int($i/2)) { ?> row1 <?php } else { ?> row2 <?php } if ($i == 1) { ?> row_first <?php } ?>">
                                        <div style="width:55px; position:absolute; text-align:center; left:20px;">
                                                <a href="<?php echo $aAlbum['album_url']; ?>" title="<?php echo $aAlbum['name']; ?>">
                                                        <?php echo $aAlbum['image_path_parsed']; ?>
                                                </a>
                                        </div>
                                        <div style="margin-left:130px; min-height:55px; height:auto !important; height:55px;">
                                                <a href="<?php echo $aAlbum['album_url']; ?>" title="<?php echo $aAlbum['name']; ?>">
                                                        <?php echo $aAlbum['name']; ?>
                                                </a>
                                                                                                <?php echo Phpfox::getPhrase('music.by'); ?>
                                                <a href="<?php echo $aAlbum['creator_url']; ?>" title="<?php echo $aAlbum['user_name']; ?>">
                                                        <?php echo $aAlbum['full_name']; ?>
                                                </a>
                                                <div class="extra_info">
                                                        <?php echo Phpfox::getLib('parse.output')->shorten($aAlbum['text_parsed'], 200); ?>
                                                </div>
                                                                                                <div class="extra_info">
                                                                                                        <?php
                                                                                                                echo Phpfox::getPhrase('music.total_play_plays',
                                                                                                                                array(
                                                                                                                                        'total_play' => $aAlbum['total_play'],
                                                                                                                                )
                                                                                                                );
                                                                                                        ?>
                                                                                                        <?php echo Phpfox::getPhrase('music.released'),': ',$aAlbum['year']; ?>
                                                                                                        <?php
                                                                                                                echo Phpfox::getPhrase('music.total_track_tracks',
                                                                                                                                array(
                                                                                                                                        'total_track' => $aAlbum['total_track'],
                                                                                                                                )
                                                                                                                );
                                                                                                        ?>
                                                                                                </div>
                                        </div>
                                </div>
                        <?php
                        $i++;
                        }
                }
                ?>
                <div class="clear"></div>
        </div>
        <div class="bottom">
                <ul>
                        <li id="js_block_bottom_1" class="first">
                                <a href="<?php echo $sViewAll; ?>" id="js_block_bottom_link_1">
                                        <?php echo Phpfox::getPhrase('music.view_more'); ?>
                                </a>
                        </li>
                </ul>
        </div>
</div>

Поделиться

Другие публикации по теме:

Комментарии