Views: 3860
Last Modified: 10.10.2012

The demo site includes an example of creation of the simplest site switcher. The API functions are used to get an array of sites and display the list of sites each linked to the respective root folder.

Site switcher

<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?>
<table cellpadding="0" cellspacing="0" border="0" width="0%">
    <tr>    
        <?
        $arSites = $APPLICATION->GetSiteSwitcherArray();
        // Display LANGUAGE SWITCHER if there are more than one site in the system
        if (count($arSites)>1):
            for($i=0; $i<count($arSites); $i++):
                $arSite = $arSites[$i];
        ?>
            <td align="left">
                <? if($arSite["SELECTED"]=="Y"):?>
                    <font class="langact"><?echo $arSite["NAME"]?></font>
                <? else:?>
                    <a href="<?=$arSite["DIR"]?>" class="lang"><?echo $arSite["NAME"]?></a>
                <? endif;?>
            </td>
            <td align="center" width="0%"><img src="/bitrix/templates/<?echo SITE_TEMPLATE_ID?>/images/lang_arrow.gif" width="10" height="11" hspace="5" alt=""></td>
        <?
            endfor;
        endif;
        ?>        
    </tr>
</table>


Courses developed by Bitrix24