Help adding unique text to each page displayed


always ‘category’


Well then it’s not surprising that it always sets the contents of $text to be as you define it within the code that deals with that situation. If it’s never set to “trending”, “top” or the other one, it will never give it that value.

Within the code block that deals with $page == "category", how do you decide whether you are seeing trending, latest or top videos?


Thanks again for your message.
As I didn’t write this script, I’m not sure of the answer to your question. There is a file named categories.html that holds this code:

<div class="col-md-12">
	<div class="row">
        <div class="content pt_shadow">
            <div class="home-page-categories">
                <div class="title">
						<svg xmlns="" 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-tag" color="#384047"><path d="M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"></path><line x1="7" y1="7" x2="7" y2="7"></line></svg>&nbsp;&nbsp;{{CATEGORY_ONE_NAME}} 
                        <span class="view_more_link">
                            <a  data-load="<?php echo (!empty($pt->subscriptions)) ? '?link1=subscriptions' : '?link1=videos&page=category&id={{CATEGORY_ONE_ID}}' ?>" href="<?php echo (!empty($pt->subscriptions)) ? "{{LINK subscriptions}}" : "{{LINK videos/category/{{CATEGORY_ONE_ID}}}}" ?>">
                                {{LANG explore_more}} <svg xmlns="" 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-chevron-right"><polyline points="9 18 15 12 9 6"></polyline></svg>
                <div class="videos">
                    <div class="row pt_cat_vid_list">
                            foreach ($pt->cat_videos as $key => $video) {
                                $video = PT_GetVideoByID($video, 0, 0, 0);
                                echo PT_LoadPage('home/list', array(
                                    '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,
                                    'VIDEO_ID' => $video->video_id_,
                                    'VIDEO_ID_' => PT_Slug($video->title, $video->video_id)
                        <div class="clear"></div>
            <div class="clear"></div>

I look forward to any comments


The code you originally posted showed four separate possible values for $page - “top”, “trending”, “latest” and “category”. I presumed early on that for “trending” videos, that would be the value of $page and therefore you could create your unique text inside the specific if-condition that deals with that value, and the same for the other three values.

Now that you have revealed that $page is always set to “category” regardless of anything, I first have to ask what on earth the point of the first three sections of code are?

That aside, it seems that the value of $_GET['id'] is what decides the category. You create an array at the top of your code called $categories, which you use to check whether the category is valid, and to assign the title.

So my advice would be:

  1. Create a second array using the same syntax and a different name in the code, and have that array contain your unique text values for each category, in the same order as the category names.

  2. Duplicate the line that retrieves the category title and use it to retrieve the unique text into your $text variable.

You have enough sample code and discussion within this thread to achieve both of those without any further help, as they are both simply copying one brief section of code and altering it. Please, please, have a go at it before coming back to ask for “any further advice” or “links to examples”.

1 Like

Thanks for your reply.

I don’t see an array at the top of the code called $categories.
I appreciate your advice, and have given it a try, but don’t know how to create what you’ve described


Yes, you’re quite right, all this back and forth has confused me and I was looking at the array called $pages. There is an array called $categories, because you use it in this line of code:

$title    = $categories[$category];

but I cannot see where it is defined.

So I guess the question is, what value of $_GET['id'] denotes which category you are showing? Or does something else define whether you are looking at trending, top or latest?


Thanks for your reply.
there are just 3 categories.
category_id 1 is titled ‘latest’
category_id 2 is titled ‘trending’
category_id 3 is titled ‘top’


And do those IDs come in via $_GET['id'] or some other way?

If they do, create an array in the same way that the $pages array is created, and give it a different name that isn’t used anywhere else. Put each of the bits of unique text into the array. Remember that by default the first element of an array is 0 rather than 1, so if the values above are correct you’ll have to put something else in for the first element.

In the code later on where you create $text, all you need to do is access the correct element of the array using code similar to the line that accesses the $categories array.


I’m confused. So you have pages “latest”, “trending” and “top”, but also categories “latest”, “trending” and “top”?
Are these the same things, or are the separate? If they are separate, how do they differ and/or what is their relation (if any)?


This appears to work successfully on the html page:

		if ($_GET["id"] == 1){
    		echo "This is the Page 1";
		else if ($_GET["id"] == 2){
		echo "This is the Page 2";
		else if ($_GET["id"] == 3){
		echo "This is the Page 3";

Much thanks for all of your replies/suggestions/guidance

closed #53

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.