В ваших проектах наверняка есть куча шаблонов, чанков и полей. Наверняка есть категории, правила именования и так далее. Не могли бы вы поделиться сим ценным опытом
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>[[++site_name]] - [[*pagetitle]]</title> <base href="[[++site_url]]" /> [[$myIncludeCSS? &name=`jquery-ui-1.9.1`]] [[$myIncludeCSS? &name=`common`]] [[$myIncludeCSS? &name=`ucp`]] [[$myIncludeCSS? &name=`login`]] [[$myIncludeCSS? &name=`mainpage`]] [[$myIncludeCSS? &name=`container`]] [[$myIncludeCSS? &name=`comments`]] <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.0/jquery-ui.min.js"></script> </head> <body> [[$myKovchegTemplateBegin]] [[*content]] [[$myKovchegTemplateEnd]] </body> </html>
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> [[$HEAD]] </head> <body> <!--header_wrap-start--> <div id="header_wrap"> <!--header-start--> <div id="header"> [[$Header]] </div> <!--header-end--> </div> <div class="greenline"></div> <!--header_wrap-end--> <div class="banner"> <div class="banner_left"> [[$Menu.Slider]] </div> <div class="banner_right"> [[$Menu.top]] </div> <div class="clrflt"> </div> <div class="margin5"> </div> <div class="greenline"></div> <div class="clrflt"> </div> <div class="margin3"> </div> <marquee loop="infinite" behavior="altemate" bgcolor="#14601e" direction="left" height="23" width="100%" scrollamount="3" style="color:#fff; font-size:1.1em; padding:7px 0 0 0; font-family:Georgia, Times New Roman, Times, serif; font-style:italic; ">[[$Stroka]]</marquee> <div class="clrflt"> </div> </div> <!--banner-end--> <div id="content"> <!--content-start--> [[$Menu.left]] <div class="content_right fltright"> <div class="right_box1"> <!--div class="right_box1_left fltleft"><img src="inc/img/right_box1_pic.png" alt="" width="187" height="187" /></div--> <!--div class="right_box1_right fltright"--> [[*content]] <a href="[[~4]]">Узнать больше</a> <!--div class="clrflt"> </div> </div--> <div class="clrflt"> </div> </div> <div class="right_box2"> <h2>Наш коллектив</h2> <div class="infiniteCarousel"> <div class="wrapper"> <ul> [[getResources? &parents=`45` &tpl=`tpl.gR.Slider_foto.row` &includeTVs=`1` &processTVs=`1` &tvPrefix=`` &hideContainers=`1` &limit=`0` &sortdir=`ASC` &sortby=`[[getResourcesTree? &parents=`45` &depth=`100`]]` &tvFilters=`show_in_carusel==on` ]] </ul> </div> </div> <!-- --> </div> <div class="right_box3"> [[$Block_news]] [[$Block_Article]] <div class="clrflt"> </div> </div> <div class="clrflt"> </div> </div> <!--content-end--> <!--footer-start--> <div id="footer"> [[$Footer]] </div> <!--footer-end--> </body> </html>
$docs = $modx->getCollection('modResource', array( 'parent' => $modx->getOption('site_start') ));
$context = $modx->getContext('web'); $contextConfig = $context->config;
Array ( [0] => 500 [1] => 331 [2] => 2 [3] => width="500" height="331" [bits] => 8 [channels] => 3 [mime] => image/jpeg )
public function failure($message = '', $object = null) { return $this->process($message, false, $object); }
public function process($message = '', $status = false, $object = null) { if (isset($this->modx->registry) && $this->modx->registry->isLogging()) { $this->modx->registry->resetLogging(); }
public function resetLogging() { if ($this->_loggingRegister && $this->_prevLogTarget && $this->_prevLogLevel) { $this->modx->setLogTarget($this->_prevLogTarget); $this->modx->setLogLevel($this->_prevLogLevel); $this->_loggingRegister = null; } }
$LogTarget = $modx->getLogTarget(); $LogTopic = $LogTarget->subscriptions[0]; /* processor_code */ $modx->runProcessor($processor); $modx->registry->setLogging($LogTarget, $LogTopic);
$LogTarget = $modx->getLogTarget(); $LogTopic = $LogTarget->subscriptions[0]; /* processor_code */ $modx->runProcessor($processor); $modx->registry->setLogging($LogTarget, $LogTopic); $LogTarget = $modx->getLogTarget(); $LogTopic = $LogTarget->subscriptions[0]; /* processor_code */ $modx->runProcessor($processor); $modx->registry->setLogging($LogTarget, $LogTopic);
public function setLogging(modRegister &$register, $topic, $level = modX::LOG_LEVEL_ERROR)
Не могли бы вы помочь мне с Рево — никак не могу найти тегов для вывода статистики по рендерингу страницы. Из Ево сработало часть: [^qt^] - время на запросы к базе данных [^q^] - запросов к базе данных [^p^] - время на работу PHP скриптов [^t^] - общее время на генерацию страницы [^s^] - источник содержимого (база или кэш) только 2 последних. А мне бы хотелось узнать сколько нужно памяти для рево и время генерации страницы поскольку балуюсь на локалке.
$out= str_replace("[^q^]", $queries, $out); $out= str_replace("[^qt^]", $queryTime, $out); $out= str_replace("[^p^]", $phpTime, $out); $out= str_replace("[^t^]", $totalTime, $out); $out= str_replace("[^s^]", $source, $out);
$this->modx->resource->_output= str_replace("[^q^]", $queries, $this->modx->resource->_output); $this->modx->resource->_output= str_replace("[^qt^]", $queryTime, $this->modx->resource->_output); $this->modx->resource->_output= str_replace("[^p^]", $phpTime, $this->modx->resource->_output); $this->modx->resource->_output= str_replace("[^t^]", $totalTime, $this->modx->resource->_output); $this->modx->resource->_output= str_replace("[^s^]", $source, $this->modx->resource->_output);
$tstart = $modx->getMicroTime(); if (!$result = @ mysql_query($sql, $this->conn)) { $modx->messageQuit("Execution of a query to the database failed - " . $this->getLastError(), $sql); } else { $tend = $modx->getMicroTime(); $totaltime = $tend - $tstart; $modx->queryTime = $modx->queryTime + $totaltime; if ($modx->dumpSQL) { $modx->queryCode .= "<fieldset style='text-align:left'><legend>Query " . ($this->executedQueries + 1) . " - " . sprintf("%2.4f s", $totaltime) . "</legend>" . $sql . "</fieldset><br />"; } $modx->executedQueries = $modx->executedQueries + 1; return $result; }
public function getCollection($className, $criteria= null, $cacheFlag= true) { return $this->call($className, 'loadCollection', array(& $this, $className, $criteria, $cacheFlag)); }
$rows= xPDOObject :: _loadRows($xpdo, $className, $criteria);
public static function & _loadRows(& $xpdo, $className, $criteria) { $rows= null; if ($criteria->prepare()) { if ($xpdo->getDebug() === true) $xpdo->log(xPDO::LOG_LEVEL_DEBUG, "Attempting to execute query using PDO statement object: " . print_r($criteria->sql, true) . print_r($criteria->bindings, true)); $tstart= $xpdo->getMicroTime(); if (!$criteria->stmt->execute()) { $tend= $xpdo->getMicroTime(); $totaltime= $tend - $tstart; $xpdo->queryTime= $xpdo->queryTime + $totaltime; $xpdo->executedQueries= $xpdo->executedQueries + 1; $errorInfo= $criteria->stmt->errorInfo(); $xpdo->log(xPDO::LOG_LEVEL_ERROR, 'Error ' . $criteria->stmt->errorCode() . " executing statement: \n" . print_r($errorInfo, true)); if (($errorInfo[1] == '1146' || $errorInfo[1] == '1') && $xpdo->getOption(xPDO::OPT_AUTO_CREATE_TABLES)) { if ($xpdo->getManager() && $xpdo->manager->createObjectContainer($className)) { $tstart= $xpdo->getMicroTime(); if (!$criteria->stmt->execute()) { $xpdo->log(xPDO::LOG_LEVEL_ERROR, "Error " . $criteria->stmt->errorCode() . " executing statement: \n" . print_r($criteria->stmt->errorInfo(), true)); } $tend= $xpdo->getMicroTime(); $totaltime= $tend - $tstart; $xpdo->queryTime= $xpdo->queryTime + $totaltime; $xpdo->executedQueries= $xpdo->executedQueries + 1; } else { $xpdo->log(xPDO::LOG_LEVEL_ERROR, "Error " . $xpdo->errorCode() . " attempting to create object container for class {$className}:\n" . print_r($xpdo->errorInfo(), true)); } } } $rows= & $criteria->stmt; } else { $errorInfo = $xpdo->errorInfo(); $xpdo->log(xPDO::LOG_LEVEL_ERROR, "Error preparing statement for query: {$criteria->sql} - " . print_r($errorInfo, true)); if (($errorInfo[1] == '1146' || $errorInfo[1] == '1') && $xpdo->getOption(xPDO::OPT_AUTO_CREATE_TABLES)) { if ($xpdo->getManager() && $xpdo->manager->createObjectContainer($className)) { if (!$criteria->prepare()) { $xpdo->log(xPDO::LOG_LEVEL_ERROR, "Error preparing statement for query: {$criteria->sql} - " . print_r($errorInfo, true)); } else { $tstart= $xpdo->getMicroTime(); if (!$criteria->stmt->execute()) { $xpdo->log(xPDO::LOG_LEVEL_ERROR, "Error " . $criteria->stmt->errorCode() . " executing statement: \n" . print_r($criteria->stmt->errorInfo(), true)); } $tend= $xpdo->getMicroTime(); $totaltime= $tend - $tstart; $xpdo->queryTime= $xpdo->queryTime + $totaltime; $xpdo->executedQueries= $xpdo->executedQueries + 1; } } else { $xpdo->log(xPDO::LOG_LEVEL_ERROR, "Error " . $xpdo->errorCode() . " attempting to create object container for class {$className}:\n" . print_r($xpdo->errorInfo(), true)); } } } return $rows; }
$q = $modx->newQuery('modResource'); $q->where(array( 'id' => 5, )); $docs = $modx->getCollection('modResource', $q);
Query Time: 0.0000 s Request: 0 PHP Exec: 0.0760 s Total time: 0.0760 s
$q = $modx->newQuery('modResource'); $q->where(array( 'idddddddddddddd' => 5, )); $docs = $modx->getCollection('modResource', $q);
Query Time: 0.0000 s Request: 1 PHP Exec: 0.0800 s Total time: 0.0800 s
if ($criteria->prepare()) { if ($xpdo->getDebug() === true) $xpdo->log(xPDO::LOG_LEVEL_DEBUG, "Attempting to execute query using PDO statement object: " . print_r($criteria->sql, true) . print_r($criteria->bindings, true)); $tstart= $xpdo->getMicroTime(); if (!$criteria->stmt->execute()) { $errorInfo= $criteria->stmt->errorInfo(); $xpdo->log(xPDO::LOG_LEVEL_ERROR, 'Error ' . $criteria->stmt->errorCode() . " executing statement: \n" . print_r($errorInfo, true)); if (($errorInfo[1] == '1146' || $errorInfo[1] == '1') && $xpdo->getOption(xPDO::OPT_AUTO_CREATE_TABLES)) { if ($xpdo->getManager() && $xpdo->manager->createObjectContainer($className)) { if (!$criteria->stmt->execute()) { $xpdo->log(xPDO::LOG_LEVEL_ERROR, "Error " . $criteria->stmt->errorCode() . " executing statement: \n" . print_r($criteria->stmt->errorInfo(), true)); } } else { $xpdo->log(xPDO::LOG_LEVEL_ERROR, "Error " . $xpdo->errorCode() . " attempting to create object container for class {$className}:\n" . print_r($xpdo->errorInfo(), true)); } } } $tend= $xpdo->getMicroTime(); $totaltime= $tend - $tstart; $xpdo->queryTime= $xpdo->queryTime + $totaltime; $xpdo->executedQueries= $xpdo->executedQueries + 1; $rows= & $criteria->stmt; }
Query Time: 0.0000 s Request: 7 PHP Exec: 0.0680 s Total time: 0.0680 s
public static function loadCollectionGraph(xPDO & $xpdo, $className, $graph, $criteria, $cacheFlag) { $objCollection = array(); if ($query= $xpdo->newQuery($className, $criteria, $cacheFlag)) { $query = $xpdo->addDerivativeCriteria($className, $query); $query->bindGraph($graph); $rows = array(); $fromCache = false; $collectionCaching = (integer) $xpdo->getOption(xPDO::OPT_CACHE_DB_COLLECTIONS, array(), 1); if ($collectionCaching > 0 && $xpdo->_cacheEnabled && $cacheFlag) { $rows= $xpdo->fromCache($query); $fromCache = !empty($rows); } if (!$fromCache) { if ($query->prepare()) { if ($query->stmt->execute()) { $objCollection= $query->hydrateGraph($query->stmt, $cacheFlag); } else { $xpdo->log(xPDO::LOG_LEVEL_ERROR, "Error {$query->stmt->errorCode()} executing query: {$query->sql} - " . print_r($query->stmt->errorInfo(), true)); } } else { $xpdo->log(xPDO::LOG_LEVEL_ERROR, "Error {$xpdo->errorCode()} preparing statement: {$query->sql} - " . print_r($xpdo->errorInfo(), true)); } } elseif (!empty($rows)) { $objCollection= $query->hydrateGraph($rows, $cacheFlag); } } return $objCollection; }
public function exec($query) { if (!$this->connect(null, array(xPDO::OPT_CONN_MUTABLE => true))) { return false; } $tstart= $this->getMicroTime(); $return= $this->pdo->exec($query); $tend= $this->getMicroTime(); $totaltime= $tend - $tstart; $this->queryTime= $this->queryTime + $totaltime; $this->executedQueries= $this->executedQueries + 1; return $return; }
$q = $modx->newQuery('modResource'); $q->prepare(); $sql = $q->toSQL(); $modx->exec($sql); $modx->exec($sql); $modx->exec($sql);
Query Time: 0.0040 s Request: 10 PHP Exec: 0.0680 s Total time: 0.0720 s
$sql = array( select => "a.*, ah.description, ah.conditions, ah.features, ah.action_end, ah.full_price, ah.discount, ah.sale_price, ah.cost_discount, adrs.name as firmname, (select act.cat_cat_id from ".self::$tables['actions_categories']." as act where act.action_action_id = a.action_id limit 1) as cat_id, (select cat.name from ".self::$tables['actions_categories']." as act join ".self::$tables['categories']." as cat on cat.cat_id = act.cat_cat_id where act.action_action_id = a.action_id limit 1) as category, c.pagetitle, c.longtitle, c.id, c.uri, cp.id as partnerDocID, cp.uri as partnerDocUri, cp.published as parentIsPublished, cp.deleted as parentIsDeleted, cp.hidemenu as parentIsHideMenu, ai.value as action_image, pi.value as partner_logo, (select count(*) from ".self::$tables['user_cupon']." as uc where uc.action_action_id = a.action_id) as bought, metro.station as metro", from => self::$tables['actions']." as a join ".self::$tables['actions_history']." ah ON ah.action_action_id = a.action_id and ah.actstat_actstat_id = 5 and now() between ah.start_date and ah.end_date AND NOW() < ah.action_end join ".self::$tables['actions_status']." as `as` on `as`.actstat_id = ah.actstat_actstat_id join ".self::$tables['partners']." as p on p.partner_id = a.partner_partner_id join ".self::$tables['partners_history']." as ph on ph.partner_partner_id = p.partner_id and now() between ph.start_date and ph.end_date join ".self::$tables['partners_statuses']." as ps on ps.partstatus_id = ph.partstatus_partstatus_id". " join ".self::$tables['catalog_content']." as cc on cc.action_action_id = a.action_id join ".self::$tables['catalog_content']." as ccp on ccp.partner_partner_id = p.partner_id join ".self::$tables['site_content']." as c on cc.cont_cont_id = c.id and c.published = 1 and c.hidemenu = 0 and c.deleted = 0 join ".self::$tables['tv_values']." as ai on ai.contentid = c.id and ai.tmplvarid = ".self::$TVs['actionImg']." left join (select aa.action_action_id, adh.name from ".self::$tables['addresses']." as ca join ".self::$tables['addresses_history']." as adh on adh.adrs_adrs_id = ca.adrs_id and adh.adrstat_adrstat_id = 1 and now() between adh.start_date and adh.end_date join ".self::$tables['actions_addresses']." as aa on ca.adrs_id = aa.adrs_adrs_id and aa.status = 1 and now() between aa.start_date and aa.end_date where adh.city in (". implode(",", $cities). ") {$adrs_where} group by aa.action_action_id ) as adrs on adrs.action_action_id = a.action_id left join ".self::$tables['site_content']." as cp on ccp.cont_cont_id = cp.id left join ".self::$tables['tv_values']." as pi on pi.contentid = cp.id and pi.tmplvarid = ".self::$TVs['partnerLogo']." left join ( SELECT caa.action_action_id, if(cm.complex_name is not null && cm.complex_name != '', cm.complex_name, cm.station) as station FROM modx_catalog_actions_addresses as caa join modx_catalog_metro_relations as cmr on cmr.adrs_adrs_id = caa.adrs_adrs_id join modx_catalog_metro as cm on cm.metro_id = cmr.metro_metro_id where now() between caa.start_date and caa.end_date group by 1 ) as metro on metro.action_action_id = a.action_id ". ($not_sended == true ? " left join modx_catalog_actions_sended as `asn` on `asn`.action_action_id = a.action_id ": "")." where `as`.status = 'Активна' and ps.status = 'Активный' and (adrs.action_action_id is not null OR ah.all_cities = '1') {$where} order by c.publishedon desc", limit => self::$limit, offset => self::$offset );
// Получаем города, которые используются для этого хоста $cities = self::get_host_cities(); $where = array( 'now() between ah.start_date and ah.end_date', 'ah.actstat_actstat_id' => 5, 'NOW() < ah.action_end', 'now() between ph.start_date and ph.end_date', 'ph.partstatus_partstatus_id' => 2, 'c.published' => 1, 'c.hidemenu' => 0, 'c.deleted' => 0, 'ai.tmplvarid' => self::$TVs['actionImg'], 'now() between aa.start_date and aa.end_date', 'aa.status' => 1, 'now() between adh.start_date and adh.end_date', ); $q = self::$modx->newQuery('Actions'); $q->select(array( 'Actions.*', 'ah.description', 'ah.conditions', 'ah.features', 'ah.action_end', 'ah.full_price', 'ah.discount', 'ah.sale_price', 'ah.cost_discount', 'adh.name as firmname', 'c.pagetitle', 'c.longtitle', 'c.id', 'c.uri', 'cp.id as partnerDocID', 'cp.uri as partnerDocUri', 'cp.published as parentIsPublished', 'cp.deleted as parentIsDeleted', 'cp.hidemenu as parentIsHideMenu', 'ai.value as action_image', 'pi.value as partner_logo', "if(cm.complex_name is not null && cm.complex_name != '', cm.complex_name, cm.station) as metro" )); $q->innerJoin('ActionsHistory', 'ah', 'ah.action_action_id = Actions.action_id'); $q->innerJoin('Partners', 'p', 'p.partner_id = Actions.partner_partner_id'); $q->innerJoin('PartnersHistory', 'ph', 'ph.partner_partner_id = p.partner_id'); $q->innerJoin('Content', 'cc', 'cc.action_action_id = Actions.action_id'); $q->innerJoin('Content', 'ccp', 'ccp.partner_partner_id = p.partner_id'); $q->innerJoin('modResource', 'c', 'cc.cont_cont_id = c.id'); $q->innerJoin('modResource', 'cp', 'ccp.cont_cont_id = cp.id'); $q->innerJoin('modTemplateVarResource', 'ai', 'ai.contentid = c.id'); $q->innerJoin('ActionsAddresses', 'aa', 'aa.action_action_id = Actions.action_id'); $q->innerJoin('AddressesHistory', 'adh', 'adh.adrs_adrs_id = aa.adrs_adrs_id'); $q->leftJoin('MetroRelations', 'cmr', 'cmr.adrs_adrs_id = aa.adrs_adrs_id'); $q->leftJoin('Metro', 'cm', 'cm.metro_id = cmr.metro_metro_id'); $q->leftJoin('modTemplateVarResource', 'pi', 'pi.contentid = cp.id AND pi.tmplvarid = '.self::$TVs['partnerLogo']); if($not_sended == true){ $q->leftJoin('ActionsSended', 'asn', 'asn.action_action_id = Actions.action_id'); $where['asn.actsnd_id'] = NULL; } $q->where($where); $q->andCondition( "(adh.city IN (".implode(",", $cities).") OR ah.all_cities = '1')" ); if($not_sended == false){ self::$rows = self::$modx->getCount('Actions', $q); $q->limit(self::$limit, self::$offset); } // Подсчитываем кол-во строк $q->groupby('Actions.action_id'); $q->sortby('c.publishedon', 'DESC'); if(!$q->prepare()){ return false; } if(!$q->stmt->execute()){ return false; } $result__ = $q->stmt->fetchAll(PDO::FETCH_ASSOC);
$object = $modx->getObject('object', $where); $object->fromArray($data); $object->save();
SELECT * FROM atable WHERE id=$parent AND id>(MIN+((MAX-MIN)/COUNT)*offset LIMIT numrows
$where = array( 'id' => $parent, 'id > (MIN+((MAX-MIN)/COUNT)*offset' )
$q = $modx->newQuery($class); $q->select($select); $q->where($where); $q->prepere(); <strong>print $q->toSQL();</strong>