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
鲶鱼cms系统5.2.0版以及鲶鱼Blog系统3.2.0版在编辑文章页面新增了上传附件功...
我们在《鲶鱼CMS和鲶鱼Blog怎么自定义注册页面》一文里面介绍了如何通过制作主题文件来...
在实际建站过程中,往往需要进行网站备案,那么当我们备案之后,需要按要求在自己网站上放上备...
鲶鱼Blog系统可以在后台上传升级包进行升级,有些用户可能会很长时间没有升级,这样可能会...
我们在《鲶鱼CMS和鲶鱼Blog怎么自定义登录页面》一文里面介绍了怎么在制作主题的时候自...
我们在《 鲶鱼CMS和鲶鱼Blog怎么自定义登录页面》这一篇里面介绍了如何自己制作一个登...
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 ...