Need help displaying uploads from a different section

8 posts by 3 authors in: Forums > CMS Builder
Last Post: December 19, 2013   (RSS)

By gkornbluth - December 15, 2013

Hi,

Didn't we begin this conversation on http://www.interactivetools.com/forum/forum-posts.php?postNum=2232221#post2232221 a while ago?

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By Codee - December 15, 2013

Wow! great memory...BUT it's a tad different. 

By ross - December 18, 2013

Hi there

I think I have something for you :).  It gets a little more advanced but I think it's still manageable :).

What I am thinking is creating a function that looks up the images for your colors on the fly as the page lists your products.  Here's an example:

 function getColorUploadSourceByColorNum($colorNumber) {
    
    $imageRecord = mysql_select("uploads", "tableName = 'colors' AND fieldName = 'graphic' AND `order` = '1' AND recordNum = '". mysql_real_escape_string ($colorNumber) ."'");
    
    return $imageRecord[0]['thumbFilePath'];
  }

If you pass this function a number, it will look that up in the uploads table for you and return the thumbnail path to its file.  You might need to adjust

tableName = 'colors' AND fieldName = 'graphic'

but only if I didn't get the names correct.  Next up, calling this function.  In your foreach  loop, you'll need something like this:

<?php foreach($record['color:values'] as $colorNumber): ?>
      <?php if (getColorUploadSourceByColorNum($colorNumber)): ?>
      <img src="<?php echo getColorUploadSourceByColorNum($colorNumber); ?>">      
      <?php endif ?>
      <br/>
<?php endforeach; ?>

It becomes a foreach within a foreach.  Again, you might need to make adjustment to the field names I am using here.  

Does this all make sense? Give it a shot and let me know how you make out. Thanks!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

By Codee - December 18, 2013

Hi Ross!

So, does the function script go in the head of the page.?..specifically the products.php (list page) or productDetails.php (details page)?

and the forEach script to bring in the graphic to the public just goes on the page where I want the graphic to appear, correct?

By ross - December 19, 2013

Hi 

I think you are on the right track here. The function goes at the top of the page (technically it doesn't matter where - that's just where I like to put my functions), and the foreach goes where you want the image to appear.

The code will work for both list and detail pages.  Keep in mind that on the list page, you'll need to put my foreach inside of the main foreach that's cycling through your records.  On both pages, you'll need to make sure where I have $record, you swap it in for what you've called your data set.

Does that all make sense? Keep me up to date with how you are making out. Thanks!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

By Codee - December 19, 2013

Actually, Ross, I failed over-and-over on this last night and sent an email to Greg about just hiring either him or you to get this nailed down for me asap as the client is in need. I sent him ftp details and a request for how much it will cost. I'll pay instantly if you guys could jump in on this while I work on another part of the project.

By ross - December 19, 2013

Hi

Sounds good! Thanks for the heads up :). Greg just forwarded me your email and I'll be in touch shortly!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/