Created
September 13, 2012 06:18
-
-
Save FuzzicalLogic/3712291 to your computer and use it in GitHub Desktop.
MODx Revolution: Allows you to "nest" a MODx Revolution Template within another MODx Revolution Template. Requires the use of a Template Switcher plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Requires an Template ID | |
if (empty($id)) | |
return ''; | |
else | |
{//Get the Template | |
$parent = $modx->getObject('modTemplate', $id); | |
// Must be a valid Template ID | |
if (empty($parent)) | |
return ''; | |
$parent = $parent->get('content'); | |
// Adjust the Child Content by removing the call. | |
$child = $modx->getObject('modTemplate', $modx->resource->get('template')); | |
$child = $child->get('content'); | |
$sansSnippet = preg_replace("/((?m)(!{0,1}\[\[!inheritTemplate\?{0,1}.{0,}\]\]))/", '', $child); | |
// Get the content | |
$adjusted = str_replace('[[*content]]', $sansSnippet, $parent); | |
$_REQUEST['inherited'] = $adjusted; | |
// Reset the already processed content | |
$output = $adjusted; | |
$modx->resource->_output = $output; | |
} | |
return $output; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment