PHP code example of andrewdanilov / yii2-site-data

1. Go to this page and download the library: Download andrewdanilov/yii2-site-data library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

andrewdanilov / yii2-site-data example snippets


$config = [
	// ...
	'modules' => [
		// ...
		'sitedata' => [
			'class' => 'andrewdanilov\sitedata\Module',
			'access' => ['admin'], // access role for module controllers, optional, default is ['@']
			'uploadBasePath' => '@frontend/web', // optional, default is '@frontend/web'
			'uploadPath' => 'upload/sitedata', // optional, default is 'upload/sitedata'
		],
	],
];

$config = [
	// ...
	'components' => [
		// ...
		'siteData' => [
			'class' => 'andrewdanilov\sitedata\components\SiteData',
		],
	],
];

$this->title = Yii::$app->siteData->get('seo_title', 'Default seo title');

$this->title = Yii::$app->siteData->set('seo_title', 'New seo title');

// list of links for managing values of each category all in one page
$categoryListUrl = Yii::$app->urlManager->createUrl(['/sitedata/manager']);
// manager of all values of category in one page
$categoryDataManagerUrl = Yii::$app->urlManager->createUrl(['/sitedata/manager/edit', 'category_id' => 123]);

// grid for adding/editing/removing data items
$dataGridUrl = Yii::$app->urlManager->createUrl(['/sitedata/data']);
// grid for adding/editing/removing data categories
$categoryGridUrl = Yii::$app->urlManager->createUrl(['/sitedata/category']);

$sitedata_menu_items = [
    ['label' => 'Site Data'],
	['label' => 'Site settings', 'url' => ['/sitedata/manager'], 'icon' => 'cog'],
];

echo \yii\widgets\Menu::widget(['items' => $sitedata_menu_items]);

php yii migrate --migrationPath=@andrewdanilov/sitedata/migrations