PHP code example of psagnataf / cms

1. Go to this page and download the library: Download psagnataf/cms 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/ */

    

psagnataf / cms example snippets


Niku\Cms\CmsServiceProvider::class,

use Niku\Cms\Http\Middlewares\WhitelistPostTypesMiddleware;
use Niku\Cms\Http\Middlewares\WhitelistConfigGroupsMiddleware;

protected $routeMiddleware = [
	...
    'posttypes' => WhitelistPostTypesMiddleware::class,
    'groups' => WhitelistConfigGroupsMiddleware::class,
	...
];

return [
    'post_types' => [

        // Default
        'attachment' => App\Cms\PostTypes\Attachment::class,

        // CMS
        'page' => App\Cms\PostTypes\Pages::class,
        'posts' => App\Cms\PostTypes\Pages::class,
        'posts-category' => App\Cms\PostTypes\PostsCategory::class,

    ],

    'config_types' => [

        // Registering the single config page
        'defaultsettings' => App\Cms\ConfigTypes\DefaultSettings::class,        

    ];

Niku\Cms\Cms::postTypeRoutes([
	'register_post_types' => [
		'posts',
		'superadminposts',
	],
]);

// Registering the routes for config pages
Niku\Cms\Cms::postTypeRoutes([
	'register_groups' => [
		'defaultsettings',		
	],
]);

namespace App\Cms\PostTypes;

use Niku\Cms\Http\NikuPosts;

class Pages extends NikuPosts
{
    // The label of the custom post type
    public $label = 'Pages';

    // Custom post type identifer
	public $identifier = 'page';

    // Users can only view their own posts when this is set to true
    public $userCanOnlySeeHisOwnPosts = false;    

    public $config = [

    ];

    // Setting up the template structure
    public $templates = [
        'default' => [
            'customFields' => [
                'post_content' => [
                    'component' => 'niku-cms-text-customfield',
                    'label' => 'Text',
                    'value' => '',
                    'validation' => '

public $templates = [
    'default' => [
        'label' => 'Default page',
        'template' => 'default',
        'customFields' => [
            'text' => [
                'component' => 'niku-cms-text-customfield',
                'label' => 'Text',
                'value' => '',
                'validation' => '  'validation' => '

Route::get('blog', 'BlogController@blog');
Route::get('blog/{slug}', 'BlogController@singleBlog');

public function blog()
{
    $posts = Posts::where([
        ['status', '=', '1'],
        ['post_type', '=', 'post']
    ])->with('postmeta')->get();
    return view('static.blog', compact('posts'));
}

'text' => [
    'component' => 'niku-cms-text-customfield',
    'label' => 'Text',
    'value' => '',
    'validation' => '

php artisan vendor:publish --tag=niku-config

php artisan vendor:publish --tag=niku-posttypes

php artisan migrate
blade
@foreach($posts as $post)
    <div class="row">
        @if(!empty($post->getMeta('image')))
            
            $image = json_decode($post->getMeta('image'));
            $image = $image->url;