2017 © Pedro Peláez
 

yii2-extension yii2-link-preview

LinkPreview widget renders page preview

image

yii2mod/yii2-link-preview

LinkPreview widget renders page preview

  • Monday, December 12, 2016
  • by disem
  • Repository
  • 9 Watchers
  • 23 Stars
  • 685 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 9 Forks
  • 1 Open issues
  • 9 Versions
  • 14 % Grown

The README.md

Yii2 Link Preview Widget

LinkPreview widget automatically retrieves some information from the content of the link., (*1)

Latest Stable Version Total Downloads License Build Status, (*2)

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

php composer.phar require --prefer-dist yii2mod/yii2-link-preview "*"

or add, (*5)

"yii2mod/yii2-link-preview": "*"

to the require section of your composer.json file., (*6)

Usage

1) Execute init migration:, (*7)

php yii migrate/up --migrationPath=@vendor/yii2mod/yii2-link-preview/migrations

2) Define preview action in your controller:, (*8)

public function actions()
{
    return [
        'link-preview' => LinkPreviewAction::className()
    ];
}

3) Add widget to your page as follows:, (*9)

echo LinkPreview::widget([
    'selector' => '#your-input-id or .someclass',
    'clientOptions' => [
        'previewActionUrl' => \yii\helpers\Url::to(['link-preview'])
    ],
])

Example of usage with the ActiveForm and saving the page info, (*10)

1) Create the basic form in the view:, (*11)

<?php $form = \yii\widgets\ActiveForm::begin() ?>
    <div class="form-group">
        <label for="preview">Preview</label>
        <input name="preview" class="form-control" id="preview" placeholder="Preview">
    </div>
    <?php echo \yii2mod\linkpreview\LinkPreview::widget([
        'selector' => '#preview',
        'clientOptions' => [
            'previewActionUrl' => \yii\helpers\Url::to(['link-preview'])
        ],
    ]) ?>
    <div class="form-group">
        <?= \yii\helpers\Html::submitButton('Save', ['class' => 'btn btn-primary']) ?>
    </div>
<?php \yii\widgets\ActiveForm::end() ?>

2) Add the following code to your action for the saving page info:, (*12)

$model = new LinkPreviewModel();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
    $model->save();
}

// or the short version 

$linkPreviewId = LinkPreviewModel::saveAndGetId(Yii::$app->request->post());

#### GitHub Preview Example

Alt text, (*13)

Alt text, (*14)

The Versions

12/12 2016

dev-master

9999999-dev

LinkPreview widget renders page preview

  Sources   Download

MIT

The Requires

 

The Development Requires

by Igor Chepurnoy

preview page preview link preview

22/11 2016

1.3

1.3.0.0

LinkPreview widget renders page preview

  Sources   Download

MIT

The Requires

 

The Development Requires

by Igor Chepurnoy

preview page preview link preview

09/11 2016

1.2.1

1.2.1.0

LinkPreview widget renders page preview

  Sources   Download

MIT

The Requires

 

by Igor Chepurnoy

preview page preview link preview

09/11 2016

1.2

1.2.0.0

LinkPreview widget renders page preview

  Sources   Download

MIT

The Requires

 

by Igor Chepurnoy

preview page preview link preview

18/07 2016

1.1

1.1.0.0

LinkPreview widget renders page preview

  Sources   Download

MIT

The Requires

 

by Igor Chepurnoy

extension yii2

19/05 2016

1.0.3

1.0.3.0

LinkPreview widget renders page preview

  Sources   Download

MIT

The Requires

 

by Igor Chepurnoy

extension yii2

19/05 2016

1.0.2

1.0.2.0

LinkPreview widget renders page preview

  Sources   Download

MIT

The Requires

 

by Igor Chepurnoy

extension yii2

28/12 2015

1.0.1

1.0.1.0

LinkPreview widget renders page preview

  Sources   Download

MIT

The Requires

 

by Igor Chepurnoy

extension yii2

06/07 2015

1.0

1.0.0.0

LinkPreview widget renders page preview

  Sources   Download

MIT

The Requires

 

by Igor Chepurnoy

extension yii2