如何向现有的 joomla 2.5 组件添加新视图(以及新的菜单项类型)?

2023-10-11php开发问题
0

本文介绍了如何向现有的 joomla 2.5 组件添加新视图(以及新的菜单项类型)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

也许我想向内容组件添加一个新的 view,以及一个新的 Menu Item Type.

Maybe I want to add a new view, and also a new Menu Item Type to content component.

请问步骤是什么?

更新

问题(来自@ValentinDespa):

您想要扩展 com_content 功能或您想要覆盖查看或构建一个新组件来做某事?

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 并向其添加一个新视图.现在有一些视图,例如Single ArticleCategory BlogCategory List.

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.

我想添加另一个名为 Article Titles 的菜单项,这样只会显示标题,但带有一些参数(如列数).

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.

注意

伙计们,我的新视图应该是什么样的并不重要,请告诉我如何创建新视图.

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.

很简单,只需从您的 com_content 中复制任何视图(类别、博客).

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.

然后您可以通过提供正确的网址来访问此视图.例如:www.example.com/index.php?option=com_content&view=yourviewname&layout=yourlayoutnames.

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

这里我提到视图文件夹名称必须是控制器和模型文件名,我们也可以用其他名称来实现,但是当你不擅长 joomla 时,它会给你带来问题.

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.

您也可以在一个视图中添加多个布局在您的 tmpl 文件夹内只需创建新文件.另外不要错过控制器和模型放入 com_contents/controller 和 com_contents/model 文件夹

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

更多帮助看看这个

这篇关于如何向现有的 joomla 2.5 组件添加新视图(以及新的菜单项类型)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

PHP实现DeepL翻译API调用
DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以...
2025-08-20 php开发问题
168

PHP通过phpspreadsheet导入Excel日期数据处理方法
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的...
2024-10-23 php开发问题
287

mediatemple - 无法使用 codeigniter 发送电子邮件
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)...
2024-08-23 php开发问题
11

Laravel Gmail 配置错误
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)...
2024-08-23 php开发问题
16

将 PHPMailer 用于 SMTP 的问题
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)...
2024-08-23 php开发问题
4

关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)...
2024-08-23 php开发问题
17