Hello,
I’m curious if it’s possilble to load a page in a different template.
In my case, I’m loading the weblogin snippet via Ajax.
For this purpose, I need the template to be blank.
As soon as i post the login, it redirects to a new page with a blank template.
Is there a way to do this?
e.g. index.php?id=15&template=4
I could change the action part of the form using javascript, so this seems to be a reasonable solution
Cheers!
-
☆ A M B ☆
- 24,524 Posts
&loginhomeid=`xx`, where xx is the ID of the page you want them to go to on login.
Thanks!
This almost does the trick.
It just fails when someone enters a wrong password..
For now, I should just let those who enter their password incorrectly deal with a nearly blank page...
-
☆ A M B ☆
- 24,524 Posts
There is a plugin for changing templates; it uses a query string like you mentioned. The page involved must be uncached, however, as when a page is cached the parser doesn’t even look for the resource’s template (unless the cache file for it doesn’t exist). So the plugin has to use an event that occurs before the parser checks for its cache status. It could delete the resource’s cache file if one exists, thus forcing the parser to load the template and re-parse the resource if the GET parameter exists.
-
☆ A M B ☆
- 24,524 Posts
Just set the template ID; MODx will grab it and apply it to the document’s content. If you set the document’s content to be the template’s content, then all you’ll get is the template content plugged into the template where the [*content*] tags are. This could get really ugly really fast, as the [*content*] now evaluates to the template’s content, which has the [*content*] tag which now evaluates to the template’s content...
-
☆ A M B ☆
- 24,524 Posts
By the time OnWebPagePrerender is invoked, the document is parsed and ready to send to the server.
http://www.sottwell.com/system-events.html
Here’s the code to my old template switcher, it may help.
// TemplateSwitcher - plugin for MODx
// [email protected]
// released to the Public Domain
// uses OnLoadWebDocument event
// stores template choice in cookie
// add the usecookie argument to the Configuration
// &usecookie=Use Cookie;list;no,yes;no
// default is 'no'
// set Configuration to 'yes' to use cookie
// place an HTML comment <!-- donotswitch --> in the content of pages you don't want switched
// add template=templatename to the URL
if(!strstr($modx->documentContent, "donotswitch")) { // this page is not switchable
if (isset($_GET['template'])) {
$overrideTemplate = $_GET['template'];
} else if (isset($_COOKIE['template']) && $usecookie == 'yes') {
$overrideTemplate = $_COOKIE['template'];
}
if (isset($overrideTemplate)) {
$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'];
} else {
$this->messageQuit("Error retrieving template.");
}
if($usecookie == 'yes') {
setcookie("template",$overrideTemplate,time()+604800, "/", "", 0);
}
}
} // end if page is switchable