Does anybody know if there is an existing method to allow different hosts on a given domain to use different templates in pnRender?
The concept is as follows (think of a setup like typepad, webex, or other site where users or organizations get their own "hostname" on top of the service's domain name). ClientA uses a service on example.com. Example.com wants to provide a "nice" URL for ClientA to give out to their own customers like clienta.example.com. This could possibly go a step further and select a completely different theme based on the hostname, so now, example.com can allow a custom theme/skin for their clientA.
I think that multisites could handle this situation, but it might be a little overkill. After looking at the pnRender code, I think it's possible to extract the hostname and add a host-specific (or hostname-specific) search path for templates inside pnRender. Something like themes/mytheme/pntemplates/hosts/hostname/ should work and would allow a simple way to offer the functionality I describe here in addition to other more standard situations like mobile.example.com, wap.example.com, etc...
My other option is to build a simple module called during pnRender or pnUserGetTheme which would do a lookup on themepath for a given hostname, uri, or URL parameter. This might make for less hacking on the core, but I would have to create hidden themes for each of my clients and that still does not cover mobile/pda/wap setups and would still have to fall back to the site's current/default theme.
For completeness, a wildcard DNS entry is required to point all hostnames not otherwise specified to the webserver of your choice. If you have multiple webservers and need to manually load balance, you could copy your default PN codebase to the other servers and point some of your client hostnames to the new server.
Any prior experience with something like this would be greatly appreciated. I have to come up with something, so I'll report back with the results later.
Chris
--
Chris Stevens, CEO
OpenTaxi Systems LLC
866.OPENTAXI
www.opentaxi.com
On-Demand Air Taxi Reservations Platform, Flight Reservations, Consulting.
Watch
GitHub Core
Show your support for Zikula! Sign up at Github account and watch the Core project!
GitHub Modules
- mazdev responded to »Hide "Register new account" and change template to 3 col« 07:50 AM
- mesteele101 created topic »Zikula 1.3.3 - Site Search 1.5.2 - Unable to turn off plug-ins« 07:48 AM
- internetking created topic »password problem« 25. May
- mesteele101 responded to »ERR (3): E_USER_ERROR: Smarty error: [in pagesvar:pagesitem2en line XXX]…« 25. May
- mazdev responded to »Pages 2.5.0 and updating - Page not found« 25. May
- mesteele101 responded to »Zikula 1.3.3 - Selecting a category in Pages not working« 25. May
- mdee created topic »How to implement returnpage ?« 25. May
Zikula Blog
- Anatomy of Open Source Projects on Mar 07
- Continuous Review on Mar 01
- Not Invented Here on Feb 24
- How to Contribute Your Code at Github on Jan 13
- 10 Steps to Coding-Nirvana: Tips for Successful Module Writing on Nov 12
- Submitting Bug Report Tickets That Get Results on Aug 17
- Cozi Tricks #1: Syntax Highlighting on Aug 07
Login
Host-Specific Themes, Templates, Overrides
-
- Rank: Registered User
- Registered: Dec 19, 2006
- Last visit: Jun 01, 2009
- Posts: 33
-
**unknown user**
- Rank: Freshman
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 78
hack function _load_config() in pnTheme.class.php like below.
the else part is different from elseif part only at
Code
$server = pnServerGetVar('SERVER_NAME');
$customargs = $server/$this->module.'/'.$this->type.'/'.$this->func.$customargs;
Here is the code
Code
// code hacked
} else {
$server = pnServerGetVar('SERVER_NAME');
$customargs = $server/$this->module.'/'.$this->type.'/'.$this->func.$customargs;
// find any page configurations that match in a sub string comparison
$match = '';
$matchlength = 0;
foreach ($pageconfigurations as $pageconfiguration => $pageconfigurationarray) {
if (stristr($customargs, $pageconfiguration) && $matchlengh < strlen($pageconfiguration)) {
$match = $pageconfiguration;
$matchlengh = strlen($match);
}
}
if (!empty($match)) {
$file = $pageconfigurations[$match]['file'];
}
}
} elseif {
$customargs = $this->module.'/'.$this->type.'/'.$this->func.$customargs;
// find any page configurations that match in a sub string comparison
$match = '';
$matchlength = 0;
foreach ($pageconfigurations as $pageconfiguration => $pageconfigurationarray) {
if (stristr($customargs, $pageconfiguration) && $matchlengh < strlen($pageconfiguration)) {
$match = $pageconfiguration;
$matchlengh = strlen($match);
}
}
if (!empty($match)) {
$file = $pageconfigurations[$match]['file'];
}
}
thanks
s. moon -
- Rank: Registered User
- Registered: Dec 19, 2006
- Last visit: Jun 01, 2009
- Posts: 33
I was out of town, but wanted to say thanks for the input! I'll try it out the first chance I get.
--
Chris Stevens, CEO
OpenTaxi Systems LLC
866.OPENTAXI
www.opentaxi.com
On-Demand Air Taxi Reservations Platform, Flight Reservations, Consulting. -
Unregistered
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 4294967287
IMoon's code in this thread will work great for PN 0.800.
Here's a solution to the host-specific theme issue for PN 0.764. This has not been fully tested, but seems to work for me.
Insert the following code into includes/pnUser.php just after the "User theme" logic and just before the "default site theme" logic in the function pnUserGetTheme.
Code
// Custom theme selection based on hostname
$server = pnServerGetVar('SERVER_NAME');
// grab the hostname from the servername
$server = explode('.',$server);
$servertheme = $server[0];
// try to match the server name with an active
// Xanthia theme
if (!empty($servertheme))
{
$themeinfo = pnThemeInfo($servertheme);
if ($themeinfo && $themeinfo['active'])
{
$theme = $servertheme;
return $servertheme;
}
else
{
// hostnames in urls will be all lowercase, so
// try uppercasing the first letter to match our
// normal theme naming schemes
$servertheme = ucwords($servertheme);
$themeinfo = pnThemeInfo($servertheme);
if ($themeinfo && $themeinfo['active'])
{
$theme = $servertheme;
return $servertheme;
}
}
}
Create a standard Xanthia theme named after the hostname you want to use (ex. "mobile").
Upload and activate it.
If your webserver is configured to point all hostnames for your domain at your Postnuke installation, you should see your site rendered with the new theme when you go to mobile.yourdomain.com.
This works because pnUserGetTheme handles most of the include path sourcing for templates and plugins between Xanthia, pnRender, and the Core.
Any improvements or extensions on this are certainly welcome.
Standard disclaimers apply about altering the PN Core and upgrade-compatibility.
Chris
- Moderated by:
- Support
