Ordering by Multiple Value Lists

23 posts by 4 authors in: Forums > CMS Builder
Last Post: December 17, 2010   (RSS)

By Jason - December 13, 2010

Hi,

The array we created to hold the category records are indexed by the num field. What field in $group stores the category num? Use this instead of $groupTitle.

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/

Re: [Jason] Ordering by Multiple Value Lists

By studio-a - December 13, 2010

Hi Jason,

Thanks for the input. Since we are referencing two tables we're not sure which field is correct. Below is the code for all the arrays AND Attached is the CMS cpanel for both tables.

$categoryNumToRecord=array();
foreach($attractions_categoriesRecords as $categoryRecord){
$categoryNumToRecord[$categoryRecord['num']]=$categoryRecord;
}

$orderedGroups=array();
foreach($local_attractionsRecords as $attraction){
$groups = trim($attraction['category'],"\t");

if($groups){ //record has groups
$groups = explode("\t",$groups);

foreach($groups as $group){
$orderedGroups[$group][]=$attraction;
}
}
else{ //record has no group
$orderedGroups['No Group'][]=$attraction;
}
}


Can you let us know the correct field you are suggesting.

Thanks,

studio-a
Attachments:

tables.jpg 306K

By Jason - December 13, 2010

Hi,

It looks like your using the title of attractions_categories as the value field of local_attractions['category'], so we'll have to change our array:

$categoryTitleToRecord=array();
foreach($arractions_categoriesRecords as $categoryRecord){
$categoryTitleToRecord[$categoryRecord['title']]=$categoryRecord;
}


And then use it like this:

<?php foreach ($orderedGroups as $groupTitle => $group): ?>
<div>
<?php if($attractions_categories = @$categoryTitleToRecord[$groupTitle]):?>
<?php foreach ($attractions_categories['thumbnail'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" align="left" alt="alt tag goes here" />
<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" align="left" border="0" alt=""/>
<?php endif ?>
<?php endforeach ?>
<?php endif ?>
<!-- ////////// Title and Description per category ///////// -->
<?php if(is_numeric($groupTitle)): ?>
<h4><?php echo $categoryNumToName[$groupTitle]; ?></h4>
<?php else: ?>
<h2><?php echo $groupTitle; ?> </h2>
<?php endif ?>
<?php echo @$attractions_categories['description'] ?> <br />


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/

Re: [Jason] Ordering by Multiple Value Lists

By studio-a - December 13, 2010 - edited: December 13, 2010

Hi Jason,

Your help is greatly appreciated, but we are not seeing the Group Description or thumbnail for each Group. No errors message either, odd?

We're thinking since we change to the code from your last posting help, perhaps there are more changes within this section of code too? Below is the lines of code for the description and images.

UPDATE: Problem Solved!
-----------------------------------------------------------
After reviewing Jason's code and the CMS Admin it turns out we needed to "change" the Field for the Option Values within the
attractions_categories table FROM "num" TO the field we named "title."

See the attached jpeg for CMS screenshot.

-----------------------------------------------------------

Between the arrays and referencing the two tables things can get a bit confusing for us. Nonetheless, Interactive Tools pulls through and helps us find the solution. Thanks Jason.

You guys rock!

studio-a
Attachments:

tables2.jpg 274K

By Jason - December 14, 2010

Hi,

Glad to hear everything is working now.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Ordering by Multiple Value Lists

By studio-a - December 14, 2010

Hi Jason,

Thanks again for your help. We do have an additional question. Currently we are limiting the number of attractions listing per page. However, sometimes the pagination breaks one Group into two pages. Below is the code we're using.

list($local_attractionsRecords, $local_attractionsMetaData) = getRecords(array(
'tableName' => 'local_attractions',
'perPage' => '15',
));


We have tried to limit the number of Groups per page in the same manner above, but it losses the pagination links.

We're pretty sure the arrays contribute in some form of matter and we cannot figure out how to limit the number of Groups per page.

If you can shine some light on this additional feature we would appreciate it.

thanks,

studio-a

By Jason - December 15, 2010

Hi,

There are a number of different options you can use to do this. One way to do this would be to would be to paginate attractions_categories and then use a separate query to get a certain number of local_attractions per category. If there are more attractions in that category than were returned, you can have a "View More" link that would take you to another page only displaying records for that category

Example:

Category 1
-attraction 1
-attraction 2

Category 2
-attraction 3
-attraction 4
-attraction 5
-attraction 6
View More

Category 3
...

Does this sound like what you're looking for?
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Ordering by Multiple Value Lists

By studio-a - December 15, 2010

Hi Jason,

Thanks for your input. We read your feedback and it's slightly more than what our client is thinking.

They would like each Category (group) NOT to be split between separated pages. Currently we are limiting the number of listed attractions, but happens is the Category (group) sometimes is divided into two separate pagination (half of the Category (group) on one page an the other half on another page), just the opposite what the client likes.

So we are trying to figure out how to keep a Category (Group) from being divided into two pages. We tried using the limited 'perPage' MySQL query but that does not work. The amount of attractions within a Category (group) will not be limited ONLY the Groups per page.

Does this clarify the functionality we are seeking? We look forward to your feedback.

Thanks,

studio-a

By Chris - December 15, 2010

Hi studio-a,

Is this layout what you're looking for?

(3 categories per page, list all attractions per category)

PAGE 1:

Category 1
Attraction
Attraction
Attraction
Category 2
Attraction
Attraction
Category 3
Attraction

PAGE 2:

Category 4
Attraction
Attraction
Attraction
Attraction
Category 5
Attraction
Attraction
Attraction
Category 6
Attraction
Attraction
Attraction
Attraction
Attraction
Attraction
Attraction
Attraction
Attraction
Attraction
Attraction
Attraction
Attraction
Attraction

PAGE 3:

Category 7
Attraction
Attraction
Attraction

All the best,
Chris

Re: [chris] Ordering by Multiple Value Lists

By studio-a - December 15, 2010

Hi Chris,

Your example is correct. Any help is greatly appreciated!

Thanks,

studio-a