在 Joomla ! 1.5 中的 data model 主要由三個 elements 所構成, 分別是 article, category, 以及 section. 按照 Joomla ! 給的 glossary 說明, 三者的關係是這樣 ( 以 article 的 glossary 說明就可看出 ) :
可以看到這三個 elements 是階層式的結構, section 是 categories 的 container, 而 category 是 articles 的 container. 同時注意說明中提到的 "particular", 亦即一篇 article 對應到特定的一個 category 以及一個 section.
Article : Discrete piece of content within the Joomla! hierarchy, which may be associated with a particular Section/Category combination or may be an Uncategorized Article; usually displayed in the main body of your page. Within the content hierarchy, a Section is the top level and is a container for Categories. A Category is the next level and is a container for the third level, which is the Article.
如果再參考後端管理介面, 在你新增一個 article, category 時的 template 選項, 或是到 database 中看 prefix_categories table (prefix 跟你安裝時的設定有關) 的話, 會發現一個 category 只能會對應到一個 section, 同時 category 雖然有 parent 的欄位, 但是並沒有被使用到. 如果畫成簡易 UML 圖的話, 三者的關係大概是像這樣 :

這樣的 data model 規劃讓使用者其實比較沒有彈性去 organize 內容, 因而會出現為了把一篇 article 分到多個 category, 而要把同樣的內容複製到不同的 articles 內, 再分別指定 categories 的情況出現.
解決的方法要不就是修改這個 data model ( 但是連帶的 database schema 可能也要修改 ), 要不就是在 Joomla ! 的內部邏輯作處理, 利用 category 內的 parent 欄位, 製造出 category 的 hierarchy, 而在 Joomla ! 內部, 當要呈現某一個 category 的 articles 時, 會自動去尋找 child category 內的 articles 作 aggregation, 但是這可能會有 performance 的問題. 此時上圖就會修正成下面這樣 :

既然 forum 上已經有討論的聲音出現了, 不知道 Joomla ! 開發團隊會怎樣處理. 如果是採用第一及第二種作法, 我認為在 Joomla ! 1.5 Stable 應該不可能出現, 因為現在都 RC4 了, 該會留到下一個版本. 因此先採取方法三, 再於之後的版本整合 meta-keys 跟 category 或許會是比較好的策略吧.
沒有留言:
張貼留言