combining data from different sections on a multiple list page

9 posts by 3 authors in: Forums > CMS Builder
Last Post: November 21, 2016   (RSS)

By loccom - November 18, 2016

Hi

I have 5 sections in CMSB admin and I would like to combine data from each one of these dections on the List Page

Can someone advise how to do this?

I am adding multiple page loads at the the of the page? I am trying but it only loads data from one and is not lopping the other 4 sections.

Most grateful if someone could do a few steps for me. I have been using ITools products since 2000 but it has been ages since i have done any work on it and I have gotten rusty.

thanks

By willydoit - November 18, 2016

Hi,

I am no expert but I have a page loading from 2 section and this is the header code for that, hope it helps.

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */
  
  // load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/home/sites/bridlington.net/public_html/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
  
  // load record from 'books'
  list($booksRecords, $booksMetaData) = getRecords(array(
    'tableName'   => 'books',
    'where'       => whereRecordNumberInUrl(0),
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
   ));
  $booksRecord = @$booksRecords[0]; // get first record
  
 // load record from 'authors'
  list($authorsRecords, $authorsMetaData) = getRecords(array(
    'tableName'   => 'authors',
    'where'       => whereRecordNumberInUrl(0),
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $authorsRecord = @$authorsRecords[0]; // get first record
  


?>

By loccom - November 18, 2016

thanks for your reply.

Is this for a detailed page or listings index (i.e List of books)?

By Damon - November 18, 2016

Hi,

I have 5 sections in CMSB admin and I would like to combine data from each one of these dections on the List Page

Can you give an example of the end result?

For example, are you wanting to publish content from 5 different section editors in different areas of one page?

Or are you wanting to have a list of records that is a combination of 5 different section editors?

If you can provide more details, that will help me get a better idea about what you are trying to accomplish.

Thanks!

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By loccom - November 18, 2016 - edited: November 18, 2016

Hi Damon

thanks for your response.

So basically we have 5 sections for our charity rally roadtrips, these are in the back end of CMSB admin

1. Team Info
2. Team Member Info
3. The Vehicle
4. Fundraising
6. Border Entry and meeting Points

We would like to see a list of all the teams

Each Listing will need a few data points from each such as Team Logo, Team Name, Vehicle, Fundraising Total etc.

Each team listing will then link to a detailed page with more about the team.

I have tried adding the 5 viewers at the top of the page and then adding each for each statement and closing <?php endforeach ?> but only one of the viewers ever work, which is the first one. The rest go undefined,

I have attached a screenshot of what i have so far , however, I have only managed to pick points from one section and I would like to add more to these listings if I can find a way to add points from different sections.

By loccom - November 21, 2016

i still have not figured this out

By loccom - November 21, 2016

This will be dead simple fix probably

If I add 2 viewer libraries the second library never works. So I assume I am not loading the header libraries properly. I have linked the demo page at the bottom.

This is the detailed page, I also need to do the same on the search results page too. I need to load data from multiple section editors on one page. How can I do this properly on both detailed page and search results page?

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
/* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

// load viewer library
$libraryPath = 'team-manager/lib/viewer_functions.php';
$dirsToCheck = array('/home/drivetom/domains/charityrallies.org/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

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

// load record from 'vehicle_details'
list($vehicle_detailsRecords, $vehicle_detailsMetaData) = getRecords(array(
'tableName' => 'vehicle_details',
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));


?>
<html>
<head>
</head>
<body>

<p> Record Number: <?php echo htmlencode($teamsRecord['num']) ?></p>
<p> Team Name: <?php echo htmlencode($teamsRecord['title']) ?></p>
<p> Team Description: <?php echo htmlencode($teamsRecord['content']) ?></p>

<p> Make: <?php echo htmlencode($vehicle_detailsRecord['title']) ?></p>
<p> Model: <?php echo htmlencode($vehicle_detailsRecord['model']) ?></p>

</body
<html>

Here is a sample of it working, Note Make and model has errors

http://charityrallies.org/team-profiles/test.php?yeyo148-5

By Damon - November 21, 2016

Hi,

Try this code with the code that was missing:

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
/* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

// load viewer library
$libraryPath = 'team-manager/lib/viewer_functions.php';
$dirsToCheck = array('/home/drivetom/domains/charityrallies.org/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }


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


// load record from 'vehicle_details'
list($vehicle_detailsRecords, $vehicle_detailsMetaData) = getRecords(array(
'tableName' => 'vehicle_details',
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));

$vehicle_detailsRecord = @$vehicle_detailsRecords[0]; // get first record
if (!$teamsRecord) { dieWith404("Record not found!"); } // show error message if no record found

?>
<html>
<head>
</head>
<body>


<p> Record Number: <?php echo htmlencode($teamsRecord['num']) ?></p>
<p> Team Name: <?php echo htmlencode($teamsRecord['title']) ?></p>
<p> Team Description: <?php echo htmlencode($teamsRecord['content']) ?></p>


<p> Make: <?php echo htmlencode($vehicle_detailsRecord['title']) ?></p>
<p> Model: <?php echo htmlencode($vehicle_detailsRecord['model']) ?></p>


</body
<html>

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/