When crafting HTML for Venddor IO modules, it's essential to maintain consistency and clarity. Follow these simple guidelines to ensure clean and organised code:
For example: Instead of <DIV CLASS="example">, use <div class="example">.
For example: <img src="path/to/image.jpg" alt="description">.
While structuring, avoid excessive indentation between related elements like <tr> and <table>.
By adhering to these guidelines when developing for Venddor IO modules, you'll ensure that your code remains neat, easily maintainable, and in line with best practices.
<html>
<head>
</head>
<body>
<div id="header">Header</div>
<div id="contents">
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
<h7>Some table data</h7>
<div id="table_data">
<table cellpadding="0" border="0">
<tr>
<td>
....
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
For an effective and clean Venddor IO module development, adhere to the following guidelines when working with Smarty tags:
<!DOCTYPE html>.Correct: <hr width="100%" />
Incorrect: <br>
Correct: <b><i>text</i></b>
Incorrect: <b><i>text</b></i>
Use of "&": Avoid using the "&" symbol directly within the HTML body. Instead, opt for &.
When dealing with checkboxes, the general practice is to send a capitalised "Y" for selected boxes. For checkboxes that aren't ticked, the value should be "N". Here's how it's done:
<input type="hidden" name="product_data[is_selected]" value="N" />
<input type="checkbox" name="product_data[is_selected]" value="Y" />
Correct: <div id="box_params_1234"></div>
Incorrect: <div id="1212asd[sdsd]"></div>
It's best practice to avoid using classes and IDs to reference elements. Instead, utilise more semantic or descriptive ways to target them.
When a Smarty variable is part of an HTML parameter or JavaScript code, always escape its content. This ensures that any single or double quotes within the variable don't cause errors.
<script language="javascript">
var param = '{$smarty.get.param|escape:javascript}';
</script>
...
<input type="text" name="aa" value="{$param|escape:html}">
Avoid using the javascript: prefix. Instead of using JavaScript code directly within an element, opt for event handlers. For instance, you can utilize microformats.
<a href="index.php" class="cm-submit-form">
Ensure all function definitions end with semicolons (;). This ensures clarity and avoids potential errors in execution.
Style names should be descriptive and clear. Use lowercase letters for style names and use dashes (-) for separating words.
.dialog-box {
font-size: 12px;
font-weight: 10px;
}
Generally, sizes should be specified using absolute values (like px). In specific situations, relative values might be more suitable.
Organise the CSS file into logical sections and use comments to demarcate them. This enhances readability and maintenance.
When passing flag parameters to templates, use true/false values. Avoid using values like "Y/N".
{include file="common/price.tpl" value=$price hide_sign=true}
Instead of str_replace, use the replace modifier.
Only use double quotes in templates, with the sole exception being JavaScript.
To display curly brackets, avoid using $ldelim or ldelim unless the opening and closing brackets are on the same line. This enhances clarity.
Opt for short notations when assigning values to variables. This is more concise and clearer.
{$test = 123}