How to: Cross-Related Sections
2 posts by 2 authors in: Forums > CMS Builder
Last Post: September 30, 2010 (RSS)
By zip222 - September 30, 2010
I am looking for some help on how to set up the following:
I have two sections, both are multiple-record editors. One is for Departments (info about the department), and the second is for Department Directors (info about the directors, including a photo).
In the Departments, I want to have a drop down list where I can select the director for that department. I know how to set this up in the CMS using the Get Options from Database (advanced).
But how do I get the directors info to show on the public site on the Department pages?
I have two sections, both are multiple-record editors. One is for Departments (info about the department), and the second is for Department Directors (info about the directors, including a photo).
In the Departments, I want to have a drop down list where I can select the director for that department. I know how to set this up in the CMS using the Get Options from Database (advanced).
But how do I get the directors info to show on the public site on the Department pages?
Re: [zip222] How to: Cross-Related Sections
By Jason - September 30, 2010
Hi,
How this will work will depend on what you're storing as the value for your director's list field. Most likely, you're using the num field from the directors table. In that case, when you're displaying your department information, you'll have the record number of the director. You can then simple use another query to get all their information.
EXAMPLE
(note, this example is assuming that you're using a variable called $department to output your department information. You may need to change some name to make it match what you have in your database on your page)
So you'll have the variable $director that has the information from your director record.
Hope that gets you started.
How this will work will depend on what you're storing as the value for your director's list field. Most likely, you're using the num field from the directors table. In that case, when you're displaying your department information, you'll have the record number of the director. You can then simple use another query to get all their information.
EXAMPLE
(note, this example is assuming that you're using a variable called $department to output your department information. You may need to change some name to make it match what you have in your database on your page)
list($directorRecord,$directorMetaData)=getRecords(array(
'tableName' => 'directors',
'allowSearch' => false,
'limit' => 1,
'where' => "num =".intval($department['director']),
));
$director = $directorRecord[0];
So you'll have the variable $director that has the information from your director record.
Hope that gets 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/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/