Package Data | |
---|---|
Maintainer Username: | rozklad |
Maintainer Contact: | info@sanatorium.ninja (Sanatorium) |
Package Create Date: | 2016-03-12 |
Package Last Update: | 2017-01-08 |
Language: | JavaScript |
License: | Unknown |
Last Refreshed: | 2024-11-29 15:18:58 |
Package Statistics | |
---|---|
Total Downloads: | 0 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 3 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Extended input types
Pick category from tree (to be deprecated >> see Relation).
Pick country from list.
Date formatted input.
E-mail formatted input.
Pick single file from media library. child type to Media
Pick multiple images from media library. child type to Media
Pick single image from media library. child type to Media
Pick multiple files from media library, also a parent for File, Gallery, Image, Video.
Phone formatted input.
Relation to another entity.
To register new extension, use:
try
{
// Register new relation
$this->app['sanatorium.inputs.relations']->registerRelation(
'qualification', 'Sleighdogs\Qualifications\Models\Qualification'
);
//
} catch (\ReflectionException $e)
{
// sanatorium/inputs is not installed or does not support relations
}
Note: Code above has to be booted after sanatorium/inputs for that to work properly, therefore remember to register any extension using this code as dependent on sanatorium/inputs (see block require in extension.php of your extension)
Multiple input values
1-100 (to be extended) slider scale input.
One or multiple (allowOptions) checkboxes with "switchery look".
Multiselect which allows user's with permissions to add new values.
Single true/false value.
URL link input.
Pick single video from media library. child type to Media
WYSIWYG editor input field.
Create new class in Sanatorium\Inputs\Types namespace, that might look like this
<?php
namespace Sanatorium\Inputs\Types;
class ScaleType extends BaseType
{
public $settings = [
'min' => [
'name' => 'sanatorium/inputs::types.settings.min',
'default' => 0,
'validation'=> 'numeric|max:max',
'type' => 'number'
],
'max' => [
'name' => 'sanatorium/inputs::types.settings.max',
'default' => 100,
'validation'=> 'numeric|min:min',
'type' => 'number',
]
];
/**
* {@inheritDoc}
*/
protected $identifier = 'scale';
}
Register that class in Sanatorium\Inputs\Providers\InputServiceProvider::registerTypes() method
$types = [
...
'date' => new Types\ScaleType,
];
Create templates to display the custom type on frontend and backend in sanatorium/inputs::types/{typeidentifider} theme path. (For example: /themes/admin/default/packages/sanatorium/input/views/types/scale.blade.php and /themes/frontend/default/packages/sanatorium/input/views/types/scale.blade.php)
Widget to show media input types
{{-- Show single image --}}
@display($product, 'cover_image', 'single')
{{-- Show gallery images --}}
@display($product, 'gallery', 'multiple')
Widget to show values of input group
{{-- Show input group table --}}
@displaygroup($product, 'Technical information')
All functions below are not namespaced and you can find their code in src/helpers.php
storage_url($media); // Link to media on any storage
thumbnail_url($media, $width = 300, $height = 300) // Link to thumbnail
mime2Extension($mime, $extension = '') // Returns most common extension to mime type
get_attribute_label($key, $slug) // Return label of single selected value
get_attribute_labels($keys = [], $slug, $return = 'string', $implode = ', ') // Return labels of selected values
Returns for example
get_attribute_labels($product->animal, 'animal', 'array') // => array ('cow' => 'Cow')
str_scheme($url, $scheme = 'http://'); // Add protocol if missing
str_links($text); // Turn URLs in content to <a href>
theme_set($theme); // Set active theme
theme_set_fallback($theme); // Set fallback theme
theme_set_area($area); // Set area of theme (admin|frontend)
theme_frontend(); // Shorthand for theme_set_area('frontend');
theme_admin(); // Shorthand for theme_set_area('admin');
Support not available.