List Radio Butons

2 posts by 2 authors in: Forums > CMS Builder
Last Post: June 14, 2021   (RSS)

By MercerDesign - May 20, 2021

Hi, I have a multi record page which lists categories, then on the detail page for a category I've got the category title and content text, then below that I have another multi record list of projects. I have setup a list with radio buttons so you can select which category the project needs to be in. So how do I tell the category detail page to only show projects for that category. I'd done this before using single radio buttons on seperate pages but this needs to work on the generated detail page.

Thank you in advance.

By daniel - June 14, 2021

Hi MercerDesign,

If you're using a typical generated details page that has a getRecords that looks like this:

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

You could then use something like this to get projects from that category:

    // load records from 'project'
    list($projectRecords, $projectMetaData) = getRecords(array(
        'tableName'   => 'project',
        'loadUploads' => true,
        'allowSearch' => false,
        'where'       => mysql_escapef('categoryNum = ?', getLastNumberInUrl()),
    ));

The important portion is the 'where' option; you'll need to update "categoryNum" to be the category field in your project section. You'll also need to modify any other table/field names to suit your actual sections.

Let me know how you're able to get on with that, or if you have any other questions!

Thanks,

Daniel
Technical Lead
interactivetools.com