Package Data | |
---|---|
Maintainer Username: | Agel Nash |
Maintainer Contact: | agel_nash@xaker.ru (Agel_Nash) |
Package Create Date: | 2015-12-10 |
Package Last Update: | 2018-04-04 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-16 15:02:40 |
Package Statistics | |
---|---|
Total Downloads: | 836 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 4 |
Total Watchers: | 1 |
Total Forks: | 1 |
Total Open Issues: | 0 |
You will want to run the following command to publish the config to your application, otherwise it will be overwritten when the package is updated.
php artisan vendor:publish --provider="AgelxNash\modLaravel\ServiceProvider"
Now you can edit the file config/modx.php
Create your snippet in the config file config/modx.php
return array(
'snippets' => array(
'user' => function($params){
$id = isset($params['id']) ? (int)$params['id'] : 0;
$field = (isset($params['field']) && in_array($params['field'], array('name', 'email'))) ? (string)$params['field'] : 'name';
$userObj = App\Models\User::findOrNew($id);
return $userObj->{$field};
}
)
);
Now you can call a snippet user
$text = 'Some data: [[example? &id=`asd`]]. User: [[user? &id=`2`]]';
return Modx::mergeSnippets($text);
As a result, you get something like this
Some data: Array ( [id] => asd ). User: Admin
Do not get carried away with this garbage. It is absolutely safe and can lead to cracking of your site.
For example, you have a slider. And you want to insert it in any place