PHP code example of sebastianlenz / linkfield
1. Go to this page and download the library: Download sebastianlenz/linkfield library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sebastianlenz / linkfield example snippets
use craft\commerce\elements\Product;
use lenz\linkfield\Plugin as LinkPlugin;
use lenz\linkfield\events\LinkTypeEvent;
use lenz\linkfield\models\element\ElementLinkType;
use yii\base\Event;
/**
* Custom module class.
*/
class Module extends \yii\base\Module
{
public function init() {
parent::init();
Event::on(
LinkPlugin::class,
LinkPlugin::EVENT_REGISTER_LINK_TYPES,
function(LinkTypeEvent $event) {
$event->linkTypes['product'] = new ElementLinkType(Product::class);
}
);
}
}