-
Notifications
You must be signed in to change notification settings - Fork 3
Usages
Mudzakkir edited this page Nov 6, 2021
·
12 revisions
Table of Contents
When you visit the module setting, you will see the module dashboard which have the Manage, Gist and Help tabs.
You can start to insert new widget with Insert button on the top right; once saved, the module list will show up at Manage tab.
Note: The OpenCart API syntax used in the editor might be different depend on your OpenCart version.
- Name, required widget name.
- Note, only show up at widget listing.
- Editor, control the editor visibility.
- Status, widget status.
Important:
- When the editor is hidden (unchecked); editor content is preserved while related file, modification and event entry removed.
- When the status is disabled; editor content and related file is preserved, modification status updated to disabled while event entry removed.
-
Controller::index()
is default entry method when the widget assigned to page Layout (Admin > Design > Layout
). - Example of Controller code with codetags placement.
<?php
class {controller_class} extends Controller
{
// $setting contain all widget setting
public function index($setting = array())
{
$data = array();
// Your code here..
return $this->load->view('{template_path}', $data);
}
}
- Example of Model code with codetags placement.
<?php
class {model_class} extends Model
{
/**
* How to use at controller:
* $this->load->model('{model_path}');
* $setting = $this->{model_call}->arcSetting();
*/
public function arcSetting()
{
return $result = $this->db->query(
"SELECT *
FROM `" . DB_PREFIX . "setting`
WHERE `code` = 'architect'"
)->rows;
}
}
- Example of Template code with codetags placement.
<div class="module architect arc-{module_id}">
<div class="module-heading">
<h3>...</h3>
</div>
<div class="module-body">
...
</div>
</div>
<script>
// Your code here..
</script>
- OpenCart Modification (OcMod) status follow the widget status.
- To apply OcMod manual refresh is required at
Admin > Extension > Modifications
. - Modification usage in OpenCart, please refer to Modification documentation.
- Example of OcMod code with codetags placement.
<?xml version="1.0" encoding="utf-8"?>
<modification>
<name>{ocmod_name}</name>
<version>1.0</version>
<link>...</link>
<author>{author}</author>
<code>{ocmod_code}</code>
<file path="...">
<operation error="skip">
<search><![CDATA[ ... ]]></search>
<add position="after"><![CDATA[ ... ]]></add>
</operation>
</file>
</modification>
- When widget status is disabled, event entry will be removed from database.
- Event use DocBlocks Annotation for the
trigger
,action
andorder
setting. - Event usage in OpenCart, please refer to Event documentation.
- Example of Event code with codetags placement.
<?php
class {event_class} extends Controller
{
/**
* @trigger catalog/controller/common/footer/before
* @action {event_path}/foo
* @order 99
*/
public function foo(&$route, &$data)
{
// Your code here..
}
}
- Have a special method
onSave()
andonDelete()
as an internal hook for widget action. - Example of Admin Controller code with codetags placement.
<?php
class {admin_controller_class} extends Controller
{
/**
* Executed everytime the widget saved
*/
public function onSave($setting = array())
{
// Your code here..
}
/**
* Executed when widget deleted or Architect uninstalled
*/
public function onDelete($setting = array())
{
// Your code here..
}
}
When all options evaluated to true then widget entrance controller::index()
will be executed. This options not affecting Model, Template, Modification or Event.
- Customer Group, check if customer belong to selected customer group.
- Date Duration, widget will be published in duration of the date.