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, biapar, Willr, Ingo, swaiba, simon_w

access SiteConfig fields from subsites in a template


Reply


2 Posts   193 Views

Avatar
VanceK

Community Member, 17 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!

Avatar
VanceK

Community Member, 17 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->setFrom('SiteConfig');
      $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;
   }