We all know how to use javascript in the page, then we in the design of Catfish CMS plug-in can also use javascript? The answer is of course yes, and the use of javascript in the plugin is also very simple.
Here, let's take a look at how to use javascript in the plugin.
Still use the system comes with the announcement plug-in example, assuming that we want to join the plug-in javascript code, how to do it?
There are two ways:
One is directly to the javascript code and html code mixed into the plug-in (plug-in how to make reference please refer to this site related articles)
The second method is to put the javascript code into a separate file, and then in the plug-in reference to this file.
The first method is very simple, when the javascript code is not very complicated circumstances, we can directly use the first method. But when the code is more complicated, if you still mix with the html code, you may feel that the code is not concise, then we can use the second method, the javascript code in a separate file.
The following figure is the simplest plugin that contains only one file:
Now we hope to be able to use javascript in the plug-in, we first in this file where the folder to create a new folder, named "js", as shown below:
Then we built a javascript file in the "js" folder, assuming we built a file called "announcement.js". Then we will come to the realization of the js file to the plug-in.
As with the reference style file, we need to use the built-in function "$this->import()", the actual code is as follows:
$this->import('js/announcement.js')
Then we assign it to $data with the html code, and finally display the content with the built-in function "add".
Very simple, as long as a simple line of code can refer to the external javascript file.
Original article, reproduced please specify:So verwenden Sie Javascript in Plug-in | Catfish(鲶鱼) CMS
我们在做主题的时候,有时需要在页面单独显示当前菜单下的二级菜单,这个在鲶鱼系统里面有两种...
由于PHP软件的运行都需要服务器运行环境,虽然可以找到很多PHP的集成环境来使用,但是多...
我们在使用博客网站的时候,经常会希望对自己发布的文章进行归档处理,例如每个月发布了哪些文...
鲶鱼系统可以使用找回密码功能,但是在开启找回密码功能之前,我们必须要进行一项设置,就是S...
现代程序开发多是使用框架来写应用程序,因为框架可以带来事半功倍的效果。对于PHP程序也是...
鲶鱼cms系统5.2.0版以及鲶鱼Blog系统3.2.0版在编辑文章页面新增了上传附件功...
Management background is composed of five bl...
In the previous section, we talked about how...
In the previous section we talked about how ...
To the last section we have learned to use t...
By the end of the previous section, we have ...