2.0 Development Conventions

Source: Internet
Author: User

Development practices

(1) Do not use super global variable $_get,$_post,$_request,$_files,$_server,

Use Jinput instead, jfactory::getapplication ()->input

(2) Do not write native SQL queries, use Jdatabase/jdatabasequery instead,

Jfactory::getdbo ()->getquery (true);

(3) Do not provide the entrance, using components or plug-in instead.

(4) Do not create wheels repeatedly.

(5) The use of meaningful prefixes is most indicative

(6) Convert external input using Jtext.

Where the javascript,css,image under its own component should be placed.

As you see, jpath_root/media/com_name can store all these files. Asset directories under their own components can also be stored.

Where the component-generated files are placed

Temporary files, the Web server cannot be accessed, Jfactory::getconfig ()->get (' Tmp_path ') do not use Jpath_root. ' /tmp '

Cache file, Web server not accessible, Jpath_cache

cache files, Web server can access, media/subdirectories

Persistent files, the Web server cannot be accessed, placed in a subdirectory of the component, and given a. htaccess file

Persistent files, Web server accessible, media/subdirectories

If you want to manage logs using the Jlog class

About JavaScript

(1) End with a semicolon and another line

(2) Ensure that your code is valid and does not throw errors

(3) using Try/catch

(4) write the JS code in the file in the Tmpl directory, not in the View class (view.html.php)

(5) Do not modify the native code, if you want to do it, create a subclass

(6) Do not modify the code of other programmers

2.0 Development Conventions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.