简体   繁体   中英

jquery plugin in zend framework

I recently started working on a website with zend framework. I am trying to include simple jquery plugins but i have no idea what is the proper way to include them.

I have found the main index.phtml sites but none of them have a element nor the php code to include the javascript as shown in this question . I also dont have a layout.phtml file on my server.

So where are all the javascript files added? I been looking for them everywhere but cant find them. Where should i link my own jquery plugins and javascript files.

Any help on this would be appreciated I am new to zend framework.

Default location for layout files is in application/layouts but you can check in application/configs/application.ini for resources.layout.layoutPath to check where they are. There is a chance that your project does not use layouts (they are not required part of zend).

You can try looking for <HTML> or <HEAD> tags or by js file names in all project files to find where they are added.

Proper way of adding them is by using helper headScript() (usually for scripts in header of page) or/and inlineScript() (this is confusing name because usually used at bottom of page) like this:

$this->headScript()->prependFile('/js/jQuery.js'); //this add to list of files
$this->inlineScript()->appendFile('/js/main.js');

Then add in layout:

echo $this->headScript() //this will actually print files from list
echo $this->inlineScript() 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM