Make homepage behave like browse videos page with pagination

edited February 2013 in Customizations
I will like to have the homepage act like the "vidoes" page that is the /videos page.
What i want is to have the featured videos on the homepage and have the pagination right on the homepage so that way there will be no need for the /videos page.
So when users click on the next page (on the homepage) then they will be taken to the next group of videos and the featured videos will always remain like sticky.
Think of this website here

you see how pagination is on homepage and the featured videos are always on top no matter what page?

That is exactly what i want to do.

Again thanks with previous help..was able to understand the core and more things!


  • edited February 2013
    Here you go:

    In the file /cc-core/controllers/index.php, replace the 'Recent Videos' block of code with the following:

    // Retrieve total count
    $query = "SELECT video_id FROM " . DB_PREFIX . "videos WHERE status = 'approved' AND private = '0' ORDER BY video_id DESC";
    $result_count = $db->Query ($query);
    $total = $db->Count ($result_count);

    // Initialize pagination
    View::$vars->pagination = new Pagination ($url, $total, $records_per_page);
    $start_record = View::$vars->pagination->GetStartRecord();

    // Retrieve limited results
    $query .= " LIMIT $start_record, $records_per_page";
    $result = $db->Query ($query);
    View::$vars->recent_videos = array();
    while ($video = $db->FetchObj ($result)) View::$vars->recent_videos[] = $video->video_id;

    (Replace $records_per_page with the actual number of recent videos you want to show up)

    In the file /cc-content/themes/your-theme/index.tpl, find the following line:

    <?php View::RepeatingBlock('video.tpl', $recent_videos); ?>

    And add this directly beneath:


    In the .htaccess file add this '### Main Pages', and add the following rule immediately after:

    RewriteRule ^page/([0-9]+)/$ cc-core/controllers/index.php?page=$1 [NC,QSA,L]

    All of that is basically copying some of the logic from the videos page and pasting it to the homepage. You should really build a plugin to do all of this because it'll all be lost during an update.

    Additionally, I cannot support any of the above code. It's not tested so use it at your own risk. Do not come back saying that this broke something else because we won't be able to help you.
  • you know what i thought of?
    Instead of making the homepage act like videos is better for the videos page to act like the homepage!!!

    that is a very smart move!!!

    So what i did is copy the featured videos all over to the videos page ...meaning less things to change/modify and better stability to avoid complex problems!!!

    Still working on it...just wanted to say thanks...still keep the thread open...will send a message when things are 100%

    Thanks once again!!!
  • i just noticed that there is no pagination in the videos page by default and yet on the demo site there is pagination after 9th video...why is this?

    How do i edit the number of videos i want per page?

    I see you mentioned this above:

    (Replace $records_per_page with the actual number of recent videos you want to show up)


    So i just replace the whole "$records_per_page" with a number like "10" ?
  • Pagination should trigger by default when there are a total of 10 or more public videos. 9 or less will not require pagination.
  • done..thanks
This discussion has been closed.