© Сделано на LiveStreet
Дизайн - ©2009 MODx RED Group
Много замечаю в коде, по старинке все используют конструкцию $modx->cacheManager->clearCache();. Хочу напомнить, ClearCache () является устаревшим методом работы с кэшем, в Рево 2,1 и выше появилась возможность не очищать весь кэшь, а обновлять $modx->cacheManager->refresh();xmpp:modx@conference.jabber.ru
<?php
if(!isset($id)) $id = 2;
if(!isset($level)) $level = 1;
if ($level > 1){
$tblsc = $modx->getFullTableName('site_content');
$access = "AND lvl{$level}.deleted=0 AND lvl{$level}.published=1";
$inner = '';
for ($i = $level-1; $i > 0; --$i){
$nextlvl = $i+1;
$inner .= "INNER JOIN $tblsc AS lvl{$i} ON lvl{$nextlvl}.parent=lvl{$i}.id AND lvl{$i}.deleted=0 AND lvl{$i}.published=1 ";
}
$sql = "SELECT lvl{$level}.id FROM $tblsc AS lvl{$level} " . $inner . "WHERE lvl1.parent=$id $access;";
$res = $modx->db->query($sql);
$children = array();
while($childId = $modx->db->getValue($res)){
$children[] = $childId;
}
}
else{
$children = $modx->getChildIds($id, 1);
}
return implode(',', $children);
?><?php
if(!isset($id)) $id = 2;
if(!isset($level)) $level = 5;
if($level>2) {
if(!function_exists('LevelChildren')){
function LevelChildren($docId, $levels){
global $modx;
$tblsc = $modx->getFullTableName('site_content');
$access = "AND lvl{$levels}.deleted=0 AND lvl{$levels}.published=1";
$inner = '';
for ($i = $levels-1; $i > 1; --$i){
$nextlvl = $i+1;
$inner .= "INNER JOIN $tblsc AS lvl{$i} ON lvl{$nextlvl}.parent=lvl{$i}.id AND lvl{$i}.deleted=0 AND lvl{$i}.published=1 ";
}
$sql = "SELECT lvl{$levels}.* FROM $tblsc AS lvl{$levels} " .
$inner .
"WHERE lvl2.parent=$docId $access;";
$res = $modx->db->query($sql);
$res = $modx->db->makeArray($res);
foreach($res as $v) {
$child[] = $v['id'];
}
return implode(",",$child);
}
}
$levelID = LevelChildren($id,$level);
return $levelID;
}
else { return '';}
?>$array1 = $modx->getChildIds($parent,$depth);
$array2 = $modx->getChildIds($parent,$depth-1);
$childParents = array_diff($array1, $array2);
INSERT INTO `modx_system_eventnames` (`id`, `name`, `service`, `groupname`)
VALUES
(1052, 'OnBeforeDocMove', 5, ''),
(1053, 'OnDocMove', 5, '')// invoke OnBeforeDocMove event
$modx->invokeEvent("OnBeforeDocMove",
array(
'id' => $_REQUEST['id'],
'new_parent' => $_REQUEST['new_parent']
));// invoke OnDocMove event
$modx->invokeEvent("OnDocMove",
array(
'id' => $_REQUEST['id'],
'new_parent' => $_REQUEST['new_parent']
));
Игрушка… www.crudsquad.org/modx/xpdogenerator,','=>'','?'=>'','!'=>'','"'=>'','@'=>'','%'=>'','$'=>'',
'#'=>'',';'=>'',':'=>'','&'=>'','='=>'','('=>'',')'=>'','+'=>'','/'=>'','}'=>'','{'=>'',']'=>'',
'['=>'','*'=>'','`'=>'','~'=>'','№'=>''

<?php
$mode = isset($mode) ? $mode : 'show';
$outerTpl = isset($outerTpl) ? $outerTpl : '@CODE: <h1>Вы уже смотрели:</h1><ul class="[+outer-class+]">[+rows+]</ul>';
$outerClass = isset($outerClass) ? $outerClass : 'last-view';
$rowTpl = isset($rowTpl) ? $rowTpl : '@CODE: <li><a href="[+url+]">[+name+]</a></li>';
$maxRows = isset($maxRows) ? $maxRows : 10;
if(!function_exists('fetchTpl')) {
function fetchTpl($tpl){
global $modx;
$template = "";
if(substr($tpl, 0, 6) == "@FILE:") {
$tpl_file = MODX_BASE_PATH . substr($tpl, 6);
$template = file_get_contents($tpl_file);
} else if (substr($tpl, 0, 6) == "@CODE:") {
$template = substr($tpl, 6);
} else if($modx->getChunk($tpl) != "") {
$template = $modx->getChunk($tpl);
} else {
$template = false;
}
return $template;
}
}
if(!function_exists('parseTplChunk')) {
function parseTplChunk($tpl,$placeholder=array()){
$chunk = fetchTpl($tpl);
foreach ($placeholder as $key => $value){
$chunk = str_replace("[+".$key."+]", $value, $chunk);
}
return $chunk;
}
}
$item = array();
if (isset($_COOKIE['last_view']) and $_COOKIE['last_view'] != '') {
$item = explode(',', $_COOKIE['last_view']);
}
switch ($mode) {
case 'register':
if (!in_array($modx->documentIdentifier, $item)) {
if (count($item) >= $maxRows) {
array_shift($item);
array_unshift($item, $modx->documentIdentifier);
} else {
array_unshift($item, $modx->documentIdentifier);
}
setcookie('last_view', implode(',', $item), time()+60*60*24*30, '/');
}
break;
case 'show':
if (!empty($item)) {
$docs = $modx->getDocuments($item);
$output = '';
foreach ($docs as $doc) {
$rows .= parseTplChunk($rowTpl, array('url'=>$modx->makeUrl($doc['id']), 'name'=>$doc['pagetitle']));
}
return parseTplChunk($outerTpl, array('rows'=>$rows, 'outer-class'=>$outerClass));
}
break;
}
?>$rows .= parseTplChunk($rowTpl, array('url'=>$modx->makeUrl($doc['id']), 'name'=>$doc['pagetitle'], 'image'=>$modx->getTemplateVar('img_product_home')));Array
SELECT `modResource`.`id` AS `modResource_id`, `modResource`.`type` AS `modResource_type FROM `site_content` AS `modResource` WHERE `modResource`.`FROM_UNIXTIME(`publishedon`,"%Y")` = '2011' <div class="img_for_statii">
<a href="[[~[[+id]]]]">[[*img_for_statii]]</a>
</div>@EVAL return $modx->evalSnippets("[[SqlFilter?&Docfield=`id`&filterTV =`filter_1_parameter,$_GET['pagetitle']|filter_2_sostav,$_GET['pagetitle']`&mode=`OR`]]");