8 posts by 2 authors in: Forums > CMS Builder
Last Post: January 5, 2016   (RSS)

I am trying to show the file path of an upload inside that same record after it's saved. I'm using the HTML separator to do the logic. Here is my code:

<tr>
 <td colspan='2'>
<?php if(@$RECORD['pdf_upload']) {
    foreach ($RECORD['pdf_upload'] as $index => $upload):
        echo "<strong>Link:<strong> <a href='" . htmlencode($upload['urlPath']) . "' target='_blank'>" . htmlencode($upload['urlPath']) . "</a>";
    endforeach;
} ?>
 </td>
</tr>


It doesn't seem to be showing up. Is there something I'm missing?

By ross - December 28, 2015

Hi there.

Thanks for posting.

I am not exactly sure what the issue is going to be and I would start trouble shooting this using "showme".  

You can use this function to display all the values stored in "$upload" as you cycle through your foreach loop.  Here's how:

foreach ($RECORD['pdf_upload'] as $index => $upload) {
     showme($upload);
}

The output of this will be rather "ugly" but you'll see all the values you can access in the loop.  If you don't see the value you are looking for, let me know and we'll continue to figure this out.

Thanks!

foreach ($RECORD['pdf_upload'] as $index => $upload):

-----------------------------------------------------------
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 walshb_mri - December 28, 2015 - edited: December 7, 2017

Thank you for your response Ross. I put your code instead of my code and received the following error:

Notice: Undefined index: pdf_upload in D:\inetpub\wwwroot\xxxxxxxxxx.com\admin\lib\common.php(384) : eval()'d code on line 4 Warning: Invalid argument supplied for foreach() in D:\inetpub\wwwroot\xxxxxxxxxx.com\admin\lib\common.php(384) : eval()'d code on line 4

Not sure what that means.

Brian

I am actually trying to show the url inside the admin area in cms builder. I'm using the HTML separator to do this. So what I've posted is all the code I was using. Hope that clarifies this.

By ross - January 5, 2016

Hi there.

Could you let me know why you are getting this URL to display?  

I'd like to see if there are any other ways to accomplish what you are setting up.

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/

Hey Ross,

I wanted the user to be able to view the file path of the upload so they can copy and paste it into another manager in their cms. Obviously they can just right click the download link and choose copy link, but not everyone is that tech savvy so I'd like to make it easier.

Thanks,

Brian

By ross - January 5, 2016

Hi, Brian.

I've got a code snippet you can work with.  Keep in mind that this is a fairly advanced idea and won't be something I can support in the forum.

Also, this may or may not work in future versions of CMS Builder.

Having said that, try this code in your separator

<tr><td colspan="2">

<?php

$tableName = mysql_escape(@$_REQUEST['menu']);  // get table name from URL
$recordNum = mysql_escape(@$_REQUEST['num']);   // get record number from URL

$record = mysql_get($tableName, $recordNum);    // get entire record from database (without images)
addUploadsToRecord($record);                    // add uploads to record

foreach(@$record['NAME OF YOUR UPLOAD FIELD'] as $upload)  { echo $upload['urlPath']; echo "<br />"; } // display image URLs

?>

</td></tr>

You'll need to make sure you put in the name of your upload field in.  You also may want to format the output better as this code is really simple.

Let me know any feedback.

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