Help adding unique text to each page displayed

I am using a php web video script which displays video pages titled: ‘trending’, ‘latest’ and ‘top’.
The php file code below generates what the html code will display, I believe. The outcome is if ‘trending’ is chosen, display that list of videos, if ‘latest’ is chosen display that list of videos, etc…
I would like to add some unique text to each page, but what is displayed in each choice is simply a new ‘title’ and a new list of videos. How could I either separate each page to add unique text to each page, or how would I add code to show unique text to appear when the unique page is displayed, using the existing code. For example, more ‘trending’ text when the ‘trending’ page is displayed, and more ‘latest’ text when the ‘latest’ page is displayed. I hope that make sense.
Here is the php code:

<?php

if (empty($_GET['page'])) {
    header("Location: " . PT_Link('404'));
    exit();
}
$page         = PT_Secure($_GET['page']);
$limit        = 20;
$pt->rss_feed = false;
$pt->exp_feed = true;
$pages        = array(
    'trending',
    'category',
    'latest',
    'top'
);

if (!in_array($page, $pages)) {
    header("Location: " . PT_Link('404'));
    exit();
}

if (!empty($_GET['feed']) && $_GET['feed'] == 'rss') {
    $limit        = 50;
    $pt->rss_feed = true;

}
$pt->page_url_ = $pt->config->site_url.'/videos/'.$page;
$cateogry_id = '';
$videos = array();
if ($page == 'trending') {
    $title  = $lang->trending;
    $db->where('privacy', 0);
    $videos = $db->where('time', time() - 172800, '>')->orderBy('views', 'DESC')->get(T_VIDEOS, $limit);
}

else if ($page == 'latest') {
    $title  = $lang->latest_videos;
    $db->where('privacy', 0);
    $videos = $db->orderBy('id', 'DESC')->get(T_VIDEOS, $limit);
}

else if ($page == 'top') {
    $title  = $lang->top_videos;
    $db->where('privacy', 0);
    $videos = $db->orderBy('views', 'DESC')->get(T_VIDEOS, $limit);
}

else if ($page == 'category') {
    if (!empty($_GET['id'])) {
        if (in_array($_GET['id'], array_keys($categories))) {
            $cateogry = PT_Secure($_GET['id']);
            $title    = $categories[$cateogry];
            $cateogry_id = "data-category='$cateogry'";
            $db->where('privacy', 0);
            $videos   = $db->where('category_id', $cateogry)->orderBy('id', 'DESC')->get(T_VIDEOS, $limit);
        } else {
            header("Location: " . PT_Link('404'));
            exit();
        }
    }
}

use Bhaktaraz\RSSGenerator\Item;
use Bhaktaraz\RSSGenerator\Feed;
use Bhaktaraz\RSSGenerator\Channel;


//Export rss feed
if ($pt->rss_feed) {
    $rss_feed_xml   = "";
    $fl_rss_feed    = new Feed();
    $fl_rss_channel = new Channel();


    $fl_rss_channel
        ->title($pt->config->title)
        ->description($pt->config->description)
        ->url($pt->config->site_url)
        ->appendTo($fl_rss_feed);

    if (is_array($videos)) {
        foreach ($videos as $feed_item_data) {
            $feed_item_data = PT_GetVideoByID($feed_item_data, 0, 0, 0);
            $fl_rss_item    = new Item();
            $fl_rss_item
             ->title($feed_item_data->title)
             ->description($feed_item_data->markup_description)
             ->url($feed_item_data->url)
             ->pubDate($feed_item_data->time)
             ->guid($feed_item_data->url,true)
             ->media(array(
                'attr'  => 'url',
                'ns'    => 'thumbnail',
                'link'  => PT_GetMedia($feed_item_data->org_thumbnail)))
             ->appendTo($fl_rss_channel);
        }
    }

    header('Content-type: text/rss+xml');
    echo($fl_rss_feed);
    exit();
}


$html_videos = '';
if (!empty($videos)) {
    foreach ($videos as $key => $video) {
    	$video = PT_GetVideoByID($video, 0, 0, 0);
        $html_videos .= PT_LoadPage('videos/list', array(
            'ID' => $video->id,
            'VID_ID' => $video->id,
	        'TITLE' => $video->title,
	        'VIEWS' => $video->views,
            'VIEWS_NUM' => number_format($video->views),
	        'USER_DATA' => $video->owner,
	        'THUMBNAIL' => $video->thumbnail,
	        'URL' => $video->url,
	        'TIME' => $video->time_ago,
            'DURATION' => $video->duration
        ));
    }
}

if (empty($videos)) {
	$html_videos = '<div class="text-center no-content-found empty_state"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-video-off"><path d="M16 16v1a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h2m5.66 0H14a2 2 0 0 1 2 2v3.34l1 1L23 7v10"></path><line x1="1" y1="1" x2="23" y2="23"></line></svg>' . $lang->no_videos_found_for_now . '</div>';
}
$pt->videos_count= count($videos);
$pt->page        = $page;
$pt->title       = $title . ' | ' . $pt->config->title;
$pt->description = $pt->config->description;
$pt->keyword     = @$pt->config->keyword;
$pt->content     = PT_LoadPage('videos/content', array(
    'TITLE' => $title,
    'VIDEOS' => $html_videos,
    'TYPE' => $page,
    'CATEGORY_ID' => $category_id
));

It doesn’t make sense to me, but my brain is cloudy. What type of text, and based on what?

Thanks for your reply.
The script has a content.php (code shown above) that loads a page based on its category id (or page name/title) and has just one html code file that reflects the Title and the related videos. There are only three categories. I’d just like to display different text for each displayed page. Here is the (content.html) html file code:

<div class="wo_about_wrapper_parent">
	<div class="wo_about_wrapper">
		<div class="hero hero-overlay" style="background-color: #033d5d;">
			<div class="container">
				<h1 class="text-center"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-video"><polygon points="23 7 16 12 23 17 23 7"></polygon><rect x="1" y="5" width="15" height="14" rx="2" ry="2"></rect></svg> {{TITLE}}</h1>
			</div>
		</div>
		<svg id="wave" viewBox="0 0 1440 48" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g transform="translate(0.000000, -564.000000)" fill="#033d5d"><g id="Head-background" transform="translate(-168.000000, -346.000000)"><g id="waves-background" transform="translate(888.000000, 934.000000) scale(-1, 1) translate(-888.000000, -934.000000) translate(168.000000, 910.000000)"><path d="M0,14.60779 C101.722445,4.7613277 195.244576,-4.14113188e-14 429,-2.84217094e-14 C732,-1.97619698e-14 798,45.6756592 1089,45.6756592 C1245.83848,45.6756592 1364.64602,29.5028807 1440,14.5904096 C1440,14.60779 1440,48 1440,48 L0,48 C0,48 0.0410082206,34 0,14.60779 Z" id="Path-3-Copy"></path></g></g></g></g></svg>
	</div>
</div>
<div class="content pt_shadow pt_page_margin" style="padding-top: 25px;">
	<div class="col-md-12">




		<?php if ($pt->page == 'category' && $pt->show_sub == true) { ?>
			<div class="pull-right col-md-3 no-padding-left">
					<select name="type" class="form-control form-group" id="sub_categories_">
	                    <?php echo $pt->sub_categories_array["'".$_GET['id']."'"]; ?>
	                </select>
				</div>
				<div class="pull-right col-md-2 col-sm-2 text-right"><h5>{{LANG sub_category}}</h5></div>
				<div class="clear"></div>
			</h4>
	        <div class="clear"></div>
			<hr>
		<?php } ?>

		<div class="upload-head">
		<div style="float: left;">
		<button class="btn btn-main" data-action="multuple-buy-video" onclick="PT_MultipleBuyVideo();">View all selected</button>
		</div>
		<h4><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><!--<circle cx="11" cy="11" r="8"></circle>--><!--<line x1="21" y1="21" x2="16.65" y2="16.65"></line>--></svg></h4>
		<hr>
</div>



		<div class="videos-latest-list row">
      	{{VIDEOS}}
		</div>
		<?php if ($pt->videos_count > 1) { ?>
			<div class="watch-video-show-more desc load-more" data-type="{{TYPE}}" {{CATEGORY_ID}} data-sub-category-id="<?php echo( (!empty($_GET["sub_id"])) ? $_GET["sub_id"] : '' ); ?>">
                {{LANG show_more}}
            </div>
        <?php } ?>
		<div class="clear"></div>
	</div>
	<div class="clear"></div>
</div>
<script type="text/javascript">
$(document).on('change', '#category_id', function(event) {
	event.preventDefault();
	id = $(this).val();
	$('#sub_category_id').html(sub_categories_array["'"+id+"'"]);
});
$(document).on('change','#sub_categories_', function(event) {
	window.location.href = site_url+'/videos/category/<?php echo($_GET["id"]) ?>/'+$('#sub_categories_').val();
});
</script>

any guidance is appreciated

You are already doing that, so it would be trivial to dynamically add text based on the id or some data query.

Thank you. Got it. Very helpful

1 Like
Sponsor our Newsletter | Privacy Policy | Terms of Service