Get subsite
Last updated: Jul 10, 2024

Introduction

When working with subsites, it may be convenient to get the current subsite. This can be handy if you have a section that is used on multiple subsites, but you wish to make a decision based on the subsite.

Usage

To get the current subsite handle, use the Webigniter method getSubsite() in your view files.

<?php if($webigniter->getSubsite() =='nl'):?>
   <img src='dutchflag.webp'>
<?php else:?>
   <img src='ukflag.webp'>
<?php endif; ?>

In this example, we want to show a flag based on the subsite handle. Visitors of the Dutch website should see the Dutch flag; otherwise, the UK flag should be shown.

Important: The handle of the main-site is null, so you need to check against null if you want to target the main-site.

Table of Contents
  1. Introduction
  2. Usage