The extension allows:
- make html blocks of html contents, files, images.
- make collections for options like tags, categories
- make entities for items like sliders, products, reviews, articles, pages
- support up to 5 languages
- support SEO meta tags
- make multiple menu with parenting feature
- remove first key property
- use first node of languages as firstKey
- Install with composer:
composer require afzalroq/yii2-cms "^1.0"
- After composer install run console command for create tables:
'controllerMap' => [
'migrate' => [
'class' => MigrateController::class,
'autoDiscover' => true,
'migrationPaths' => [
'@vendor/afzalroq/yii2-cms/migrations'
],
],
]
php yii migrate/up --migrationPath=@vendor/afzalroq/yii2-cms/migrations
CKEditor use Elfinder plugin for save files and images. Refer Elfinder readme for proper configuration
- Language indexes related with database columns.
- Admin panel tabs render by array values order
- For Items, Options and Menu must be isset common\models\User model
'modules' => [
'cms' => [ // don`t change module key
'class' => '@afzalroq\cms\Module',
// storage
'path' => $params['storageRoot'], // dirname(__DIR__, 2) . '/storage'
'host' => $params['storageHostInfo'], // 'https://site.example'
'cache' => 'cache', // default cache component name
'cacheDuration' => 3600, // default cache duration 3600 second
'optimized' => false, // set true for get items with options as $item->o
// images
'imageOperation' => 'cropResize',
'imageBackground' => 'transparent',
'imageXPos' => 'center',
'imageYPos' => 'center',
'fallback' => $params['storageRoot'] . '/fallback.png',
'watermark' => $params['storageRoot'] . '/logo.png',
// i18n
'languages' => [
'ru' => [
'id' => 0, // must start from 0 up to 4
'name' => 'English',
],
'en' => [
'id' => 1,
'name' => 'Русский',
],
'uz' => [
'id' => 2,
'name' => 'O`zbek tili',
],
],
// for add to menu controller actions
'menuActions' => [
'' => 'Home',
'site/contacts' => 'Contacts',
]
],
]
By default uses for caching component with name "cache". Config as belove:
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
'cachePath' => Yii::getAlias('@frontend') . '/runtime/cache'
],
]
- In admin panel open management via link:
/cms/home/index
$array = ['a', 'b'];
dd($array);
TODO
- test
- Copy from extension root directory example widgets for frontend integration
class CController extends CMSController {
public function actionCollection(string $c)
{
}
public function actionOption(string $c, string $o)
{
}
public function actionEntity(string $e)
{
}
public function actionItem(string $e, int $i)
{
}
}
Unit::get('slug'); // will return data using cache
\afzalroq\cms\entities\front\OaI::getItemIdsByCollection($slug) : array // of item Ids
\afzalroq\cms\entities\front\OaI::getItemIdsByOption($slug) : array // of item Ids
$item->getText1(); // for get Text 1
$item->getText2(); // for get Text 2
$item->getText3(); // for get Text 3
$item->getText4(); // for get Text 4
$item->getText5(); // for get Text 5
$item->getText6(); // for get Text 6
$item->getText7(); // for get Text 7
//for to get meta description and meta keywords just use this command below:
$item-registerMetaTags(); //it generates meta tags in your view page
$item->getFile1(); // for get File 1
$item->getFile2(); // for get File 2
$item->getFile3(); // for get File 3
$item->getDate($format); // for get date with format like "d.m.Y H:i:s"
// get gallery main photo URI
$item->getGalleryPhoto(width, height, operation, background, xPos, yPos)
// get gallery photos URI
$items->getPhotos() // and use with "foreach(){}"
// item photos URI
$item->getPhoto1(width, height, operation, background, xPos, yPos); // for get Photo 1
$item->getPhoto2(width, height, operation, background, xPos, yPos); // for get Photo 2
$item->getPhoto3(width, height, operation, background, xPos, yPos); // for get Photo 3
$option->getName(); // for get Name
$option->getContent(); // for get Content
$option->getPhoto1(); // for get Photo 1
$option->getPhoto2(); // for get Photo 2
$option->getFile1(); // for get File 1
$option->getFile2(); // for get File 2
//for to get meta description and meta keywords just use this command below:
$option-registerMetaTags(); //it generates meta tags in your view page
\afzalroq\cms\entities\front\Items::getEntityItemSearchResults((array) $entitySlugs, $search); // get search results with entity and items
\afzalroq\cms\entities\front\Items::getOptionItemSearchResults((array) $optionSlugs, $search); // get search results with option and items
\afzalroq\cms\entities\front\Options::getOptionSearchResults((array) $optionSlugs, $search); // get search results with options