Maybe I want to add a new view
, and also a new Menu Item Type
to content component.
What are the steps please?
UPDATE
Question (by @ValentinDespa
) :
You want to extend com_content functionality or you want to override a view or to build a new component that does something?
As I said, I want to extend com_content
and add a new view to it. There are some views like Single Article
, Category Blog
, and Category List
right now.
I want to add another menu items called Article Titles
, so titles only will be displayed but with some parameters (like columns count).
It is a need that is not supplied by current features.
NOTE
Guys, it doesn't matter what my new view should be like, please tell me How to create a new view.
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
来源:https://stackoverflow.com/questions/13488723/how-to-add-a-new-view-and-also-a-new-menu-item-type-to-existing-joomla-2-5-com