Dec 04, 2008, 03:52 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
Search via SMF or Google: modx forums all of modxcms.com web
  MODxCMS.com   Forums   Help Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: [plugin] Inherit template from parent  (Read 5283 times)
0 Members and 1 Guest are viewing this topic.
netnoise
Coding Team
*
Posts: 212



WWW
« on: Oct 12, 2005, 08:15 AM »

I needed backend-function which automatically selects the template of the parent document (instead of using the system-wide default template) if the user creates a blank page. This is what I got - hope, this is kind of useful for someone:
Code:
global $content;
$e = &$modx->Event;

switch($e->name) {
  case 'OnDocFormPrerender':
    if(($_REQUEST['pid'] > 0) && ($id == 0)) {
      if($parent = $modx->getPageInfo($_REQUEST['pid'],0,'template')) {
        $content['template'] = $parent['template'];
      }
    }
    break;

  default:
    return;
    break;
}
Logged

rthrash
Foundation
*
Posts: 9,577



WWW
« Reply #1 on: Oct 12, 2005, 08:42 AM »

that's very cool indeed.
Logged

MODx is a framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Community participation and questions are encouraged, especially when you help us help you, read the wiki, and review snippet parameters – even if you have to look at the source. Searching the forums helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.
chanh
Guest
« Reply #2 on: Oct 12, 2005, 08:54 AM »

That is really cool but how do you use it!

Thanks
Logged
davidm
Marketing & Design Team
*
Posts: 6,779


The best way to predict the future is to invent it


WWW
« Reply #3 on: Jan 26, 2006, 12:57 PM »

Yeah, I thought it would automatically set the template of the parent when selecting "Create a document here" but it does not...

How do we use it ?
Logged

.: nodeo.net : Pour un web libre, moderne et ouvert ! :: david-molliere.net : Suivez en "live" mes expérimentations et billets sur les CMS et autres applications web :.

*** Forums modxcms.fr Participez à l'élaboration du site MODx francophone ! ***

! Nouveau !  En live, ne manquez pas les news de modxcms.fr sur Twitter   ! Nouveau !

MODx est l'outil idéal pour les developpeurs et webdesigners qui cherchent un framework de gestion de contenu hautement flexible et performant, tout en étant simple d'accès pour les utilisateurs finaux.

Config : Apache 2.2.8 - MySQL 5.0.45 - PHP 5.2.6 | Debian 4.0 (Etch)

Réalisations sous MODx : | pargade-notaires.fr | soleil.info | gican.asso.fr | michelez-notaires.com | amadom.gerondicap.com | jocelyne-violet.net
Djamoer
Testers
*
Posts: 1,492

No one can limit a man other than the man himself.


WWW
« Reply #4 on: Jan 26, 2006, 02:58 PM »

It work on mine though.
It will automatically set the default template according to the parent template, during the creation of new doc/folder on backend.
Logged

davidm
Marketing & Design Team
*
Posts: 6,779


The best way to predict the future is to invent it


WWW
« Reply #5 on: Jan 26, 2006, 02:59 PM »

I'll check then, it's probably me doing something wrong...
Logged

.: nodeo.net : Pour un web libre, moderne et ouvert ! :: david-molliere.net : Suivez en "live" mes expérimentations et billets sur les CMS et autres applications web :.

*** Forums modxcms.fr Participez à l'élaboration du site MODx francophone ! ***

! Nouveau !  En live, ne manquez pas les news de modxcms.fr sur Twitter   ! Nouveau !

MODx est l'outil idéal pour les developpeurs et webdesigners qui cherchent un framework de gestion de contenu hautement flexible et performant, tout en étant simple d'accès pour les utilisateurs finaux.

Config : Apache 2.2.8 - MySQL 5.0.45 - PHP 5.2.6 | Debian 4.0 (Etch)

Réalisations sous MODx : | pargade-notaires.fr | soleil.info | gican.asso.fr | michelez-notaires.com | amadom.gerondicap.com | jocelyne-violet.net
vbrilon
Coding Team
*
Posts: 256



« Reply #6 on: Feb 02, 2006, 10:41 PM »

Great code, thanks! Very useful stuff for multi-template site.

One additional instruction for using this (since it wasn't obvious to me): Look at the tab on the Plugin entry page that's labeled "System Events". Go into that tab and check "OnDocFormPrerender" on that page and then this works just fine.
Logged

rthrash
Foundation
*
Posts: 9,577



WWW
« Reply #7 on: Mar 11, 2006, 01:17 PM »

Nice indeed ... added as rev 725 for 0.9.2 release. Smiley
Logged

MODx is a framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Community participation and questions are encouraged, especially when you help us help you, read the wiki, and review snippet parameters – even if you have to look at the source. Searching the forums helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.
zenmaster
Full Member
***
Posts: 138


WWW
« Reply #8 on: May 13, 2006, 06:18 AM »

This is incorrectly credited to Ray Irving in 0.9.2, also the date is 12 Oct 2006.

I know Modx is the future, but that's stretching a point  Grin!
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP

Copyright © 2005-2008 MODxCMS, All rights reserved. Contact Us
Styles by ziworks.com

Powered by SMF 1.1.4 | SMF © 2005, Simple Machines LLC

Valid XHTML 1.0! Valid CSS!