Hello people, I hope you are all well.
I have a Modx site at the moment and have a template that I use for all my pages. My question is I have been looking at adding my site to Facebook as an app and was wondering if it is possible to make Modx change the default template based on the sub-domain.
For example:
Current site: www.mysite.com uses default template to display all info
Facebook site: facebook.mysite.com uses custom facebook template to display all info
Mobile site: mobile.mysite.com uses custom template that will display on a mobile phone.
(That is not my site, didn’t want to put my URL in case in would just result in my been flamed)
I hope that makes sense, I just wont the same information from my pages but just laid out differently depending on how it’s accessed.
Thanks
Ian
-
☆ A M B ☆
- 24,524 Posts
That’s what plugins are for. Instead of hacking the core, make a plugin that does the same thing using the onWebPageInit event.
Good plan ..... I shall at that to my Todo list now I know how I can change it.
(I will now google onWebPageInit)
Plugin Start
Here is hint from Susan’s template switcher...
GENERAL:
$table = $modx->getFullTableName("site_templates");
$result = $modx->db->select("id, content",$table,"templatename = '".$overrideTemplate."'");
if($modx->db->getRecordCount($result) == 1) {
$row = $modx->db->getRow($result);
$modx->documentObject['template']=$row['id'];
$modx->documentContent = $row['content'];
}
CONFIGURATION:
&overrideTemplate=Template Name;text;Minimal Template
SYSTEM EVENTS:
Template Service Events
OnLoadWebDocument
DropboxUploader -- Upload files to a Dropbox account.
DIG -- Dynamic Image Generator
gus -- Google URL Shortener
makeQR -- Uses google chart api to make QR codes.
MODxTweeter -- Update your twitter status on publish.