© Сделано на LiveStreet
Дизайн - ©2009 MODx RED Group
Много замечаю в коде, по старинке все используют конструкцию $modx->cacheManager->clearCache();. Хочу напомнить, ClearCache () является устаревшим методом работы с кэшем, в Рево 2,1 и выше появилась возможность не очищать весь кэшь, а обновлять $modx->cacheManager->refresh();xmpp:modx@conference.jabber.ru
<?php
/*[[SqlFilter?&Docfield=`id`&filterTV =`filter_1_parameter,перкаль|filter_2_sostav,хлопок|DescriptionName1,белый`&mode=`OR`]]
* &tvReturnName=`image` //какое ТВ возвращать
* &filterTV =`filter_1_parameter,перкаль|filter_2_sostav,хлопок|DescriptionName1,белый` //имя ТВ
* &mode=`OR` // можно через AND, можно через OR
* &parentId=`2`// ID родителя, задается опционально
* &limit=`50`; // ограничение
* &Docfield=`id` // опционально одновременно можно вызывать либо tvReturnName либо Docfield
* @EVAL $pt=$modx->getDocument($docid,'pagetitle'); return $modx->evalSnippets("[[SqlFilter?&Docfield=`id`&filterTV =`filter_1_parameter,{$pt['pagetitle']}|filter_2_sostav,{$pt['pagetitle']}`&mode=`OR`]]");
*/
if(!isset($filterTV)) $filterTV = 'filter_1_parameter,перкаль|filter_2_sostav,хлопок'; // - имя 1 тв по которой фильтровать, значение филтра
if(!isset($mode))$mode="OR";
$limit = isset($limit) ? $limit=" LIMIT ".$limit.";" : ';';
$parentId =isset($parentId) ? $parentId: false;
$request="";
$where="";
$select_fields = "SELECT ";
$content_base = $modx->getFullTableName('site_content');
$site_tv_vals = $modx->getFullTableName('site_tmplvar_contentvalues');
$site_tv=$modx->getFullTableName('site_tmplvars');
$query=" FROM $content_base as sc ";
$FilterArr=explode("|", $filterTV);
$num=0;
foreach($FilterArr as $param) {
$Filter=explode(",", $param);
$inputTVname=$Filter[0];
$f_val = $Filter[1];
$query.="LEFT JOIN ($site_tv as tv{$num}, $site_tv_vals as tv{$num}val) ".
"ON tv{$num}.id=tv{$num}val.tmplvarid and tv{$num}val.contentid=sc.id and tv{$num}.name='$inputTVname' ";
if ($num>0){$where.=" $mode ";}
$where.="tv{$num}val.value='{$f_val}'";
$num++;
}
if ($parentId){
$where="(".$where.")";
$children = $modx->getChildIds($parentId, 10);
$where .= ' AND sc.id IN ('.implode(',', $children) . ') ';
}
$where="WHERE ".$where." GROUP BY sc.id";
if(isset($tvReturnName)) {
$query.="INNER JOIN ($site_tv as tvreturn, $site_tv_vals as tvreturnval) ".
"ON tvreturn.id=tvreturnval.tmplvarid and tvreturnval.contentid=sc.id and tvreturn.name='$tvReturnName' ";
$select_fields.="tvreturnval.value";
}
elseif (isset($Docfield)) {$select_fields.="sc.{$Docfield}";}
else return'';
$request = $modx->db->query($select_fields.$query.$where.$limit);
//$result = $modx->db->makeArray($request);
$result = array();
while($v = $modx->db->getValue($request)){
$result[] = $v;
}
return implode(',', $result);
?><?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']
));<?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
Игрушка… www.crudsquad.org/modx/xpdogenerator,','=>'','?'=>'','!'=>'','"'=>'','@'=>'','%'=>'','$'=>'',
'#'=>'',';'=>'',':'=>'','&'=>'','='=>'','('=>'',')'=>'','+'=>'','/'=>'','}'=>'','{'=>'',']'=>'',
'['=>'','*'=>'','`'=>'','~'=>'','№'=>''

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>