Category Order with two column split
2 posts by 2 authors in: Forums > CMS Builder
Last Post: June 18, 2013 (RSS)
By petejdg - June 18, 2013
I have reused some code from another project to split my categories in to two columns. I set up category menu for my Channel categories and then the Channel admin and connected the category list back to Channel categories section. I am splitting the output in to two columns. But I would like to have the Channel Categories in the order that I have them in and then sort the channels by the dragSortOrder. The following is my code and I am thinking since I am not actually connecting to the Channel Category table itself and only the Channels table - how can I order my categories correctly as ASC and DESC won't work as I need it in the specific order I want.
Channel Category should be:
Starter, Essential, Essential Digital Music, Ultimate, Premium HBO, Premium Cinemax, Premium NFL Redzone, etc
http://www.westelsystems.com/alton/tv/channel_line_upnew.php
By Jason - June 18, 2013
Hi,
It looks like you're most of the way there. What you need to do now is to retrieve your channel category records in the order you want them and then use that in your foreach loop. In this code example, I've made the following assumptions:
- Your table is called channel_category
- This table has a field called "title", which is used as the label in the "wttv_channels" section.
The first thing we would do is get your records in their drag sort order and retrieve the title field:
<?php $headings = array_pluck(mysql_select("channel_category", "TRUE ORDER BY dragSortOrder DESC"), "title"); ?>
Next, we add an additional foreach loop to go through each of the headings records first:
<?php foreach ($headings as $heading): ?>
<?php if (!array_key_exists($heading, $headingsToRecords)) { continue; } ?>
<?php foreach ($headingsToRecords[$heading] as $channels): ?><tr>
Please note that this code is untested, and you may need to change some variable and field names to match your set up.
Hope this helps
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/