2017-10-05 100 views
0

我使用的是用戶的插件,我想知道我怎麼能閃消息到用戶登錄時(新的會話),並註銷。Octobercms的OnStart閃光燈消息

使用此當客戶端登錄嘗試,但它沒有任何意義,因爲它總是會出現刷新頁面時。

<p data-control="flash-message" data-interval="5" class="success"> 
    {{message}} 
</p> 

感謝

+0

你能告訴我們你是如何設置的「信息」變量列表?十月CMS文檔應該幫助你這個https://octobercms.com/docs/markup/tag-flash –

+0

嗨,只需在方法(onSignin-> Account.php)上添加Flash :: success(成功登錄) ,然後使用標籤閃光燈輸出消息。它的工作原理只是不確定編輯用戶插件腳本是否是好的做法。/* *成功登錄後重定向到預期頁面 */ $ redirectUrl = $ this-> pageUrl($ this-> property('redirect')) ?:$ this-> property('redirect') ; 閃存::成功( '登錄成功'); – Lindelwa

回答

1

使用鉤/事件

rainlab.user.login:用戶在已成功簽署

rainlab.user.logout:用戶已成功退出。

Event::listen('rainlab.user.login', function($user) { 
    Flash::success(Successfully Logged in) 
    }); 
    Event::listen('rainlab.user.logout', function($user) { 
    Flash::success(Successfully Logged out) 
    }); 
  1. 與在引導功能的plugin.php寫入助洗劑

  2. 創建一個新的插件3" >

  3. 不改變它的供應商代碼,因爲是一個BA d練習。

更多的事件 https://octobercms.com/docs/services/events

和用戶事件的 https://github.com/rainlab/user-plugin#events