metrixinfo / nova-iframe
A Laravel Nova iFrame field.
Installs: 250 188
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: ^7.3|^8.0
This package is auto-updated.
Last update: 2024-11-14 06:53:36 UTC
README
This Laravel Nova field enables you to display HTML in an iFrame so it does not affect any of the other HTML on the page. It is only visible on the Details view.
Installation
Install the package into a Laravel app that uses Nova with Composer:
composer require metrixinfo/nova-iframe:^4.0
Usage
Add the field to your resource in the fields
method:
use Metrixinfo\Nova\Fields\Iframe\Iframe; ... ... Iframe::make('HTML Content','html_content'),
If you are only storing a URL and would like that previewed in the iFrame, you can use a closure to retrieve the HTML. This also helps getting around iframe security issues such as http content being called from https. You can use file_get_contents, curl, GuzzleHttp etc. to retrieve the HTML content.
use Metrixinfo\Nova\Fields\Iframe; ... ... Iframe::make('HTML Content', function (){ return \file_get_contents('https://www.google.com/'); }),
Options
Size
You may pass in the size of the iframe. Values can be numeric or string.
use Metrixinfo\Nova\Fields\Iframe\Iframe; ... ... Iframe::make('HTML Content','html_content')->size('100%', 600),
Style
You may pass CSS styles to the iframe.
use Metrixinfo\Nova\Fields\Iframe\Iframe; ... ... Iframe::make('HTML Content','html_content')->style('border: 10px solid black;'),
Classes
You may pass in classes to the iframe.
use Metrixinfo\Nova\Fields\Iframe\Iframe; ... ... Iframe::make('HTML Content','html_content')->classes('iframe-bordered iframe-large'),
Options may be chained
ie:
use Metrixinfo\Nova\Fields\Iframe\Iframe; ... ... Iframe::make('HTML Content','html_content') ->style('border: 10px solid black;') ->size('100%', 600) ->classes('iframe-bordered iframe-large'),
Note: Iframe will only be displayed on the Detail view