Yii2-shortcodes-pack is part of the Yii2-plugins-system that have more usefull shortcodes for our site
More here - https://github.com/loveorigami/yii2-shortcodes-pack
Yii2-shortcodes-pack is part of the Yii2-plugins-system that have more usefull shortcodes for our site
More here - https://github.com/loveorigami/yii2-shortcodes-pack
How create shortcode?
If you have yii2 widget (for example - GalleryById)
/**
* Class GalleryWidget
*/
class GalleryById extends Widget
{
public $cols = 6;
public $limit = 10;
public $id;
/**
* Render widget
* @return string
*/
public function run()
{
if ($this->id) {
$models = GalleryImages::find()->where(['gallery_id' => $this->id])->limit($this->limit)->published()->all();
return $this->render('index', [
'models' => $models,
'cols' => $this->cols,
]);
}
return null;
}
}
You can create Plugin class with shortcodes in directory with our shortcodes ( as @common/shortcodes).
/**
* Plugin Name: Gallery
* Version: 1.7
* Plugin URI: https://github.com/loveorigami/lo-module-gallery/tree/master/plugins/gallery
* Description: A simple gallery plugin for use shortcode [gallery id=1]
* Author: Andrey Lukyanov
* Author URI: https://github.com/loveorigami/yii2-plugins-system
*/
class GalleryShortcodes extends BaseShortcode
{
public static function shortcodes()
{
return [
'gallery' => [
'callback'=> [GalleryById::class, 'widget'],
'tooltip' => '[gallery id=1]',
'config' => [
'view' => 'gallery-show',
'cols' => 6,
'limit' => 60,
'id' => null
]
]
];
}
}
That’s all. After installation you can use it as
[gallery id=1] //or
[gallery id=1 linit=10 cols=2] // for 10 images in 2 columns
Hi,
I try to install this extension via composer but it does not work.
composer require "loveorigami/yii2-shortcodes-pack": "*"
here is the error description
[InvalidArgumentException]
Could not find package * at any version for your minimum-stability (stable)
. Check the package spelling or your minimum-stability
i got situation too, maybe repo on private