Giter VIP home page Giter VIP logo

typicms-pageoptions's Introduction

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.

typicms-pageoptions's People

Contributors

ludmanp avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.