The forum is here for legacy reasons. No new posts will be created. User registration is disabled! If you have any questions, please email us or check https://www.adultscriptpro.com for more details!
You are not logged in.
Hi,
In order to display both recent and featured videos on the frontpage (default free templates) you need to save the below code to modules/frontpage/frontpage.php:
<?php
defined('_VALID') or die('Restricted Access!');
class VModule_frontpage
{
private $db;
private $cache;
private $vcfg;
public function __construct()
{
$this->db = VF::factory('database');
$this->cache = VF::factory('cache');
$this->vcfg = VF::cfg('module.video');
}
public function render()
{
VLanguage::load('frontend.frontpage');
$fcfg = VF::cfg('module.frontpage');
$errors = array();
$messages = array();
if (isset($_SESSION['error'])) {
$errors[] = $_SESSION['error'];
unset($_SESSION['error']);
}
if (isset($_SESSION['message'])) {
$messages[] = $_SESSION['message'];
unset($_SESSION['message']);
}
$tpl = VF::factory('template');
if (!empty($fcfg['watched'])) {
$sql = "SELECT video_id, title, slug, rating, rated_by, duration, thumb, thumbs,
total_views, ext, add_time, premium
FROM #__video
WHERE status = 1
ORDER BY view_time DESC
LIMIT ".$fcfg['watched_per_page'];
if (!$watched = $this->cache->get($sql, 900)) {
$watched = $this->db->get_rows($sql);
if ($this->db->affected_rows()) {
$this->cache->store($sql, $watched, 900);
}
}
$tpl->watched = $watched;
}
$sql_count = "SELECT COUNT(*) AS total_videos
FROM #__video
WHERE status = 1";
$total_videos = $this->db->get_field($sql_count, 'total_videos');
$pagination = VPagination::get(1, $total_videos, $fcfg['videos_per_page']);
$sql = "SELECT v.video_id, v.title, v.slug, v.rating,
v.rated_by, v.duration, v.premium,
v.thumb, v.thumbs, v.total_views,
v.ext, v.add_time, u.username
FROM #__video AS v
LEFT JOIN #__user AS u ON (u.user_id = v.user_id AND u.status = '1')
WHERE v.status = 1
ORDER BY v.add_time DESC";
$sql = $sql. ' LIMIT '.$pagination['limit'];
if (!$videos = $this->cache->get($sql, 3600)) {
$videos = $this->db->get_rows($sql);
if ($this->db->affected_rows()) {
$this->cache->store($sql, $videos, 3600);
}
}
$sql = "SELECT v.video_id, v.title, v.slug, v.rating,
v.rated_by, v.duration, v.premium,
v.thumb, v.thumbs, v.total_views,
v.ext, v.add_time, u.username
FROM #__video_featured AS f
INNER JOIN #__video AS v ON (v.video_id = f.video_id AND v.status = 1)
LEFT JOIN #__user AS u ON (u.user_id = v.user_id AND u.status = '1')
ORDER BY f.feature_time DESC
LIMIT ".$fcfg['videos_per_page'];
$featured = $this->db->get_rows($sql);
$tpl->title = __('recent-title');
$tpl->menu = 'home';
$tpl->errors = $errors;
$tpl->messages = $messages;
$tpl->vcfg = $this->vcfg;
$tpl->sort = 'recent';
$tpl->timeline = '';
$tpl->category = 0;
$tpl->categories = $this->get_video_categories();
$tpl->featured = $featured;
$tpl->videos = $videos;
$tpl->pagination = $pagination;
$tpl->load(array('header', 'frontpage', 'footer'));
$tpl->display();
}
private function get_video_categories()
{
$categories = array();
if (!$categories = $this->cache->get('categories', 86400)) {
$this->db->query("SELECT cat_id, parent_id, name, description, slug, total_videos
FROM #__video_categories
ORDER BY slug, parent_id ASC");
if ($this->db->affected_rows()) {
$categories = $this->db->fetch_rows();
if ($this->vcfg['subcategories'] == '1') {
$categories = VArray::tree($categories);
}
$this->cache->store('categories', $categories, 86400);
}
}
return $categories;
}
}
?>
and below code to templates/your-template/frontpage.tpl.php:
<?php defined('_VALID') or die('Restricted Access!'); ?>
<div id="page">
<?php echo $this->fetch('errors'); ?>
<?php echo $this->fetch('messages'); ?>
<?php echo $this->fetch('warnings'); ?>
<div id="left" class="width-200">
<div class="content-box">
<div class="content-box-title"><?php echo __('CATEGORIES'); ?></div>
<div class="content">
<?php echo p('categories', $this->categories); ?>
</div>
</div>
<?php echo w('link_left'); ?>
<?php echo w('tag_left'); ?>
<?php echo p('adv', 'frontpage-left'); ?>
</div>
<script type="text/javascript">
$(document).ready(function() {
$("#refresh").click(function(e) {
e.preventDefault();
$("#content-watched-videos").load("<?php echo RELATIVE_URL; ?>/ajax.php?s=watched");
});
});
</script>
<div id="right" class="width-760">
<?php echo w('news_header'); ?>
<?php if (isset($this->watched)): ?>
<div class="content-box">
<div class="content-box-title-left"><?php echo __('watched-title'); ?></div>
<a href="<?php echo RELATIVE_URL; ?>/#watched" id="refresh" rel="nofollow" class="content-box-refresh"><?php echo __('refresh'); ?></a>
<div id="content-watched-videos" class="content clear">
<?php if ($this->watched):
echo p('adv_square', 'frontpage-watched');
foreach ($this->watched as $video): ?>
<div id="video-<?php echo $video['video_id']; ?>" class="video">
<a href="<?php echo RELATIVE_URL,'/',$video['video_id'],'/',$video['slug']; ?>/" title="<?php echo e($video['title']); ?>">
<img src="<?php echo THUMB_URL,'/',path($video['video_id']),'/',$video['thumb']; ?>.jpg" alt="<?php echo e($video['title']); ?>" id="preview-video-<?php echo $video['video_id'].'-'.$video['thumb'].'-'.$video['thumbs']; ?>-watched" /><br />
<h5><?php echo e(VText::truncate_chars($video['title'], 50)); ?></h5>
<?php if ($video['ext'] == 'mp4'): ?><img src="<?php echo TPL_REL; ?>/images/hd.png" class="watermark" alt="" /><?php endif; ?>
<?php if ($video['premium'] == '1'): ?><span class="watermark transparent">Premium</span><?php endif; ?>
</a>
<span class="duration"><?php echo VDate::duration($video['duration']); ?></span>
<div class="rating_bar"><div style="width:<?php echo round($video['rating']*20); ?>%"></div></div>
<span class="timeline clear"><?php echo VDate::nice($video['add_time']); ?></span>
<span class="views"><?php echo $video['total_views'],' '; if ($video['total_views'] == '1'): echo __('view'); else: echo __('views'); endif; ?></span>
<div class="clear"></div>
</div>
<?php endforeach; ?>
<div class="clear-left"></div>
<?php else: ?>
<div id="no-watched-videos" class="none"><?php echo __('no-watched'); ?></div>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<?php if (isset($this->featured) && $this->featured): ?>
<div class="content-box">
<div class="content-box-title"><?php echo __('featured-title'); ?></div>
<div class="content">
<?php echo p('adv_square', 'frontpage-recent'); foreach ($this->featured as $video): ?>
<div id="video-<?php echo $video['video_id']; ?>" class="video">
<a href="<?php echo RELATIVE_URL,'/',$video['video_id'],'/',$video['slug']; ?>/" title="<?php echo e($video['title']); ?>">
<img src="<?php echo THUMB_URL,'/',path($video['video_id']),'/',$video['thumb']; ?>.jpg" alt="<?php echo e($video['title']); ?>" id="preview-video-<?php echo $video['video_id'].'-'.$video['thumb'].'-'.$video['thumbs']; ?>" /><br />
<h5><?php echo e(VText::truncate_chars($video['title'], 50)); ?></h5>
<?php if ($video['ext'] == 'mp4'): ?><img src="<?php echo TPL_REL; ?>/images/hd.png" class="watermark" alt="" /><?php endif; ?>
<?php if ($video['premium'] == '1'): ?><span class="watermark transparent">Premium</span><?php endif; ?>
</a>
<span class="duration"><?php echo VDate::duration($video['duration']); ?></span>
<div class="rating_bar"><div style="width:<?php echo round($video['rating']*20); ?>%"></div></div>
<span class="timeline clear"><?php echo VDate::nice($video['add_time']); ?></span>
<span class="views"><?php echo $video['total_views'],' '; if ($video['total_views'] == '1'): echo __('view'); else: echo __('views'); endif; ?></span>
<div class="clear"></div>
</div>
<?php endforeach; ?>
<div class="clear-left"></div>
</div>
</div>
<?php endif; ?>
<div class="content-box">
<div class="content-box-title"><?php echo __('recent-title'); ?></div>
<div class="content">
<?php if ($this->videos):
echo p('adv_square', 'frontpage-recent');
foreach ($this->videos as $video): ?>
<div id="video-<?php echo $video['video_id']; ?>" class="video">
<a href="<?php echo RELATIVE_URL,'/',$video['video_id'],'/',$video['slug']; ?>/" title="<?php echo e($video['title']); ?>">
<img src="<?php echo THUMB_URL,'/',path($video['video_id']),'/',$video['thumb']; ?>.jpg" alt="<?php echo e($video['title']); ?>" id="preview-video-<?php echo $video['video_id'].'-'.$video['thumb'].'-'.$video['thumbs']; ?>" /><br />
<h5><?php echo e(VText::truncate_chars($video['title'], 50)); ?></h5>
<?php if ($video['ext'] == 'mp4'): ?><img src="<?php echo TPL_REL; ?>/images/hd.png" class="watermark" alt="" /><?php endif; ?>
<?php if ($video['premium'] == '1'): ?><span class="watermark transparent">Premium</span><?php endif; ?>
</a>
<span class="duration"><?php echo VDate::duration($video['duration']); ?></span>
<div class="rating_bar"><div style="width:<?php echo round($video['rating']*20); ?>%"></div></div>
<span class="timeline clear"><?php echo VDate::nice($video['add_time']); ?></span>
<span class="views"><?php echo $video['total_views'],' '; if ($video['total_views'] == '1'): echo __('view'); else: echo __('views'); endif; ?></span>
<div class="clear"></div>
</div>
<?php endforeach; ?>
<div class="clear-left"></div>
<div class="pagination"><ul><?php echo p('pagination', $this->pagination, RELATIVE_URL.'/recent/#PAGE#/'); ?></ul></div>
<?php else: ?>
<div class="none"><?php echo __('no-videos'); ?></div>
<?php endif; ?>
<?php echo p('adv', 'frontpage-bottom'); ?>
</div>
</div>
</div>
<div class="clear"></div>
</div>
Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds
Offline
hi, it not works for me. when i input the code into modules/frontpage/frontpage.php the website is only white screen.
Offline
Enable debug in Admin and then post the error here.
Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds
Offline
Will post a complete frontpage.php and frontpage.tpl.php files here.
Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds
Offline
Ahhh...i think i sent it via email. Will also post here.
Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds
Offline
Offline
Updated this howto with the complete files frontpage.php and frontpage.tpl.php (tested in aspro 1.0.12).
Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds
Offline
Offline
No way to have random videos appearing and currently now way to display featured only in admin. Will add in next version.
Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds
Offline