Jump to content

Help with determining if file outputs subcategory


Chrisj

Recommended Posts

The web video script that I'm trying to modify, successfully filters videos by category and by sub-category. The file code here shows sub-category related code: https://pastebin.com/zgbELKJf on lines 149 and 215 I am trying to display a search form when sub-category page appears, so I first need to determine if this code is the file that outputs the subcategory pages. (as a first step in being able to search the sub-category page by keyword).  If this provides a clue, when I remove these lines:

$pt->show_sub = false;
$pt->sub_categories_array = array();
foreach ($pt->sub_categories as $cat_key => $subs) {
    $pt->sub_categories_array["'".$cat_key."'"] = '<option value="">'.$lang->all.'</option>';
    foreach ($subs as $sub_key => $sub_value) {
        $pt->sub_categories_array["'".$cat_key."'"] .= '<option value="'.array_keys($sub_value)[0].'" '.((!empty($_GET['sub_id']) && $_GET['sub_id'] == array_keys($sub_value)[0]) ? "selected" : "") .'>'.$sub_value[array_keys($sub_value)[0]].'</option>';
   }

    if (!empty($_GET['id']) && $_GET['id'] == $cat_key) {
        $pt->show_sub = true;
if($pt->show_sub) {

}
}

it eliminates the drop-down list to choose a subcategory, so there’s no way to display subcategory pages without that code.

And on the html page file there is also this code:

<?php if ($pt->page == 'category' && $pt->show_sub == true) { ?>
<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 additional assistance is welcomed

 

Link to comment
Share on other sites

Thanks for your reply.
I'm trying to get help to determine if the php file outputs the subcategory.

And then I'll be looking for guidance to ultimately have a search form appear on the page when it's  a subcategory page.

I had tried echo-ing the Form onto the sub-category page by adding to the php file ( https://pastebin.com/zgbELKJf ) this:

$injectForm = "";

 - - -etc.- - -

$injectForm = "<form action=\"content.php\" method=\"GET\" id=\"sub-search\">
<input id=\"search\" name=\"keywords\" type=\"text\" placeholder=\"Type here\">
<input type=\"submit\" value=\"Search\" />
</form>";

and added this to the html page:

<?php
echo $injectForm;
?>

but no success with displaying the Search Form onto a subcategory page

 

Edited by Chrisj
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.