Need help cross referencing

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

By dccreatives - December 14, 2010

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

By Jason - December 14, 2010

Hi,

Could you give some more clarification on what you're trying to accomplish? How are you trying to "pull" these records? Are you just trying to get the records from the downloads section or the actual files that have been uploaded?

Let me know and we'll see what we can figure out.
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

By dccreatives - December 15, 2010

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

By dccreatives - December 15, 2010

<?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

By dccreatives - December 15, 2010

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: [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/