How to add a new view (and also a new Menu Item Type) to existing joomla 2.5 components?

大兔子大兔子 提交于 2019-11-30 21:54:04

Yes You can create a new view.

Its simple just copy any of the view (category,blog) from your com_content.

The file structure should be like inside the folder.

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.

Then you can access this view by giving correct url. eg: www.example.com/index.php?option=com_content&view=yourviewname&layout=yourlayoutnames.

Here I mentioned view folder name must be controller and model file name we can achieve with other name also but it will create problem for you when you are not good in joomla.

Note: For adding a view you don't need to install a component its not a good idea at all.

Also You can add multiple layouts in a view inside your tmpl folder just create new files.Also don't miss the controller and model to put in com_contents/controller and com_contents/model folder

for More help take a look at this

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!