Adding extra info upload fields - is this the right way?

5 posts by 2 authors in: Forums > CMS Builder
Last Post: July 14, 2017   (RSS)

By JeffC - July 5, 2017

Hi

I would like to add two extra info upload fields. Can I do this simply by creating the extra fields here:

admin.php?menu=database&action=editTable&tableName=uploads

I am guessing that any changes to this file will be overwritten when I upgrade?

Would any information that I have added to these fields also be overwritten with an upgrade, or would the database info stay intact and just cause an error until I recreate the fields?

Is there a better way of doing this?

Thanks
Jeff

Jeff

By JeffC - July 6, 2017

Hi Dave

Thanks for the advice. I have done as you suggested and have set up a related records field. I have used the CMSB relatedRecordLookupFunctions plugin and a tutorial by Jerry Kornbluth to achieve this.

I have everything set up perfectly on a standalone detail page. Ideally though I would like to integrate it with your CMSB Instant Website Template, and I am stuck. Currently, in my standalone page, my Range section editor pulls in records from the Products section editor: 

  list($rangesRecords, $rangesMetaData) = getRecords(array(
    'tableName'   => 'ranges',
    'where'       => '', // load first record
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $rangesRecord = @$rangesRecords[0]; // get first record
  if (!$rangesRecord) { dieWith404("Record not found!"); } // show error message if no record found

?>

<?php if ($rangesRecords): ?>
<?php
beta_lookupRelatedFields(array(   
    'table'      => 'ranges',   
    'recordList' => &$rangesRecords,   
    'fieldList'  => array( 'products' )    
  )); 
  $rangesRecord = @$rangesRecords[0]; // get first record 
?>  
<?php endif ?>

My problem is how to implement the above lookupRelatedFields array into the structure of the IW website_init.php (extract below).

// load pages
list($categories, $selectedCategory,) = getCategories(array(
  'tableName'            => 'iw_pages',
  'defaultCategory'      => 'first',    // Enter 'first', a category number, or leave blank '' for none
//  'selectedCategoryNum'  => '',         // defaults to getLastNumberInUrl()
  'categoryFormat'       => 'showall',  // showall, onelevel, twolevel, breadcrumb
  'ulAttributesCallback' => 'customMenuUlAttr', // ADVANCED: custom function to return ul attributes, eg: myUlAttr($category);
  'liAttributesCallback' => 'customMenuLiAttr', // ADVANCED: custom function to return li attributes, eg: myLiAttr($category);
));
$page = $selectedCategory;

function customMenuUlAttr($category) {
  return ($category['_hasParent'] && $category['depth'] == '1')? "class=\"dropdown-menu\" role=\"menu\"" : "" ;
}

function customMenuLiAttr($category) {
  return ($category['_hasChild'] && $category['depth'] == '0')? 'class="dropdown"': "" ;
}

Thanks in advance,
Jeff

Jeff

By Dave - July 6, 2017

Hmm, I haven't used that plugin in a long time so I'm not sure.  

One thing you can try is using showme() to see the contents of that variable <?php echo showme($rangesRecord); ?>

Perhaps it's added some fields that you can now output on the page? 

Dave Edis - Senior Developer
interactivetools.com

By JeffC - July 14, 2017

Hi Dave

I'm still struggling with this. I have submitted a custom consulting request via the website. 

Cheers

Jeff