Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h1>OpenCart 2.x</h1> <p>The path names have changed in OpenCart 2 - you will want to create</p> <p><code>admin/controller/extension/module/hello.php admin/language/en-gb/extension/module/hello.php admin/view/template/extension/module/hello.tpl </code> Then the route becomes </p> <p><code>admin/index.php?route=extension/module/hello</code></p> <h1>OpenCart 1.x</h1> <ul> <li>Include full MVC flow.</li> </ul> <p>I found out how to do this. OpenCart uses the MVC pattern. I recommend reading about <a href="https://stackoverflow.com/questions/13478995/how-to-become-an-opencart-guru">How to be an OpenCart Guru?</a> post about learning how the system works - this Admin workflow should also suffice for customer end.</p> <p>1) Create a new file in <code>admin/controller/custom/helloworld.php</code></p> <p>Your filename and controller name should be the same in desc order:</p> <p><strong>helloworld.php</strong></p> <pre><code>&lt;? class ControllerCustomHelloWorld extends Controller{ public function index(){ // VARS $template="custom/hello.tpl"; // .tpl location and file $this-&gt;load-&gt;model('custom/hello'); $this-&gt;template = ''.$template.''; $this-&gt;children = array( 'common/header', 'common/footer' ); $this-&gt;response-&gt;setOutput($this-&gt;render()); } } ?&gt; </code></pre> <p>2) Create a new file in <code>admin/view/template/custom/hello.tpl</code></p> <p><strong>Hello.tpl</strong></p> <pre><code>&lt;?php echo $header; ?&gt; &lt;div id="content"&gt; &lt;h1&gt;HelloWorld&lt;/h1&gt; &lt;?php echo 'I can also run PHP too!'; ?&gt; &lt;/div&gt; &lt;?php echo $footer; ?&gt; </code></pre> <p>3) Create a new file in <code>admin/model/custom/hello.php</code></p> <pre><code>&lt;?php class ModelCustomHello extends Model { public function HellWorld() { $sql = "SELECT x FROM `" . DB_PREFIX . "y`)"; $implode = array(); $query = $this-&gt;db-&gt;query($sql); return $query-&gt;row['total']; } } ?&gt; </code></pre> <p>4) You then need to enable the plugin to avoid permission denied errors:</p> <pre><code>Opencart &gt; Admin &gt; Users &gt; User Groups &gt; Admin &gt; Edit </code></pre> <p>Select and Enable the Access Permission.</p> <p>To visit your page go to</p> <p><strong>www.yoursite.com/opencart/admin/index.php?route=custom/helloworld</strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload