Post by jedipi » Tue Sep 11, 2012 9:39 am

Image

Module Apps - Custom Apps into OpenCart

Module Apps is module which can extend your OpenCart with custom code in your own coding style.

Highlight
================
include php, html, javascript scripts, or css into any modules position
Develop you applications in your own way
Pass any number of arguments

With Module Apps
================
  • * you can develop your module in your favors style without learning OpenCart MVC coding style.
    * you can include php, html, javascript scripts, or css into the modules position,
    * you can even include static html or txt pages into your pages without using iframe,
    * you have full access to OpenCart variables, functions, constants, etc. in your php scripts.
Module Apps is ideal solution for
=============================
  • *including banners or text ads into your OpenCart site: no matter if your own or affiliates ones,
    * easy and fast inclusion of smart javascript, php, html and dhtml scripts into your Opencart position,
    * fast development of not only small and simple customized modules solutions based on php, javascript and html or dhtml scripts like flash shows, ads and picture presentations, forms inclusion, etc. But for the development of more complex solutions including database data processing.
Demo
==========
Front: http://demo.thyconsultants.net/opencart ... ount/login
Admin: http://demo.thyconsultants.net/opencart/index.php
(Username: demo Password:demo)

Download
==========
http://www.opencart.com/index.php?route ... on_id=8204


Image

Image

Image Image Image

Australian Bank Transfer

Find out all my extensions here


User avatar
Active Member

Posts

Joined
Sat Jul 14, 2012 11:06 am
Location - Victoria, Australia

Post by jedipi » Tue Sep 11, 2012 10:09 am

Demo usage
==========

I am going to show you an example usage of Module Apps here: including a very simple script files and using Module Apps arguments.

This is the live examples can be seen throughout our demo website:

PHP code module_apps_demo.php with arguments
The result of this example script can be seen on our live demo website here.
http://demo.thyconsultants.net/opencart ... ount/login

It gives you this

Code: Select all

Hello in the world of Module Apps!

This is the default Module Apps demo file "module_apps_demo.php".

The real strength and great flexibility of Module Apps is its ability to pass any number of argument values into your php scripts very easily. Values can be referenced by $apps[] array in your code.

Your current content of $apps[] array is:

    $apps[0] = Hello World!!
    $apps[1] = Hello
There is the step to achieve the result shown above.
1. create a folder "module_apps_demo"
2. create a file inside this folder with a name "module_apps_demo.php"
3. open "module_apps_demo.php" with your favors text editor
4. copy & paste the code below

Code: Select all

<p><strong>Hello in the world of Module Apps!</strong></p>
<p>This is the default Module Apps demo file "module_apps_demo.php".</p>
<p>The real strength and great flexibility of Module Apps lies in its ability to pass practically any number of argument values into your php scripts very easily. Values can be referenced by $apps[] array in your code.</p>
<p>Your current content of <b>$apps[]</b> array is:</p>
<?php
   if (!empty($apps)){
      echo "<ul>\n";
      foreach ($apps as $key => $value) {
   	  echo '<li>$apps['.$key.'] = '.$value.'</li>';
   	}
   	echo "</ul>\n";
	}
	else {
		echo "<p>empty</p>";
	}
	echo $this->language->get('heading_title');
?>
5. save and upload the whole folder to OpenCart root directory
6. log into your Opencart store as administrator
7. setup your Module Apps use the setting below.
Note: each argument has to inside the brackets [], anything outside the brackets will be omitted.
An argument can contain any characters. It will put into the $apps[] array.
Image
8. enable your module and save.

That's it. Hope that it works for you.

Image

Image Image Image

Australian Bank Transfer

Find out all my extensions here


User avatar
Active Member

Posts

Joined
Sat Jul 14, 2012 11:06 am
Location - Victoria, Australia

Post by jedipi » Sat Sep 15, 2012 10:02 am

With ModuleApps, you can develop your own modules and applications very quickly and easily.

You should have some basic knowledge of HTML, PHP, JavaScript, and CSS. There are thousands of small or big applications are available on Internet for free. You can just implement them into to your OpenCart environment.

If you are not familiar with those languages, I recommend you read some tutorials on http://www.w3schools.com/
I also recommend you to study the demo and code snippets which attached in this post.

After you have finished tests of your custom code, you are recommended to add the following lines at the very beginning of your code. They are very important for security reasons!

Code: Select all

<?php
defined('DIR_SYSTEM')OR die( "Direct Access Is Forbidden" );
?>
This code basically just stop direct access to your applications

After you had done with your application and upload it to your server. Then you can just include it into your ModuleApps module.

it's easy, Right?

Now your application is "living" inside OpenCart environment.
That meas your application have full access to all OpenCart global variables, objects, and methods.


I wish the official OpenCart API documentation can be done in near future.

Image

Image Image Image

Australian Bank Transfer

Find out all my extensions here


User avatar
Active Member

Posts

Joined
Sat Jul 14, 2012 11:06 am
Location - Victoria, Australia

Post by jedipi » Thu Oct 11, 2012 1:59 pm

Create a simple RSS reader for Module Apps

I am showing how to create a simple application for Module App to retrieve the data from a RSS feed. Data are cached in a cache directory for 1 hours.
  • 1. First we create a php file and name it rss_reader.php

    2. Then copy and paste the following code below into rss_reader.php

    3. Add a Module App in extension section of your OpenCart admin panel

    4. Fill in the correct path for this application. In this example, we use "module_apps_demo/rss_reader.php"

    5. Argument value should be [http://www.opencart.com/index.php?route ... ension/rss][1200]
    first argument is the RSS feed address, second argument is how many minutes the cache file should be kept.

    6. Save, and don't forget to enable this new module.

Code: Select all

<?php defined('DIR_SYSTEM')OR die( "Direct Access Is Forbidden" );
/* get argument value*/
$rss_url    = $apps[0];
$cache_time = $apps[1]; 
$cache_file_name  = 'module_apps_demo/cache/'.md5($rss_url);

if(file_exists($cache_file_name) && (strtotime('now') - filemtime($cache_file_name) < $cache_time)) {
    $rss = file_get_contents($cache_file_name); // get feed from cache file
} else {
    $rss = file_get_contents($rss_url); // get feed from server
    
    if(strlen($rss) > 3000)
        file_put_contents($cache_file_name, $rss); // cache content
}

$rss = simplexml_load_string($rss);

echo '<h1>'. $rss->channel->title. '</h1>'. "\n";
echo '<h2>'. $rss->channel->description. '</h2>'. "\n";

foreach($rss->channel->item as $item) {
    echo '<h4><a href="'. $item->link. '">'. $item->title. '</a><div>'. $item->pubDate. '</div></h4>'. "\n";
    echo $item->description. "\n";
}
?>
Note:
1. This rss reader requires PHP SimpleXML library.Your host must support PHP SimpleXML library.
2. Support RSS version 2.0 only. You need to modify it if you want to retrieve data from other type of data feeds.

Attachments

Simple RSS Reader for Module App

Last edited by jedipi on Tue Nov 06, 2012 7:41 am, edited 1 time in total.

Image

Image Image Image

Australian Bank Transfer

Find out all my extensions here


User avatar
Active Member

Posts

Joined
Sat Jul 14, 2012 11:06 am
Location - Victoria, Australia

Post by jedipi » Tue Nov 06, 2012 7:15 am

With Module Apps, You can use Google's free service to create forms and include them into your OpenCart website.

In this example, I will show you how to create a simple survey form and include it into OpenCart website with the power of Module Apps.


Prerequests:

First of all, this service is provide by Google, you need to have Google account to use it. I am sure all of you have a Google account already. In case you don't, please follow this link: New Account

Also, you need to have some basic knowledge for using Google Documents.


Copy the code provided by Google.
1. Create new form and click to Embed form
2. Copy the code provided by Google.

Create an app
Now we create a file with the name google_form.php
Open it with your favor text editor.
Paste the code into the google_form.php. Don't forget to include the code for security.
The whole file would look something like this

Code: Select all

<?php defined('DIR_SYSTEM')OR die( "Direct Access Is Forbidden" ); ?>

<iframe src="https://docs.google.com/spreadsheet/embeddedform?formkey=dHljLVhzU2FQQWNzV3RZdkYxMlMyZFE6MQ" width="100%" height="715" frameborder="0" marginheight="0" marginwidth="0">Loading...</iframe>

Publish your Apps
1.Add a Module App in extension section of your OpenCart admin panel

2. Fill in the correct path for this application. In this example, we use "module_apps_demo/google_form.php"

3. leave the Argument value empty.

5. Save, and don't forget to enable this new module.

Check out the live demo of this example here: http://demo.thyconsultants.net/opencart ... ount/login

Image

Image Image Image

Australian Bank Transfer

Find out all my extensions here


User avatar
Active Member

Posts

Joined
Sat Jul 14, 2012 11:06 am
Location - Victoria, Australia

Post by jedipi » Thu Dec 27, 2012 6:24 am

Module App is a tool

Most modules (e.g. Featured, Latest, Opening Hours, etc.) provides output immediately after they are published. Module Apps is different. Module Apps is a tool.

Module Apps itself provides nothing. It's empty. Like OpenCart without any content. You have to give Module Apps somethings that can be processed and presented to users. The "somethings" for Module Apps are custom codes.

Image

Image Image Image

Australian Bank Transfer

Find out all my extensions here


User avatar
Active Member

Posts

Joined
Sat Jul 14, 2012 11:06 am
Location - Victoria, Australia
Who is online

Users browsing this forum: No registered users and 2 guests