PHP code example of andrewdanilov / yii2-custom-pages
1. Go to this page and download the library: Download andrewdanilov/yii2-custom-pages 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-custom-pages example snippets
$config = [
// ...
'modules' => [
// ...
'custompages' => [
'class' => 'andrewdanilov\custompages\backend\Module',
// access role for module controllers, optional, default is ['@']
'access' => ['admin'],
// path to Views for pages and categories
'templatesPath' => '@frontend/views/custompages',
// optional, path to user translates
'translatesPath' => '@common/messages/custompages',
// optional, enables controls for managing page tags, default is true
'enableTags' => false,
// optional, enables controls for managing page albums, default is true
'enableAlbums' => false,
// optional, enables controls for managing categories, default is true
'enableCategories' => false,
// optional, enables controls for managing pages extra fields, default is true
'enablePageFields' => false,
// file manager configuration, optional, default is:
'fileManager' => [
'basePath' => '@frontend/web',
'paths' => [
[
'name' => 'News',
'path' => 'upload/images/news',
],
[
'name' => 'Articles',
'path' => 'upload/images/articles',
],
],
],
// bootstrap version to use, optional, default is '5.x'
'bsVersion' => '5.x',
],
],
];
$config = [
// ...
'modules' => [
// ...
'custompages' => [
'class' => 'andrewdanilov\custompages\frontend\Module',
// optional, path to template Views for pages and categories
'templatesPath' => '@frontend/views/custompages',
// optional, path to user translates
'translatesPath' => '@common/messages/custompages',
// optional, page text short version length, default is 50
'pageShortTextWordsCount' => '100',
// optional, callable functions to process page and category text,
// i.e. to replace some shortcodes on it
'pageTextProcessor' => 'frontend\components\MyPageTextProcessor::replaceShortcodes',
'categoryTextProcessor' => 'frontend\components\MyCategoryTextProcessor::replaceShortcodes',
// pagination settings
'paginationForcePageParam' => false, // optional, whether to always have the page parameter in the URL, even on first page, default is false
'paginationPageParam' => 'page', // optional, name of the parameter storing the current page index, default is 'page'
'paginationPageSizeParam' => false, // optional, false or name of the parameter storing the page size, default is false
'paginationPageSize' => 20, // optional, number of items per page, default is 20
],
],
];
use yii\helpers\Url;
// detailed page url
$pageUrl = Url::to(['/custompages/default/page', 'id' => 123]);
// pages list url, shows pages in defined category
$categoryUrl = Url::to(['/custompages/default/category', 'id' => 1]);
// pages list url by tag id
$pageTagUrl = Url::to(['/custompages/default/page-tag', 'id' => 7]);
// pages list url by tag slug
$pageTagUrl = Url::to(['/custompages/default/page-tag', 'slug' => 'tagname']);
// pages list url by tag id, shows pages in defined category only
$pageTagUrl = Url::to(['/custompages/default/page-tag', 'id' => 7, 'category_id' => 123]);
// pages list url by tag slug, shows pages in defined category only
$pageTagUrl = Url::to(['/custompages/default/page-tag', 'slug' => 'tagname', 'category_id' => 123]);