PHP code example of snowsoft / oapage-designer

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

    

snowsoft / oapage-designer example snippets


$router->resource('page-designer', PageDesignerController::class);
$router->resource('page-designer-images', PageDesignerImagesController::class);
$router->resource('page-designer-videos', PageDesignerVideoController::class);
$router->resource('page-designer-texts', PageDesignerTextController::class);
$router->resource('page-designer-inline-galleries', PageDesignerInlineGalleryController::class);
$router->resource('page-designer-embeds', PageDesignerEmbedController::class);

use App\Http\Controllers\PageDesignerController;

Route::get('/page/{id}', [PageDesignerController::class, 'index'])->name('page-designer');

$form->pagedesigner('data', __('pageDesign'));

// set snap
$form->pagedesigner('data', __('pageDesign'))->snap(30);

use OpenAdmin\Admin\PageDesigner\Traits\PageDesignItem;

class PageDesignerQuoteController extends AdminController
{
    use PageDesignItem;

    public function __construct()
    {
        $this->initPageDesignItem();
    }

    public static function pageDesign()
    {
        return [
            'parent_field'=> 'page_id',
            'type'        => 'quote',
            'title'       => 'quote',
            'icon'        => 'icon-quote-right',
            'model'       => "\App\Models\PageDesignerQuote",
        ];
    }

    // this part renders the content part of the item
    // the rendering on the frond-end is seperate, but offcourse you can let them share styles
    public static function pageDesignScripts()
    {
        return <<<'JS'
            // use the type as writen above + 'SetContent'
            window.quoteSetContent = function(data,current_content){
                current_content.innerHTML = '<h2>Quote: '+data.quote+'</h2>';
            };
        JS;
    }

    ...

$ composer isan admin:import page-designer

$ php artisan vendor:publish --tag=page-designer

$ php artisan migrate