Skip to content

Instantly share code, notes, and snippets.

@webinmd
Created May 22, 2019 17:42
Show Gist options
  • Save webinmd/3d5ff0904d983b68adbd58cbcf85bd10 to your computer and use it in GitHub Desktop.
Save webinmd/3d5ff0904d983b68adbd58cbcf85bd10 to your computer and use it in GitHub Desktop.
Создает настройки, чанки и поля после установки modx
<?php
require_once dirname(__FILE__).'/config.core.php';
include_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx= new modX();
$modx->initialize('mgr');
$modx->setLogLevel(modX::LOG_LEVEL_INFO);
$modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');
header("Content-type: text/plain");
// Settings
$settings = array(
'publish_default' => 1
,'cache_resource' => 0
, 'topmenu_show_descriptions' => 0
//url
, 'automatic_alias' => 1
, 'friendly_urls' => 1
, 'global_duplicate_uri_check' => 1
, 'use_alias_path' => 1
, 'friendly_alias_translit' => 'russian'
, 'ace.font_size' => '14px'
, 'ace.theme' => 'monokai'
, 'admintools_enable_favorite_elements' => 0
, 'admintools_enable_notes' => 0
, 'admintools_alternative_permissions' => 0
, 'admintools_check_elements_permissions' => 0
, 'admintools_plugins_events' => 0
, 'seopro.allowbranding' => 0
, 'seopro.delimiter' => ' - '
, 'seopro.fields' => 'pagetitle:70,longtitle:70,description:155'
, 'pdotools_fenom_parser' => 1
, 'frontendmanager_frontend_position' => 'bottom'
, 'feed_modx_news_enabled' => 0
, 'feed_modx_security_enabled' => 0
, 'pdotools_elements_path' => '{assets_path}template/tpl/'
);
foreach ($settings as $k => $v) {
$opt = $modx->getObject('modSystemSetting', array('key' => $k));
if (!empty($opt)){
$opt->set('value', $v);
$opt->save();
echo 'edited '.$k.' = '.$v."\n";
} else {
$newOpt = $modx->newObject('modSystemSetting');
$newOpt->set('key', $k);
$newOpt->set('value', $v);
$newOpt->save();
echo 'added '.$k.' = '.$v."\n";
}
}
// Resources
$resources = array(
array('pagetitle' => 'sitemap',
'template' => 0,
'published' => 1,
'hidemenu' => 1,
'alias' => 'sitemap'
,'content_type' => 2,
'richtext' => 0,
'content' =>"{'!pdoSitemap'|snippet: [ 'checkPermissions' => 'list' ] }",
'menuindex' => 999998
)
, array('pagetitle' => 'robots',
'template' => 0,
'published' => 1,
'hidemenu' => 1,
'alias' => 'robots',
'content_type' => 3,
'richtext' => 0,
'content' => 'User-agent: *
Disallow: /manager/
Disallow: /assets/components/
Allow: /assets/uploads/
Disallow: /core/
Disallow: /connectors/
Disallow: /index.php
Disallow: /search
Disallow: /profile/
Disallow: *?
Host: [[++site_url]]
Sitemap: [[++site_url]]sitemap.xml' ,
'menuindex' => 999997
)
, array('pagetitle' => '404',
'template' => 1,
'published' => 1,
'hidemenu' => 1,
'alias' => '404'
,'content_type' => 1,
'richtext' => 1,
'content' =>'Страница не найдена',
'menuindex' => 999996
)
);
foreach ($resources as $attr) {
$response = $modx->runProcessor('resource/create', $attr);
}
// chunks
/*
$chunks = array(
array(
'name' => 'head'
)
,array(
'name' => 'HEADER'
)
,array(
'name' => 'FOOTER'
)
);
foreach ($chunks as $attr) {
$chunk = $modx->newObject('modChunk');
$chunk->set('name',$attr['name']);
$chunk->save();
}
*/
// tvs
/*
$tvs = array(
array(
'name' => 'img',
'caption' => 'Изображение',
'type' => 'image'
)
);
foreach ($tvs as $attr) {
$response = $modx->runProcessor('element/tv/create', $attr);
}
*/
$modx->cacheManager->refresh();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment