LaravelPackages.net
Acme Inc.
Toggle sidebar
ludmanp/typicms-pageoptions

Allow to add more parameters to a Page in TypiCMS

31
0
14.0.0
About ludmanp/typicms-pageoptions

ludmanp/typicms-pageoptions is a Laravel package for allow to add more parameters to a page in typicms. It currently has 0 GitHub stars and 31 downloads on Packagist (latest version 14.0.0). Install it with composer require ludmanp/typicms-pageoptions. Discover more Laravel packages by ludmanp or browse all Laravel packages to compare alternatives.

Last updated

PageOptions for TypiCMS

Latest Version on Packagist Total Downloads MIT Licence

Allow to extend TypiCMS Page properties according to page templates.

Installation

You can install the package via composer:

composer require ludmanp/typicms-pageoptions

To prepare for usage you can run

php artisan page-options:install

The command will publish and run the migrations.

You can alternatively run separate commands to do these operations:

php artisan vendor:publish --tag="page-options-migrations"
php artisan migrate

Optionally, you can publish the views using

php artisan vendor:publish --tag="typicms-pageoptions-views"

Usage

Admin

Include

<x-pageoptions-admin-form :model="$model" />

into resources/viwes/vendor/pages/admin/_from.blade.php.

$model is the current Page model

Create blade file in resources/viwes/vendor/page-options/admin directory with page tempalate name. For example default.blade.php

To add options you can use, for example,

{!! BootForm::text(__('Description'), 'options[description]') !!}
{!! TranslatableBootForm::text(__('Phone number'), 'options[phone][number]') !!}

To include specific images, use

<x-pageoptions-image :model="$model" name="preview_image_id" label="Preview image"/>
<x-pageoptions-image :model="$model" name="phone.icon_id" label="Phone icon"/>

name is option's name, use dots to make multilevel array. label is optional, but recommended to distinguish from other image fields

The same way you can add file fields

<x-pageoptions-file :model="$model" name="specification" label="Specification"/>

Public

To output PageOptions use in page template (pages/public/*.blade/php)

To output simple option use

{{ $pageOptions->present()->option('phone') }}

To output translatable option use

{{ $pageOptions->present()->optionTranslated('company.name') }}

There is available optional locale parameter

{{ $pageOptions->present()->optionTranslated('company.name', 'en') }}

To output image use


<img src="{{ $pageOptions->present()->optionsImage('contact.image') }}"
    alt="{{ optional($pageOptions->present()->optionsFile('contact.image'))->alt_attribute ?? 'Contacts' }}"/>

Additional parameters width, height and options are available, like in presenter's image method.

To get file model use.


$pageOptions->present()->optionsFile('contact.file')

As you can see above it is available also for images to get alt_attribute for example.

To make link to file you can write like following

<a href="{{ optional($pageOptions->present()->optionsFile('contact.file'))->url }}">File</a>

Credits

License

The MIT License (MIT). Please see License File for more information.

Comments