• Welcome to PHPVIBE Forums. Please log in.

[ Video Sharing CMS v4 ] Alphabetize the Channel List

Started by hunt07777,

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

hunt07777Topic starter

Mario, my channel list on the left is getting really long...
Is there anyway to alphabetize it.. using php?

Thanks so much bud.
  •  

Marius P.

lib/functions.php find this:

function the_nav() {



in this function find:


$categories = $cachedb->get_results("SELECT cat_id as id, child_of as ch, cat_name as name, picture FROM  ".DB_PREFIX."channels limit 0,10000");



and change it to :


$categories = $cachedb->get_results("SELECT cat_id as id, child_of as ch, cat_name as name, picture FROM  ".DB_PREFIX."channels order by cat_name desc limit 0,10000");



notice the ordering:
order by cat_name desc

if that doesn't suit you, use


order by cat_name asc



Sorry, it's late and i'm out, can't think clear right now which one it's best.
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

hunt07777Topic starter

Worked perfect!! Thank you so much Mario for all your hard work! (solved!)
  •  

hamnawa

Worked for me also I got another question how to display only few categories by category id?
  •  

Marius P.

lib/functions.php

function the_nav() {




$categories = $cachedb->get_results("SELECT cat_id as id, child_of as ch, cat_name as name, picture FROM  ".DB_PREFIX."channels limit 0,10000");



changed to
$categories = $cachedb->get_results("SELECT cat_id as id, child_of as ch, cat_name as name, picture FROM  ".DB_PREFIX."channels where cat_id in (1,2,3,4,5,6,7) limit 0,10000");

change

in (1,2,3,4,5,6,7)



to your ids list.

Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

grantj21

Update on this code for 3.5 A-Z List order for category's.
Look in lib/function.php
function the_nav() {

Replace this code.
$categories = $cachedb->get_results("SELECT cat_id as id, child_of as ch, cat_name as name, picture FROM  ".DB_PREFIX."channels limit 0,10000");

With is one.
$categories = $cachedb->get_results("SELECT cat_id as id, child_of as ch, cat_name as name, picture FROM  ".DB_PREFIX."channels WHERE type='$type' order by cat_name asc limit 0,10000");


One thing I did notices it that the word Pop if used as a main cat on the music channel comes out on top it many be something in my own script, I'll update if I fine out why. Other than that it works fine.
  •  

PHPVibe A.

Make sure you don't have an space before the Pop in sql.

grantj21

Yes there was thank you how looking good.
  •  

PHPVibe A.

Will commit this to default release as well (Idk why we forgot, maybe we're to tired)

grantj21

You guy's have do a great job, just some house keeping to do. I Know some plug-ins are being made for PHPVibe I will be the first and I will post a link once my site is live.
  •  

Marius P.

Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

hamnawa

How to display channels by id in version 3.6 I used following code it is not working for me:

$categories = $cachedb->get_results("SELECT cat_id as id, child_of as ch, cat_name as name, picture FROM  ".DB_PREFIX."channels where cat_id in (1,2,3,4,5,6,7) limit 0,10000");
  •  

PHPVibe A.

Use the 3.6 query and just add the conditional:

where cat_id in (1,2,3,4,5,6,7)

hamnawa

Thank you it worked for me.

I used as follow:

$categories = $cachedb->get_results("SELECT cat_id as id, child_of as ch, cat_name as name, picture FROM  ".DB_PREFIX."channels where cat_id in (1,2,3,4,5) order by cat_id asc limit 0,10000");


  •  

hamnawa

Am i using the correct format as follow for version 3.6?

$categories = $cachedb->get_results("SELECT cat_id as id, child_of as ch, cat_name as name, picture FROM  ".DB_PREFIX."channels where cat_id in (1,2,3,4,5) order by cat_id asc limit 0,10000");


It works in one of my web-sites while in other it displays Video channels under Audio and Image also at the same time.
  •  

hamnawa

Can anyone tell me if I am using right format?
  •  

x5000x

Quote from: hamnawa on
Can anyone tell me if I am using right format?

This works in 3.6

$categories = $cachedb->get_results("SELECT cat_id as id, child_of as ch, cat_name as name, picture FROM  ".DB_PREFIX."channels WHERE type='$type' order by cat_name asc limit 0,10000");
  •  

hamnawa

Thank you it works however I am facing another issue here.

I have listed as below:

13,15,18,1,2,28,29,30,39,44,52,57,68,77,78,80,83,86,87,91,93,94

Everything shows as it should but channel 1,2 is displayed at the top of the list instead.
  •  

PHPVibe A.

They are ordered by the category name.
Make sure you don't have an whitespace before the name.

Similar topics (7)