Skip to content

Opencart Html Helper provides a set of static methods for generating commonly used HTML tags.

Notifications You must be signed in to change notification settings

8sun/opencart-html-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

opencart-html-helper

Opencart Html Helper provides a set of static methods for generating commonly used HTML tags.

This module from Yii2 Framework is adapted by Mefistophell Nill and Zoturn (8sun Empire) for OpenCart.

This module includes another module from Yii2, which we adapted and you can use it separately. The link to the module is shown below.

ArrayHelper - provides additional array functionality that you can use in your application.

Tested on Opencart 2.0. If you find an error, let us know.

Version: 0.9.1

Install

  1. You need to copy the files to the directory /system/helper/.

  2. Further, add the Helpers to /system/startup.php as shown below:

require_once(DIR_SYSTEM . 'helper/Html.php');
require_once(DIR_SYSTEM . 'helper/ArrayHelper.php');
require_once(DIR_SYSTEM . 'helper/BaseJson.php');
require_once(DIR_SYSTEM . 'helper/InvalidParamException.php');

Usage

Just use the Helpers in your template files. You can get something like this:

...
<td>
  <?php echo Html::input("text", $attribute, $value, ["class" => "form-control", "placeholder" => "comment"]) ?>
</td>
<td>
  <?php echo Html::dropDownList($name, $value, $selected, ["class" => "form-control"]); ?>
</td>
<td>
  <?php echo Html::button(
  Html::tag("i", "", ["class" => "fa fa-minus-circle"]), 
  ["class" => "btn btn-danger", "title" => "Delete"]) ?>
</td>
...

Here is a list of available features

MethodDescription
a() Generates a hyperlink tag.
addCssClass() Adds a CSS class (or several classes) to the specified options.
addCssStyle() Adds the specified CSS style to the HTML options.
beginForm() Generates a form start tag.
beginTag() Generates a start tag.
button() Generates a button tag.
buttonInput() Generates an input button.
checkbox() Generates a checkbox input.
checkboxList() Generates a list of checkboxes.
cssFile() Generates a link tag that refers to an external CSS file.
cssStyleFromArray() Converts a CSS style array into a string representation.
cssStyleToArray() Converts a CSS style string into an array representation.
decode() Decodes special HTML entities back to the corresponding characters.
dropDownList() Generates a drop-down list.
encode() Encodes special characters into HTML entities.
endForm() Generates a form end tag.
endTag() Generates an end tag.
escapeJsRegularExpression() Escapes regular expression to use in JavaScript
fileInput() Generates a file input field.
getAttributeName() Returns the real attribute name from the given attribute expression.
hiddenInput() Generates a hidden input field.
img() Generates an image tag.
input() Generates an input type of the given type.
jsFile() Generates a script tag that refers to an external JavaScript file.
label() Generates a label tag.
listBox() Generates a list box.
mailto() Generates a mailto hyperlink.
ol() Generates an ordered list.
passwordInput() Generates a password input field.
radio() Generates a radio button input.
radioList() Generates a list of radio buttons.
removeCssClass() Removes a CSS class from the specified options.
removeCssStyle() Removes the specified CSS style from the HTML options.
resetButton() Generates a reset button tag.
resetInput() Generates a reset input button.
script() Generates a script tag.
style() Generates a style tag.
submitButton() Generates a submit button tag.
submitInput() Generates a submit input button.
tag() Generates a complete HTML tag.
textInput() Generates a text input field.
textarea() Generates a text area input.
ul() Generates an unordered list.

A full list of the features you can find on Yii2 reference: http://www.yiiframework.com/doc-2.0/yii-helpers-html.html

However, please note that given classes do not have all the features!

About

Opencart Html Helper provides a set of static methods for generating commonly used HTML tags.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages