Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

access SiteConfig fields from subsites in a template

Go to End

2 Posts   663 Views


Community Member, 18 Posts

9 December 2013 at 4:19pm

Hi, I'm using SS 3.1.2 and the Subsites module. I've extended SiteConfig to add several database fields so that each subsite can enter its own data (Contact info, address, Google map coords, etc.). From the main site I would like to be able to retrieve the subsite data from SiteConfig to list in a template, but so far I am unable to do this. Can anyone offer any help or direction?

Thanks in advance!


Community Member, 18 Posts

10 December 2013 at 1:34am

This works. Putting this in my controller and looping on $Subsites in the template:

public function getSubsites() {
$db = new SQLQuery();
$db->setWhere('SubsiteID > 0');
$records = $db->execute();
$items = array();
foreach($records as $record){
$items [] = new $record['ClassName']($record);
$sites = new ArrayList();
$sites ->merge($items);
return $sites;