本文整理汇总了PHP中modX::runSnippet方法的典型用法代码示例。如果您正苦于以下问题:PHP modX::runSnippet方法的具体用法?PHP modX::runSnippet怎么用?PHP modX::runSnippet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modX
的用法示例。
在下文中一共展示了modX::runSnippet方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: redirectToFirst
/**
* Redirect user to the first page of pagination
*
* @param $isAjax
*
* @return string
*/
public function redirectToFirst($isAjax = false)
{
unset($_GET[$this->pdoTools->config['pageVarKey']]);
unset($_GET[$this->modx->getOption('request_param_alias', null, 'q')]);
if (!$isAjax) {
$this->modx->sendRedirect($this->modx->makeUrl($this->modx->resource->id, $this->modx->context->key, $_GET, 'full'));
return '';
} else {
$_GET[$this->pdoTools->config['pageVarKey']] = 1;
$_REQUEST = $_GET;
return $this->modx->runSnippet('pdoPage', $this->pdoTools->config);
}
}
示例2: modX
<?php
require_once '../../../core/config/config.inc.php';
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('mgr');
$modx->getService('error', 'error.modError', '', '');
set_include_path(MODX_CORE_PATH . '../php/');
require_once 'lib/testing/assert_extension.php';
$result = $modx->runSnippet('getGalAlbumIdsByName', array('name' => 11));
$total = sizeof($result);
assert('$total == 0', 'getGalAlbumIdsByName :: Просто число вместо имени.');
//----------------------------------------------------------------------------
$result = $modx->runSnippet('getGalAlbumIdsByName', array('name' => 'wrong name'));
$total = sizeof($result);
assert('$total == 0', 'getGalAlbumIdsByName :: Нет такого имени альбома.');
//----------------------------------------------------------------------------
$result = $modx->runSnippet('getGalAlbumIdsByName', array('name' => 'test1'));
$total = sizeof($result);
$id = $result[0];
assert('$total == 2', 'getGalAlbumIdsByName :: Два альбома с один именем.');
assert('($id == 4)||($id == 5)', 'getGalAlbumIdsByName :: id альбомов 4 и 5.');
//----------------------------------------------------------------------------
$result = $modx->runSnippet('getGalAlbumIdsByName', array('name' => 'test2'));
$total = sizeof($result);
$id = $result[0];
assert('$total == 1', 'getGalAlbumIdsByName :: Только 1 альбом.');
assert('$id == 7', 'getGalAlbumIdsByName :: id альбома 7.');
//----------------------------------------------------------------------------
if ($errors_total == 0) {
echo 'All tests passed.';
示例3: checkAuth
/**
* Runs snippet that checks permission of user to upload files
*
* @return bool|string
*/
function checkAuth()
{
return !empty($this->config['authSnippet']) ? $this->modx->runSnippet($this->config['authSnippet'], $this->config) : true;
}
示例4: tagManagerBase
$modx->resource = $modx->getObject('modResource', $criteria);
if (!is_object($modx->resource) || !$modx->resource->checkPolicy('view')) {
echo json_encode($output);
exit;
}
$modx->resourceIdentifier = $modx->resource->get('id');
$modx->getService('error', 'error.modError');
$modx->getRequest();
$modx->getParser();
$modx->resourceMethod = 'id';
$modx->resource->_contextKey = $modx->context->get('key');
$modx->invokeEvent('OnLoadWebDocument');
require_once MODX_CORE_PATH . "components/tag_manager2/model/tm_base.class.php";
$tag_manager = new tagManagerBase($modx);
$properties = $tag_manager->getSnippetProperties();
$output['prod_list'] = $modx->runSnippet('tmCatalog', $properties);
$output['prod_list'] .= '<div class="clearfix"></div>';
$output['onPageLimit'] = intval($properties['limit']);
if (isset($modx->placeholders[$properties['pageNavVar']])) {
$output['pages'] = $modx->placeholders[$properties['pageNavVar']];
if (isset($modx->sanitizePatterns['tags1'])) {
$output['pages'] = preg_replace($modx->sanitizePatterns['tags1'], '', $output['pages']);
}
if (isset($modx->sanitizePatterns['tags2'])) {
$output['pages'] = preg_replace($modx->sanitizePatterns['tags2'], '', $output['pages']);
}
}
if (isset($modx->placeholders['pageCount'])) {
$output['pageCount'] = $modx->placeholders['pageCount'];
}
if (isset($modx->placeholders[$properties['totalVar']])) {
示例5: define
/* be sure this has a trailing slash */
define('MODX_CORE_PATH', dirname(dirname(dirname(dirname(__FILE__)))) . '/');
}
/* get the MODX class file */
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
/* instantiate the $modx object */
$modx = new modX();
if (!$modx || !$modx instanceof modX) {
echo 'Could not create MODX class';
}
/* initialize MODX and set current context */
$modx->initialize('web');
/* load the error handler */
$modx->getService('error', 'error.modError', '', '');
/* Set up logging */
$modx->setLogLevel(xPDO::LOG_LEVEL_INFO);
/* Set log target */
$modx->setLogTarget('ECHO');
// Is CronJob allowed?
if ($modx->getOption($pkg . '.use_cronjob') && $modx->getOption($pkg . '.activated') && $modx->getOption($pkg . '.seofriendly')) {
// Clear Cache
//$cm = $modx->getCacheManager();
//$cm->refresh();
// Run Import Snippet - Cached Version
$modx->runSnippet($pkg . '_import', array());
exit(1);
}
exit(0);
}
echo 'This is an command line script for cronjobs';
exit(0);