I’m trying to pull the subdomain as a parameter for rendering a page. Here’s what I have:
<?php
list($subdomain) = explode('.', $_SERVER['HTTP_HOST'], 2);
if ($subdomain == 'www') $subdomain = 'default';
?
{exp:channel:entries channel="pages" search:subdomains="foo"}No matter what I do it loads my pages despite foo not being in the multiselect.
[Mod Edit: Moved to the Development and Programming forum]
Hi Chris,
Could you perhaps elaborate on what you’re trying to do as I can’t really figure it out by looking at you example. Also, your way of fetching the subdomain isn’t th most reliable way, because if you were to access that page without a subdomain, it would return the domainname itself…
Wouter
Hey Wouter,
We have a multiselect field that stores the subdomain. A page entry might have the pages URL /home. Entries with this URL would exist multiple times but which pages entry is loaded depends on whether it finds an entry with that subdomain in the subdomain multiselect.
Also, we force www on all of our domains so this would work. There’s a better way to do it though I’m sure.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.