sheillendra / yii2-embed-script
Yii2 Embed Script
Installs: 17
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
This package is not auto-updated.
Last update: 2024-10-24 00:54:30 UTC
README
yii2 embed custom script or 3rd party like google tracking and seo or other
Quick start
Config
...
'components'=>[
...
'embedScript'=>[
'class'=>'sheillendra\embedscript\Collection',
'services'=>[
'googleAnalytics'=>[
'class'=>'sheillendra\embedscript\services\GoogleAnalytics',
'trackerId'=>'UA-XXXXXXXX-X',
]
]
]
...
]
...
trick for local config, use NotActive for service class I'm not yet found best way without a condition (if).
...
'components'=>[
...
'embedScript'=>[
'class'=>'sheillendra\embedscript\Collection',
'services'=>[
'googleAnalytics'=>[
'class'=>'sheillendra\embedscript\services\NotActive'
]
]
]
...
]
...
using as widget in view / layout
<?php use sheillendra\embedscript\widgets\EmbedScript ?>
<?php EmbedScript::widget();?>
It can also be used as a bootstrap module so as not to bother applying widget in any layout or view.
#config
...
'bootstrap' => ['log','embedscript'],
'modules' => [
'embedscript' => ['class'=>'sheillendra\embedscript\Module']
]
...