octobercms-plugins

Extracting October pages indentation in JSON for a Vue.js app

夙愿已清 提交于 2020-07-10 07:29:47
问题 For building a vue menu in October, I have a plugin that I want to extract the October pages structure in a JSON data keeping the pages and subpages indentation. Based on this post : How to get static page dropdown in OctoberCMS with get page tree? I used the following code : public function boot() { \RainLab\Pages\Classes\Page::extend(function($model) { $model->addDynamicMethod('getPageOptions', function() { $theme = \Cms\Classes\Theme::getEditTheme(); $pageList = new \RainLab\Pages\Classes

relationship between user and category OctoberCMS

半腔热情 提交于 2020-01-06 07:52:48
问题 how to establish a relationship between the user and the category? A category has more than one user, and a user belongs to a category I add category_id in the user table on the frontend I display the list of users with the plugin builder but I also want to display the category of the user I use the RainLab user plugin Help me please, thank you in advance 回答1: it seems you need to extend user model and add category relation runtime You need to add this code to your plugin's boot method public

how to change the direction of a form dynamicly with ajax or javascript in octobercms

混江龙づ霸主 提交于 2019-12-24 10:25:04
问题 I have a form, and I would like it when I submit it, that it redirects me in another page, knowing that the redirection path must be dynamic, it means that I use a javascript function that takes the user's choice and return a string the ajax handler data-request-redirect only accept a string and execute not javascript code: title = "test" url = "/test" layout = "default" is_hidden = 0 == <?php function onStart() { $this['example'] = Session::get('example-key'); } function onTest() { Session:

OctoberCMS plugin show all the validations at once

戏子无情 提交于 2019-12-24 06:06:49
问题 I am using Builder plugin to create plugins and did field validations in my model in one of my plugins which works fine. Let's say I have a validation something like this in one my plugin call it as Team . Model File: technobrave\team\models\Team.php <?php namespace Technobrave\Team\Models; use Model; /** * Model */ class Team extends Model { use \October\Rain\Database\Traits\Validation; /* * Validation */ public $rules = [ 'name' => 'required|unique:technobrave_team_', 'photo' => 'required',

OctoberCMS: How to maintain a two-way friendship relation?

前提是你 提交于 2019-12-24 06:03:11
问题 I'm extending the rainlab.user plugin to allow each user to have friends via a simple intermediate table with the following fields: user_id friend_id status I've extended the User model: use RainLab\User\Models\User as FrontUser; FrontUser::extend(function($model) { $model->belongsToMany['friends']=[ 'RainLab\User\Models\User', 'table' => 'meysam_social_friends', 'pivot' => ['status'], 'pivotModel' => 'Meysam\Social\Models\FriendsPivot', 'timestamps' => true, 'key' => 'user_id', 'otherKey' =>

OctoberCMS: How to maintain a two-way friendship relation?

不打扰是莪最后的温柔 提交于 2019-12-24 06:03:04
问题 I'm extending the rainlab.user plugin to allow each user to have friends via a simple intermediate table with the following fields: user_id friend_id status I've extended the User model: use RainLab\User\Models\User as FrontUser; FrontUser::extend(function($model) { $model->belongsToMany['friends']=[ 'RainLab\User\Models\User', 'table' => 'meysam_social_friends', 'pivot' => ['status'], 'pivotModel' => 'Meysam\Social\Models\FriendsPivot', 'timestamps' => true, 'key' => 'user_id', 'otherKey' =>

October CMS - Display only those records that are attached to the groups of the current user

拜拜、爱过 提交于 2019-12-23 05:06:33
问题 I need to display only those records in the model that are attached to some groups. ("belongsToMany" Relations). (backend page of plugin list of Movies model) I want to get the groups of the current user and create a query. What I mean: I use Relations field to to attach records to groups. i.e: I have table "elisseii_myplugin_movies". In the "Movies" model, I created a relation field with the name "groups". and created the table "elisseii_myplugin_movies_groups". Used $belongsToMany in the