Pulling in first record from each category (set by list/radio buttons)

4 posts by 2 authors in: Forums > CMS Builder
Last Post: September 24, 2013   (RSS)

By Jason - September 17, 2013

Hi,

Sure.  What you can do is use the getListOptions() function to loop though all your different show types, and then use getRecords to get a single record for each one.

In this example, we assume that you have a section called "shows", and that your radio button list is called "type"

<?php foreach (getListOptions("shows", "type") as $value => $label): ?>

  <?php
    list($showRecord, ) = getRecords(array(
      'tableName'    =>  'shows',
      'allowSearch'  =>  false,
      'limit'        =>  1,
      'where'        =>  "type = '".mysql_escape($value)."'",
    ));
    
    if (!$showRecord) { continue; } // skip if no record was found
    $show = $showRecord[0];
    
  ?>
  
  // output $show record here.


<?php endforeach ?>

Hope this helps get you started

---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

By Kittybiccy - September 23, 2013

Hi Jason,

Thanks for this. What would I then need for each top record per section to be displayed as per that html page I linked to ie. the top record for x show type - the top record for y show type - the top record for z show type etc .

One row of the 5 top records: http://www.fromemtc.co.uk/NEW/forthcoming-shows-in-frome.html

Do you think this would be easier if we got you guys to look into it and could you tell me how much that would cost?

Hannah

By Jason - September 24, 2013

Hi Hannah,

This code can be embedded in your HTML where you want the show records to be displayed.  Each iteration of the loop should output the HTML for a single one of your show "boxes".  If you would like us to step in and implement this for you, we can certainly do that.  If you could please email consulting@interactivetools.com we can go over some options.   As this looks like a pretty simple integration, I would expect the cost to be quite low.

Hope this helps

---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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