也许我想向内容组件添加一个新的 View
,以及一个新的Menu Item Type
。
请问有哪些步骤?
更新
问题(来自 @ValentinDespa
):
You want to extend com_content functionality or you want to override a view or to build a new component that does something?
正如我所说,我想扩展 com_content
并向其添加一个新 View 。目前有Single Article
、Category Blog
和Category List
等 View 。
我想添加另一个名为 Article Titles
的菜单项,这样只会显示标题但带有一些参数(例如列数)。
这是当前功能无法满足的需求。
注意
伙计们,不管我的新 View 应该是什么样子,请告诉我如何创建一个新 View 。
最佳答案
是的,您可以创建一个新 View 。
只需从您的 com_content 复制任何 View (类别、博客)即可。
文件结构应该和文件夹内的一样。
Step 1
view.html.php
tmpl
your layout names(default.php)
xml file.
Also remember to change the class name of the view.html.php
Step 2
Add a controller file (just make a copy of existing one category or blog)
Controller name must be your new view folder name.
Also remember to change the class name of the controller
step 3
add a model file for your new view (same make copy of any existing)
remember to change the class name and file name should be view folder name.
然后您可以通过提供正确的 url 来访问此 View 。 例如:www.example.com/index.php?option=com_content&view=yourviewname&layout=yourlayoutnames。
这里我提到 View 文件夹名称必须是 Controller 和模型文件名称,我们也可以用其他名称来实现,但是当你不擅长 joomla 时,这会给你带来问题。
注意: 要添加 View ,您不需要安装组件,这根本不是一个好主意。
您还可以在一个 View 中添加多个布局 在你的 tmpl 文件夹中创建新文件。也不要错过 Controller 和模型放入 com_contents/controller 和 com_contents/model 文件夹
更多帮助 take a look at this
关于php - 如何向现有的 joomla 2.5 组件添加新 View (以及新的菜单项类型)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13488723/