This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @functions strip-value($value) { | |
| @return $value / (($value*0) + 1); | |
| } | |
| Применение: | |
| h1 { | |
| padding: strip-value(10px)*1em; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /***************************************Пример кода 1*********************************************** | |
| * | |
| * Получение массива категорий | |
| **/ | |
| function get_cat(){ | |
| global $connection; | |
| $query = "SELECT * FROM categories"; | |
| $res = mysqli_query($connection, $query); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function saveAttributes() { | |
| ... | |
| $user = new User(); | |
| $user -> attributes = this -> attributes; //this - это модель и код находится также в файле модели | |
| ... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| linesCount () { | |
| if (this.selectedNote) { | |
| // Count the number of new line characters | |
| return this.selectedNote.content.split(/\r\n|\r|\n/).length | |
| } | |
| }, | |
| wordsCount () { | |
| if (this.selectedNote) { | |
| var s = this.selectedNote.content |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| Инициирование событий и передача в него данных (из документации) | |
| Иногда при инициировании события может понадобиться передать его обработчику дополнительную информацию. Например, объекту, отвечающему за почту, может понадобиться передать обработчику события messageSent определенные данные, раскрывающие смысл отправленных почтовых сообщений. Для этого в качестве второго параметра методу yii\base\Component::trigger() передается объект события. Объект события должен быть экземпляром класса yii\base\Event или его потомка. Например: | |
| =================================================================================================================== | |
| namespace app\components; | |
| use yii\base\Component; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function __construct(User $user) | |
| { | |
| $this->user = $user; | |
| $this->on(self::EVENT_AFTER_VALIDATE, [$this, 'resizePicture']); | |
| $this->on(self::EVENT_POST_CREATED, [Yii::$app->feedService, 'addToFeeds']); | |
| } | |
| /** | |
| * Resize image if needed | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use Yii; | |
| public function actionView() | |
| { | |
| /* @var $currentUser User */ | |
| $currentUser = Yii::$app->user->identity; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ============================================================================================ | |
| Подключчение скрипта в представлении (вмде) с указанием зависимости | |
| <?php $this->registerJsFile('@web/js/likes.js', [ | |
| 'depends' => JqueryAsset::className(), | |
| ]); | |
| ============================================================================================ | |
| Для подключения одного скрипта js или css на конкретной странице, прописываем следующий код: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace app\components; | |
| use Yii; | |
| use frontend\models\Auth; | |
| use frontend\models\User; | |
| use yii\authclient\ClientInterface; | |
| use yii\helpers\ArrayHelper; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <input id="form-token" type="hidden" name"?=Yii::$app->request->csrfParam?>" value"?=Yii::$app->request->csrfToken?>"/> |
NewerOlder