Need help cross referencing

10 posts by 2 authors in: Forums > CMS Builder
Last Post: December 15, 2010   (RSS)

I have a section called downloads. Within downloads, I have added records that I have fields for uploads for brochures, spec sheets, etc. I assigned the download id to each product item that I have. It works really well.

Now I need to create a section that has only brochures and only spec sheets. How do I create a new section editor that will pull all the brochures and spec sheets from all the download records?

I tried to make a related records field but I am not sure how to go about this.

Please help.

Re: [Jason] Need help cross referencing

Within Downloads I have items that have downloads to brochures and spec sheets for each product.

I want to pull all the spec sheets from all the items in downloads in one list. and the same for brochures. Here's an example.

On this page: http://www.axislighting.com/CMS/downloadsList.php are the items with downloads so far. The first item is brochures. What I want is to call all the brochures in one list. The next items is the Product Images. I want to call all the project images in one list. So if someone only wants to see brochures or only wants to see all the Product Images, I should be able to show it in a list. Please advise.

Re: [dccreatives] Need help cross referencing

By Jason - December 15, 2010

Hi,

Okay, I think I see where you're going with this. How are you able to differentiate between an upload that's a brochure and an upload that product images?

Thanks
---------------------------------------------------
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] Need help cross referencing

<?php foreach ($downloadsRecord['product_images'] as $upload): ?> This would be how I call the project images for each item

<?php foreach ($downloadsRecord['brochure'] as $upload): ?> This would be how I call the brochure for each item

<?php foreach ($downloadsRecord['specification_sheets'] as $upload): ?> This would be how I call the spec sheets for each item

I have each one as a separare uploads field in the Downloads section editor for each item.

Re: [dccreatives] Need help cross referencing

By Jason - December 15, 2010

Hi,

I think the easiest way to do this would be to create 3 new arrays.

In this example, we'll loop through all of the record returned from the Downloads section:

$product_images = array();
$brochures = array();
$specification_sheets = array();

foreach($downloadsRecords as $downloadsRecord){
if($downloadsRecord['product_images']){
$product_images[]=$downloadsRecords['product_images'];
}
if($downloadsRecord['brochures']){
$brochures[]=$downloadsRecords['brochures'];
}
if($downloadsRecord['specification_sheets']){
$specification_sheets[]=$downloadsRecords['specification_sheets'];
}
}


We now have all the uploads for each section stored in an individual array.

Now we can output a list. For example, brochures:

<?php foreach($brochures as $brochure):?>
<?php foreach($brochure as $upload):?>
*OUTPUT BROCHURE*
<?php endforeach ?>
<?php endforeach ?>


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] Need help cross referencing

Where am I putting the array from the top? Does that go in the Head section or right before I call the output?

Re: [dccreatives] Need help cross referencing

By Jason - December 15, 2010

Hi,

You would put the code that creates the arrays up near the top of your page, after your return your records from Downloads.

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] Need help cross referencing

Here is the code online: http://axislighting.com/CMS/downloadsList.php

I am attaching the file. Something is not correct with the way I inserted the code.

Please advise.
Attachments:

downloadslist-arrays.php 7K

Re: [dccreatives] Need help cross referencing

By Jason - December 15, 2010

Hi,

There was a typo, we had an "s" at the end of the variable name. Try replacing the code like this:

foreach($downloadsRecords as $downloadsRecord){
if($downloadsRecord['product_images']){
$product_images[]=$downloadsRecord['product_images'];
}
if($downloadsRecord['brochure']){
$brochures[]=$downloadsRecord['brochure'];
}
if($downloadsRecord['specification_sheets']){
$specification_sheets[]=$downloadsRecord['specification_sheets'];
}
}


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/