Adult Script Pro Community Forums

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.

#1 2014-10-14 05:34:01

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

[HOWTO] Display both featured and recent on the frontpage

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

#2 2014-10-14 17:35:01

Double_D
Member
From: The Netherlands
Registered: 2014-08-14
Posts: 305
Website

Re: [HOWTO] Display both featured and recent on the frontpage

thank you wink

Offline

#3 2014-10-14 20:50:40

donronca
Member
From: The Netherlands
Registered: 2012-12-27
Posts: 317
Website

Re: [HOWTO] Display both featured and recent on the frontpage

hi, it not works for me. when i input the code into modules/frontpage/frontpage.php  the website is only white screen.

Offline

#4 2014-10-15 05:50:53

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

Re: [HOWTO] Display both featured and recent on the frontpage

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

#5 2014-10-16 10:02:21

ivatigoal
Member
Registered: 2013-06-07
Posts: 367
Website

Re: [HOWTO] Display both featured and recent on the frontpage

i also get a white page


Analtube4u

Offline

#6 2014-10-16 10:07:57

ivatigoal
Member
Registered: 2013-06-07
Posts: 367
Website

Re: [HOWTO] Display both featured and recent on the frontpage

Parse error: syntax error, unexpected ')' in /home/analtube/public_html/modules/frontpage/frontpage.php on line 87


Analtube4u

Offline

#7 2014-10-17 05:28:49

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

Re: [HOWTO] Display both featured and recent on the frontpage

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

#8 2014-11-01 08:23:12

ivatigoal
Member
Registered: 2013-06-07
Posts: 367
Website

Re: [HOWTO] Display both featured and recent on the frontpage

We still wait for this post big_smile


Analtube4u

Offline

#9 2014-11-01 15:31:57

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

Re: [HOWTO] Display both featured and recent on the frontpage

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

#10 2014-11-01 21:24:40

ivatigoal
Member
Registered: 2013-06-07
Posts: 367
Website

Re: [HOWTO] Display both featured and recent on the frontpage

No I did not receive any email. But here will be better for others to see and use also.


Analtube4u

Offline

#11 2014-11-09 10:23:12

ivatigoal
Member
Registered: 2013-06-07
Posts: 367
Website

Re: [HOWTO] Display both featured and recent on the frontpage

I would like to remind you about those files you would upload for us here. I know you are busy with the 1.2 development so no great pressure for this here. Whenever you have the free time


Analtube4u

Offline

#12 2014-11-11 11:56:41

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

Re: [HOWTO] Display both featured and recent on the frontpage

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

#13 2014-11-14 08:32:03

ivatigoal
Member
Registered: 2013-06-07
Posts: 367
Website

Re: [HOWTO] Display both featured and recent on the frontpage

Yes now it works thanks. Is there anyway to have random featured videos appearing at the list? Also a way to see all the featured videos at the backend also would be very usefull


Analtube4u

Offline

#14 2014-11-15 12:39:12

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

Re: [HOWTO] Display both featured and recent on the frontpage

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

Board footer

Powered by FluxBB