99re热这里只有精品视频,7777色鬼xxxx欧美色妇,国产成人精品一区二三区在线观看,内射爽无广熟女亚洲,精品人妻av一区二区三区

Joomla Content 事件

2023-03-10 16:00 更新

內(nèi)容事件在內(nèi)容創(chuàng)建過(guò)程中觸發(fā)。這些事件在大多數(shù)的組件和視圖中被觸發(fā) - 不限定于com_content組件。

onContentPrepare

說(shuō)明

這是準(zhǔn)備輸出內(nèi)容的第一步,大多數(shù)內(nèi)容插件可以響應(yīng)本事件完成功能。由于文章和相關(guān)參數(shù)是通過(guò)引用傳遞的,因此事件處理程序可以在顯示之前對(duì)其進(jìn)行修改。

參數(shù)

  • context 內(nèi)容的上下文 - 通常是組件和視圖的拼接字符串 - 或者模塊的名稱(chēng) (如: com_content.article). 通過(guò)這個(gè)參數(shù)可以判斷當(dāng)前是否是我們需要處理的環(huán)境.
  • &article (引用傳遞)內(nèi)容對(duì)象 ,不同的觸發(fā)組件可能內(nèi)容不一樣(如: 對(duì)于文章組建,我們可以通過(guò) $article->text 得到文章的內(nèi)容).
  • &params (引用傳遞)內(nèi)容的參數(shù). 
  • page An integer that determines the "page" of the content that is to be generated. Note that in the context of views that might not generate HTML output, a page is a reasonably abstract concept that depends on the context.

返回值

無(wú)或者True / False.

示例

onContentAfterTitle

說(shuō)明

這個(gè)事件僅存在于 Joomla 3.x 及以上版本. 它的作用就是在文章輸出標(biāo)題后允許你輸出內(nèi)容. 盡管這個(gè)插件傳遞的參數(shù)也是引用,但不建議在這個(gè)插件中修改內(nèi)容,應(yīng)該使用 onContentPrepare 事件來(lái)修改內(nèi)容. 另外,對(duì)于文章組件,這個(gè)事件具有特殊的目的,文章組件使用這個(gè)事件來(lái)實(shí)現(xiàn)文章引言輸出功能.

參數(shù)

有關(guān)這些參數(shù)的更多討論,請(qǐng)參見(jiàn)onContentPrepare事件

  • context 內(nèi)容的上下文 - 通常是組件和視圖的拼接字符串 - 或者模塊的名稱(chēng) (如: com_content.article). 通過(guò)這個(gè)參數(shù)可以判斷當(dāng)前是否是我們需要處理的環(huán)境.
  • &article (引用傳遞)內(nèi)容對(duì)象 ,不同的觸發(fā)組件可能內(nèi)容不一樣(如: 對(duì)于文章組建,我們可以通過(guò) $article->text 得到文章的內(nèi)容).
  • &params (引用傳遞)內(nèi)容的參數(shù). 
  • page An integer that determines the "page" of the content that is to be generated. Note that in the context of views that might not generate HTML output, a page is a reasonably abstract concept that depends on the context.

返回值

字符串. 插件的返回值將會(huì)輸出到占位符處. 大多數(shù)模板在文章分隔符之后顯示此占位符

onContentBeforeDisplay

說(shuō)明

在內(nèi)容輸出之前觸發(fā)的事件

參數(shù)

有關(guān)這些參數(shù)的更多討論,請(qǐng)參見(jiàn)onContentPrepare事件. 注意 不同于 onContentPrepare, 這個(gè)插件的參數(shù)都是值傳遞.

  • context 內(nèi)容的上下文 - 通常是組件和視圖的拼接字符串 - 或者模塊的名稱(chēng) (如: com_content.article). 通過(guò)這個(gè)參數(shù)可以判斷當(dāng)前是否是我們需要處理的環(huán)境.
  • article 內(nèi)容對(duì)象 ,不同的觸發(fā)組件可能內(nèi)容不一樣(如: 對(duì)于文章組建,我們可以通過(guò) $article->text 得到文章的內(nèi)容).
  • params 內(nèi)容的參數(shù)
  • page An integer that determines the "page" of the content that is to be generated. Note that in the context of views that might not generate HTML output, a page is a reasonably abstract concept that depends on the context.

返回值

字符串. 插件的返回值將會(huì)輸出到占位符處. 大多數(shù)模板在文章分隔符之后顯示此占位符

示例

onContentAfterDisplay

說(shuō)明

內(nèi)容輸出之后觸發(fā)的事件

參數(shù)

有關(guān)這些參數(shù)的更多討論,請(qǐng)參見(jiàn)onContentPrepare事件. 注意 不同于 onContentPrepare, 這個(gè)插件的參數(shù)都是值傳遞.

  • context 內(nèi)容的上下文 - 通常是組件和視圖的拼接字符串 - 或者模塊的名稱(chēng) (如: com_content.article). 通過(guò)這個(gè)參數(shù)可以判斷當(dāng)前是否是我們需要處理的環(huán)境.
  • article 內(nèi)容對(duì)象 ,不同的觸發(fā)組件可能內(nèi)容不一樣(如: 對(duì)于文章組建,我們可以通過(guò) $article->text 得到文章的內(nèi)容).
  • params 內(nèi)容的參數(shù)
  • page An integer that determines the "page" of the content that is to be generated. Note that in the context of views that might not generate HTML output, a page is a reasonably abstract concept that depends on the context.

返回值

字符串. 插件的返回值將會(huì)輸出到占位符處. 大多數(shù)模板在文章內(nèi)容之后顯示此占位符

onContentBeforeSave

說(shuō)明

在內(nèi)容存儲(chǔ)到數(shù)據(jù)庫(kù)之前會(huì)觸發(fā)這個(gè)事件. 通過(guò)在插件返回false,可以終止保存操作. 以 JModelLegacy 舉例說(shuō)明,但我們終止了保存,可以通過(guò)調(diào)用 $this->setError($table->getError); 將錯(cuò)誤信息輸出給用戶

參數(shù)

  • context 內(nèi)容的上下文 - 通常是組件和視圖的拼接字符串 - 或者模塊的名稱(chēng) (如: com_content.article). 通過(guò)這個(gè)參數(shù)可以判斷當(dāng)前是否是我們需要處理的環(huán)境.
  • &article (引用傳遞)JTableContent對(duì)象 該對(duì)象代表了內(nèi)容的數(shù)據(jù) .
  • isNew bool值,如果內(nèi)容是新建的,那么就為true,否則為false
  • data 需要保存的數(shù)據(jù). 這里的data已經(jīng)經(jīng)過(guò)了組件的校驗(yàn)處理. 從 Joomla 3.7后 需要插件自己負(fù)責(zé)設(shè)置這個(gè)屬性,因?yàn)樵?nbsp;Joomla 4.0 中核心的內(nèi)容插件會(huì)使用到這個(gè)屬性

返回值

成功返回true,失敗返回false. 這個(gè)返回值將會(huì)影響保存的處理過(guò)程。如果返回false,保存會(huì)提示失敗

onContentAfterSave

說(shuō)明

將內(nèi)容保存到數(shù)據(jù)庫(kù)后,將觸發(fā)此事件.

參數(shù)

  • context 內(nèi)容的上下文 - 通常是組件和視圖的拼接字符串 - 或者模塊的名稱(chēng) (如: com_content.article). 通過(guò)這個(gè)參數(shù)可以判斷當(dāng)前是否是我們需要處理的環(huán)境.
  • article JTableContent對(duì)象 該對(duì)象代表了內(nèi)容的數(shù)據(jù) .
  • isNew bool值,如果內(nèi)容是新建的,那么就為true,否則為false

返回值

無(wú).

onContentPrepareForm

說(shuō)明

在JForm渲染之前觸發(fā)此事件. 通??梢栽谶@個(gè)事件中修改內(nèi)存中的JForm對(duì)象 如, 使用 JForm->loadFile() 添加新的字段 或者 JForm->removeField() 移除字段. 或者使用 JForm->setFieldAttribute() 去修改表單字段的屬性。

參數(shù)

  • form JForm 對(duì)象. 使用 $form->getName() 可以檢查當(dāng)前的表單是否是你需要處理的表單
  • data 對(duì)象包含了表單的數(shù)據(jù)

返回值

  • boolean 成功返回True,失敗返回False.

示例

onContentPrepareData

說(shuō)明

在獲得JForm數(shù)據(jù)的時(shí)候被觸發(fā). 通常和onContentPrepareForm一起使用,可以實(shí)現(xiàn)動(dòng)態(tài)的修改表單的字段和數(shù)據(jù) 

參數(shù)

  • context 內(nèi)容的上下文 - 通常是組件和視圖的拼接字符串 - 或者模塊的名稱(chēng) (如: com_content.article). 通過(guò)這個(gè)參數(shù)可以判斷當(dāng)前是否是我們需要處理的環(huán)境.
  • data 對(duì)象包含了表單的數(shù)據(jù)

返回值

  • boolean 成功返回True,失敗返回False.

示例

onContentBeforeDelete

說(shuō)明

在數(shù)據(jù)被從數(shù)據(jù)庫(kù)刪除之前觸發(fā)此事件. 通過(guò)在插件返回false,可以終止保存操作. 以 JModelLegacy 舉例說(shuō)明,但我們終止了保存,可以通過(guò)調(diào)用 $this->setError($table->getError); 將錯(cuò)誤信息輸出給用戶

參數(shù)

  • context 內(nèi)容的上下文 - 通常是組件和視圖的拼接字符串 - 或者模塊的名稱(chēng) (如: com_content.article). 通過(guò)這個(gè)參數(shù)可以判斷當(dāng)前是否是我們需要處理的環(huán)境.
  • data  JTableContent 對(duì)象的引用,這個(gè)對(duì)象包含了正在刪除的內(nèi)容

返回值

成功返回true,失敗返回false. 這個(gè)返回值將會(huì)影響保存的處理過(guò)程。如果返回false,保存會(huì)提示失敗

示例

onContentAfterDelete

說(shuō)明

數(shù)據(jù)從數(shù)據(jù)庫(kù)中刪除之后觸發(fā)此事件

參數(shù)

  • context 內(nèi)容的上下文 - 通常是組件和視圖的拼接字符串 - 或者模塊的名稱(chēng) (如: com_content.article). 通過(guò)這個(gè)參數(shù)可以判斷當(dāng)前是否是我們需要處理的環(huán)境.
  • data  JTableContent 對(duì)象的引用,這個(gè)對(duì)象包含了已經(jīng)刪除的內(nèi)容

返回值

無(wú)

示例

content/finder/finder.php

onContentChangeState

說(shuō)明

當(dāng)內(nèi)容的狀態(tài)改變的時(shí)候觸發(fā)此事件 (如.發(fā)布或者停止發(fā)布).

參數(shù)

  • context 內(nèi)容的上下文 - 通常是組件和視圖的拼接字符串 - 或者模塊的名稱(chēng) (如: com_content.article). 通過(guò)這個(gè)參數(shù)可以判斷當(dāng)前是否是我們需要處理的環(huán)境.
  • $pks 內(nèi)容主鍵值(id)得數(shù)組.
  • $value 新的狀態(tài)值.

返回值

無(wú)

示例

content/finder/finder.php

onContentSearch

說(shuō)明

此事件由各種與搜索相關(guān)的操作觸發(fā). 插件響應(yīng)此事件來(lái)返回對(duì)應(yīng)的搜索結(jié)果. 返回的結(jié)果必須包含下面的字段:

  • browsernav
  • catslug
  • created
  • href
  • section
  • slug
  • text
  • title

參數(shù)

  • $text 搜索的字符串.
  • $phrase 匹配模式 (exact|any|all). 默認(rèn)為 "any".
  • $ordering 排序選項(xiàng) (newest|oldest|popular|alpha|category). 默認(rèn) "newest".
  • $areas 搜索返回的數(shù)組,null表示搜索全部.

返回值

具有上述成員的stdClass對(duì)象數(shù)組

在以下文件中用到

onContentSearchAreas

說(shuō)明

當(dāng)在輸出搜索范圍的時(shí)候這個(gè)事件被觸發(fā)

參數(shù)

無(wú)

返回值

一個(gè)關(guān)聯(lián)數(shù)組. 如, array( 'categories' => 'Categories' ).

在以下文件中用到

  • components/com_search/models/search.php
  • plugins/search/categories.php
  • plugins/search/contacts.php
  • plugins/search/content.php
  • plugins/search/newsfeeds.php
  • plugins/search/tags/tags.php
  • plugins/search/weblinks.php


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)