如何在 Joomla 中添加自定义 PHP?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16290624/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to add custom PHP in Joomla?
提问by Bimba Shrestha
I'm having a very difficult time putting custom code into my first Joomla website. Is Joomla seriously limited to only the extensions and modules that they already provide? How can I customize it with my own PHP code?
我很难将自定义代码放入我的第一个 Joomla 网站。Joomla 是否严重仅限于它们已经提供的扩展和模块?如何使用我自己的 PHP 代码自定义它?
采纳答案by Lodder
I've needed to do this multiple times with Joomla, so I always go for Sourcerer. It's a free Plugin that allows you to add custom code, such as CSS, Javascript and PHP to articles. Below is an example of how easy it is to be done:
我需要使用 Joomla 多次执行此操作,因此我总是选择Sourcerer。它是一个免费插件,允许您向文章添加自定义代码,例如 CSS、Javascript 和 PHP。下面是一个简单的例子:
{source}
<?php
echo '<p>';
echo 'Hello';
echo '</p>';
?>
{/source}
回答by Tom
Is joomla seriously limited to only the extensions and modules that they already provide.
joomla 是否严重仅限于他们已经提供的扩展和模块。
Absolutely not. Joomla is quite rich when it comes to customization. All those extensions and modules is something that people have created using the rich interfaces available.
绝对不。Joomla 在定制方面非常丰富。所有这些扩展和模块都是人们使用可用的丰富接口创建的。
The wealth of information is here.
丰富的信息就在这里。
In terms of customization there are 3 main things to look at:
在定制方面,有3个主要方面需要考虑:
Plugins- event driven and fairly easy to do
插件- 事件驱动且相当容易实现
Modules- where you put small capabilities across your website; very easy to do
模块- 您可以在网站上放置小功能;很容易做到
Components- definitely the most complex (don't start with this) but this will create the main functional unit. I use this for more complex applications
组件- 绝对是最复杂的(不要从这个开始),但这将创建主要功能单元。我将它用于更复杂的应用程序
Your php experience will be put to good use.
您的 php 经验将得到很好的利用。
回答by Django
turn off the editor first -> goto module manager -> add customHTML module -> paste your code (php, html, javascript, css etc) and save... nastiest and quickest way of doing what you want.
首先关闭编辑器 -> 转到模块管理器 -> 添加 customHTML 模块 -> 粘贴您的代码(php、html、javascript、css 等)并保存...做您想做的事情的最讨厌和最快捷的方式。
editor off because otherwise it'll clean up your code...
编辑器关闭,否则它会清理你的代码......
after that, try to create your own module/plugin to suit your needs (see links above @Tom), then make a lite and pro version and make money... all it needs is a good idea xD
之后,尝试创建自己的模块/插件以满足您的需求(请参阅@Tom 上面的链接),然后制作精简版和专业版并赚钱......它需要的只是一个好主意 xD
回答by user2046410
Based from my experience, Joomla is very powerful and everything that we want was provided because there are a lot of components and modules on the internet. Sometimes I edit the component or the module that I downloaded. Just go to the folder and you will see the codes from there you can edit it. Or you can create your own module or component based on the needs of your client
根据我的经验,Joomla 非常强大,因为互联网上有很多组件和模块,所以我们提供了我们想要的一切。有时我会编辑我下载的组件或模块。只需转到该文件夹,您就会看到那里的代码,您可以对其进行编辑。或者您可以根据客户的需求创建自己的模块或组件