6 posts by 2 authors in: Forums > CMS Builder
Last Post: December 13, 2016   (RSS)

Hi guys

I have this section called Products which lists details about all the products.

Then there are 2 other multi sections for FAQ's and Testimonials.

I have the FAQ's and testimonials setup with a list item for each so that each of the FAQ and Testimonials can be associated with products.

I want to be able to pull the details from each of them and then display with the related product page.

How can i put all the related records for each of the FAQ and Testimonials.?

This is what i have but it wont pull the related records

// load record from 'products'
list($products, $productsMeta) = getRecords(array(
'tableName' => 'products',
'where' => 'products.num =' . getNumberFromEndOfUrl(),
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
'leftJoin' => array('faqs' => 'title', 'testimonials' => 'title'),
//'debugSql' => true,
));
$products = @$products[0];

Thanks

Craig
KC Media Solutions
www.kcmedia.biz

By Dave - December 13, 2016

Hi Craig, 

How many records do you have in each of the three sections?  If it's not a lot it may be easier to just load all the records from all three sections and loop over them.  Also it's a best practice to associate records by recordNum instead of "title" so that if the title changes (or is corrected) the records are still associated (since the record num won't change).

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

hi Dave

Well at the moment there isnt any but we are expecting a few in there and the products could be changing a lot so that is why LeftJoin would be better as the FAQ and Testimonials will be linked to each product. they will not be shown on other pages on the product page related to the product.

I have change the associated records to use this but still it wont load any records from the leftJoin tables and i have no idea why it wouldnt be.

// load record from 'products'
list($products, $productsMeta) = getRecords(array(
'tableName' => 'products',
'where' => 'products.num =' . getNumberFromEndOfUrl(),
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
'leftJoin' => array('faqs' => 'num', 'testimonials' => 'num'),
//'debugSql' => true,
));
$products = @$products[0];

Thanks

Craig
KC Media Solutions
www.kcmedia.biz

Hi Dave

I found a way around it so now each section FAQs and Testimonials is using its own Load Records statement and then using a custom Where statement to pull the ProductsNum from the Products section and then relating them to each record to display only the records related to that product.

Thanks

Craig
KC Media Solutions
www.kcmedia.biz

By Dave - December 13, 2016

Ok, great to hear.  Thanks for the update!

Dave Edis - Senior Developer
interactivetools.com