|
Table of Contents
Coding guidelineWe all have different ways to write our code. That's okay, if you are working alone on a project, but it will become a mess when more people are working on it. That's why pluck-cms has some coding rules, or a way the code should be written. There are a few reasons for this:
Newline styleIn text files, a newline is signified by a character. You don't notice anything of this, because that character is automatically inserted by the text editor you use to write your code. It's important to know however, that there are different ways too signify a new line. The two most used are listed below.
For pluck, we have chosen to work with Unix style newlines (LF). When writing code for pluck, please make sure the text editor you are using is set to LF. This is important, because otherwise the markup of the code might get messed up. Next to that, Bazaar (the Version Control System we use for pluck) likes LF better. HTMLComing soon… CSSCSS should be formated like this: html, #foobar { color: white; background-color: black; } PHP - NOTE: This part is not finished!GeneralUse ' and not ":WRONG: echo "test"; RIGHT: echo 'test';
WRONG: echo "$test\n"; RIGHT: echo $test."\n";
WRONG: echo'test'; RIGHT: echo 'test'; Control StructuresControl Structures should have a space between the statement and the first parametrise, but not between the expression(s) and the parentheses. There should also be a space between the last parametrise and the first brace: WRONG: require_once( 'test.php' ); if( $test == true ){ $test = 'hello'; return$test; } RIGHT: require_once ('test.php'); if ($test == true) { $test = 'hello'; return $test; }
WRONG: if ($test == true) { return $test; } RIGHT: if ($test == true) return $test; FunctionsWhen calling a function, there should be no space around the parentheses: WRONG: isset ( ); isset ( $test ); RIGHT: isset(); isset($test); Predefined functions and constantsDon't try to reinvent the wheel; when working on pluck, you can use the predefined functions and constants. These functions and constants are stored in these files:
The functions and constants defined in a file containing all can be used in both the admin center and the code of the website. Functions and constants with admin can only be used in the admin center, and with site can only be used in the website. The functions and constants are explained on this wiki on the pages listed below. If you add a function/constant, please add a description to the page on the wiki. This makes it easier for other developers and module developers to work on pluck efficiently. |