Home Blog Page 24

Regarding the internship provision Internship letter

This post is regarding the internship provision internship letter, internship letter, cover letter, intern letter, letter of the internship.

17th Dec 2009

To,
The HR manager
Everest Bank Ltd
New Baneshwor, Kathmandu

Subject: Regarding the internship provision

Respected sir/madam,

As a potential intern, with required qualifications and a strong desire to excel in the banking profession, I am seeking to align myself as an intern with a company that ranks top at the global market and also offers an internship to undergraduates like me.
I am seeking a professional opportunity where my educational and other co-curricular experiences can benefit your company as well as lead me to my career goal and drive me along my career path.

I keep forth my kind request to consider my application for an internship at your bank for a period of six weeks which is a must for the course of BCIS(Bachelor in computer information system) under Pokhara University. As under the university norms, we are supposed to select the specialized subject in the final year and I have decided to take part in the IT sector. This opportunity will help me to explore more during my classes and learn more.

I assure you that I will strongly adhere to the bank norms and rules during my tenure as an intern and at any time in the future. I will also fulfill my responsibilities with utmost dedication if given any.

I wait for your positive response.

Thanking you.

Yours sincerely,
Rupak Nepali
BCIS 7th semester
Nobel College

internship letter, cover letter, intern letter, letter of internship

The solution to HOMEWORK 4.4 M101JS: MongoDB for Node.js Developers

HOMEWORK: HOMEWORK 4.4

In this problem, you will analyze a profile log taken from a MongoDB instance. To start, please download sysprofile.json from Download Handout link and import it with the following command:

mongoimport -d m101 -c profile < sysprofile.json

Now query the profile data, looking for all queries to the students’ collection in the databaseschool2, sorted in order of decreasing latency. What is the latency of the longest-running operation to the collection, in milliseconds?

hw4.4answer

  Answer: 15820

The solution to HOMEWORK 4.2 M101JS: MongoDB for Node.js Developers

HOMEWORK: HOMEWORK 4.2

Suppose you have a collection called tweets whose documents contain information about thecreated_at time of the tweet and the user’s followers_count at the time they issued the tweet. What can you infer from the following explain output?

> db.tweets.explain("executionStats").find({"user.followers_count":{$gt:1000}}).limit(10).skip(5000).sort( { created_at : 1 } )
{
    "queryPlanner" : {
        "plannerVersion" : 1,
        "namespace" : "twitter.tweets",
        "indexFilterSet" : false,
        "parsedQuery" : {
            "user.followers_count" : {
                "$gt" : 1000
            }
        },
        "winningPlan" : {
            "stage" : "LIMIT",
            "limitAmount" : 0,
            "inputStage" : {
                "stage" : "SKIP",
                "skipAmount" : 0,
                "inputStage" : {
                    "stage" : "FETCH",
                    "filter" : {
                        "user.followers_count" : {
                            "$gt" : 1000
                        }
                    },
                    "inputStage" : {
                        "stage" : "IXSCAN",
                        "keyPattern" : {
                            "created_at" : -1
                        },
                        "indexName" : "created_at_-1",
                        "isMultiKey" : false,
                        "direction" : "backward",
                        "indexBounds" : {
                            "created_at" : [
                                "[MinKey, MaxKey]"
                            ]
                        }
                    }
                }
            }
        },
        "rejectedPlans" : [ ]
    },
    "executionStats" : {
        "executionSuccess" : true,
        "nReturned" : 10,
        "executionTimeMillis" : 563,
        "totalKeysExamined" : 251120,
        "totalDocsExamined" : 251120,
        "executionStages" : {
            "stage" : "LIMIT",
            "nReturned" : 10,
            "executionTimeMillisEstimate" : 500,
            "works" : 251121,
            "advanced" : 10,
            "needTime" : 251110,
            "needFetch" : 0,
            "saveState" : 1961,
            "restoreState" : 1961,
            "isEOF" : 1,
            "invalidates" : 0,
            "limitAmount" : 0,
            "inputStage" : {
                "stage" : "SKIP",
                "nReturned" : 10,
                "executionTimeMillisEstimate" : 500,
                "works" : 251120,
                "advanced" : 10,
                "needTime" : 251110,
                "needFetch" : 0,
                "saveState" : 1961,
                "restoreState" : 1961,
                "isEOF" : 0,
                "invalidates" : 0,
                "skipAmount" : 0,
                "inputStage" : {
                    "stage" : "FETCH",
                    "filter" : {
                        "user.followers_count" : {
                            "$gt" : 1000
                        }
                    },
                    "nReturned" : 5010,
                    "executionTimeMillisEstimate" : 490,
                    "works" : 251120,
                    "advanced" : 5010,
                    "needTime" : 246110,
                    "needFetch" : 0,
                    "saveState" : 1961,
                    "restoreState" : 1961,
                    "isEOF" : 0,
                    "invalidates" : 0,
                    "docsExamined" : 251120,
                    "alreadyHasObj" : 0,
                    "inputStage" : {
                        "stage" : "IXSCAN",
                        "nReturned" : 251120,
                        "executionTimeMillisEstimate" : 100,
                        "works" : 251120,
                        "advanced" : 251120,
                        "needTime" : 0,
                        "needFetch" : 0,
                        "saveState" : 1961,
                        "restoreState" : 1961,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "keyPattern" : {
                            "created_at" : -1
                        },
                        "indexName" : "created_at_-1",
                        "isMultiKey" : false,
                        "direction" : "backward",
                        "indexBounds" : {
                            "created_at" : [
                                "[MinKey, MaxKey]"
                            ]
                        },
                        "keysExamined" : 251120,
                        "dupsTested" : 0,
                        "dupsDropped" : 0,
                        "seenInvalidated" : 0,
                        "matchTested" : 0
                    }
                }
            }
        }
    },
    "serverInfo" : {
        "host" : "generic-name.local",
        "port" : 27017,
        "version" : "3.0.1",
        "gitVersion" : "534b5a3f9d10f00cd27737fbcd951032248b5952"
    },
    "ok" : 1
}

Solution:
The query uses an index to determine the order in which to return result documents
The query examines 251120 documents.

hw4.2answer

Answer for Homework 2.1 M101JS Courseware

HOMEWORK: HOMEWORK 2.1

In this problem, you will be using an old weather dataset. Download weather_data.csv from the Download Handout link. This is a comma separated value file that you can import into MongoDB as follows:

mongoimport –type csv –headerline weather_data.csv -d weather -c data

You can verify that you’ve imported the data correctly by running the following commands in the mongo shell:

> use weather
> db.data.find().count()
> 2963

Reading clockwise from true north, the wind direction is measured by degrees around the compass up to 360 degrees.

90 is East

180 is South

270 is West

360 is North

Your assignment is to figure out the “State” that recorded the lowest “Temperature” when the wind was coming from the west (“Wind Direction” between 180 and 360). Please enter the name of the state that meets this requirement. Do not include the surrounding quotes in providing your answer.

Answer is:
New Mexico

Write New Mexico and submit.

If you need query then following is the query to retrieve the data

db.data.find({"Wind Direction":{$gte:180,$lte:360}}, {"State":true,"Temperature":true, "_id":false, "Wind Direction":true}).sort({"Temperature":1})

 

Steps to create custom URL to work locally Xampp localhost virtual host

Steps to create a custom URL to work locally:

If you had installed Xampp in D:/ folder then follow the following steps, if you have installed in C:/ or another folder then replace D with respective folder name.

  • Open up the Xampp control panel and stop Apache (Ensure that you don’t have it running as a service.
  • Navigate to D:/xampp/apache/conf/extra or wherever you installed Xampp
  • Open up your text editor with administrative privileges and open up httpd-vhosts.conf found in the D:/xampp/apache/conf/extra folder
  • At the very bottom of the file paste the following (check if it exists there already) <VirtualHost *:80> DocumentRoot “D:/xampp/htdocs” ServerName localhost </VirtualHost>
  • Without that line of code, you will lose access to your default htdocs/ For eg: http://localhost/ will be inaccessible.
  • Now copy and paste the code below: <VirtualHost *:80> DocumentRoot “D:/xampp/htdocs/webocreation” ServerName webocreation.dev ServerAlias www.webocreation.dev <Directory “D:/xampp/htdocs/webocreation”> AllowOverride All Require all Granted </Directory> </VirtualHost>
  • Now we head over to our Windows Hosts File, to edit the HOSTS. File will be located at C:/Windows/System32/drivers/etc/hosts, where hosts is the file. 127.0.0.1             localhost
  • Look for the line above and enter your site mimicking the layout 127.0.0.1             localhost 127.0.0.1             webocreation.dev
  • Change this to the domain name you choose earlier
  • Change it to reflect the lines above (if you have problems saving it meant you didn’t have your text editor running in admin mode.
  • Restart Apache and test to make sure it is working.
  • Go to the URL

Limit number of sub-categories to show at OpenCart 2

It is not recommended to change the default files of OpenCart as if you upgrade then all changes will be lost so we have seen one solution to achieve your requirement by changing the header.tpl. Open catalog/view/theme/YOUR_THEME/template/common/header.tpl
Find the following lines of code:

<?php foreach (array_chunk($category['children'], ceil(count($category['children']) / $category['column'])) as $children) { ?>
              <ul class="list-unstyled">
                <?php foreach ($children as $child) { ?>
                <li><a href="<?php echo $child['href']; ?>"><?php echo $child['name']; ?></a></li>
                <?php } ?>
              </ul>
              <?php } ?>

And replace with following lines of code:

<ul class="list-unstyled">
  <?php foreach ($category['children'] as $key=>$child) { ?>
  <?php if($key<5){ ?>
  <li><a href="<?php echo $child['href']; ?>"><?php echo $child['name']; ?></a></li>
  <?php } ?>
  <?php } ?>
</ul>

With this change, there will be only one column.

For many sub-categories, you can make multiple columns of sub-categories in OpenCart.
While inserting the category, in the data tab, insert the “Columns” value to show multiple columns. You can see examples of the “MP3 Players” category and its sub-categories in the default installation.

limit-sub-categories-opencart-menu


Coming soon products opencart free module

Products to show without the add to cart button, another Opencart free module “Coming Soon Products module  OpenCart version 2.0”. When you enabled this module, you will be able to see the products which available date is greater than today.

The module will look like below:

coming soon opencart module

Admin section will look like:

future products opencart module

Download Coming Soon Future Products free module from the link below:

Download Coming Soon Future Products free Module

Installation:

  1. Unzip the downloaded folder.
  2. Upload the files in the root folder to your server, no file is overwritten.
  3. Then activate the “Future Products” module.

Activating the “Future Products” module:

  1. After uploading files to servers, it’s time to install the “Future Products” module
  2. We are showing the “Future Products” module at the right column of the Category page (Category Layout) but you can show it wherever you like as this acts as a normal module.
  3. Go to Admin section
  4. Then click on Extensions on the left menu
  5. After that Click Modules and go to “Future Products” in the modules list
  6. Then click the Green button for the “Future Products” to install the module (see the image below)
  7. Then click the blue edit button
  8. After that, you will see the form which has the status field, select “Enabled” and then click the Save button.
  9. Your module is active and is ready to use in the layout.

Setup layout for the sidebar “Future Products” module at the right column of the home page:

  1. From the admin section go to System >> Design >> Layouts.
  2. You will see a list of layouts, from which edit the Home layout.
  3. Then click Blue add the button to add rows at module section which is shown in the image below:
  4. Second, you choose the “Future Products” in the module column and Column right in the Position column and insert the sort order as required.
  5. Then click save button

Your custom home page is ready with the “Future Products” module in the right column. Likewise, you can show in many other layouts and pages.

Codes of “Future Products” modules of the presentation layer’s controller:

Go to catalog/controller/module/futureproducts.php

<?php
class ControllerModuleFutureProducts extends Controller {
   public function index($setting) {
      $this->load->language('module/futureproducts');
      $data['heading_title'] = $setting['name'];
      $data['text_tax'] = $this->language->get('text_tax');
      $data['button_cart'] = $this->language->get('button_cart');
      $data['button_wishlist'] = $this->language->get('button_wishlist');
      $data['button_compare'] = $this->language->get('button_compare');
      $this->load->model('catalog/product');
      $this->load->model('catalog/futureproducts');
      $this->load->model('tool/image');

      $data['products'] = array();
      $filter_data = array(
         'sort'  => 'p.date_added',
         'order' => 'DESC',
         'start' => 0,
         'limit' => $setting['limit']
      );

      $results = $this->model_catalog_futureproducts->getProducts($filter_data);
      if ($results) {
         foreach ($results as $result) {
            if ($result['image']) {
               $image = $this->model_tool_image->resize($result['image'], $setting['width'], $setting['height']);
            } else {
               $image = $this->model_tool_image->resize('placeholder.png', $setting['width'], $setting['height']);
            }
            if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
               $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
            } else {
               $price = false;
            }
            if ((float)$result['special']) {
               $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')));
            } else {
               $special = false;
            }
            if ($this->config->get('config_tax')) {
               $tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price']);
            } else {
               $tax = false;
            }
            if ($this->config->get('config_review_status')) {
               $rating = $result['rating'];
            } else {
               $rating = false;
            }
            $data['products'][] = array(
               'product_id'  => $result['product_id'],
               'thumb'       => $image,
               'name'        => $result['name'],
               'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',
               'price'       => $price,
               'special'     => $special,
               'tax'         => $tax,
               'rating'      => $rating,
               'href'        => $this->url->link('product/product', 'product_id=' . $result['product_id']),
            );
         }
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/futureproducts.tpl')) {
            return $this->load->view($this->config->get('config_template') . '/template/module/futureproducts.tpl', $data);
         } else {
            return $this->load->view('default/template/module/futureproducts.tpl', $data);
         }
      }
   }
}

Codes of “Future Products” modules of the presentation layer’s language file:

Go to catalog/language/english/module/futureproducts.php

<?php
// Heading
$_['heading_title'] = 'Future Products';
// Text
$_['text_tax']      = 'Ex Tax:';

Codes of “Account Login” modules of the presentation layer’s template file:

Go to catalog/view/theme/default/module/futureproducts.tpl

<h3><?php echo $heading_title; ?></h3>
<div class="row">
  <?php foreach ($products as $product) { ?>
  <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
    <div class="product-thumb transition">
      <div class="image"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" class="img-responsive" /></div>
      <div class="caption">
        <h4><?php echo $product['name']; ?></h4>
        <p><?php echo $product['description']; ?></p>
        <?php if ($product['rating']) { ?>
        <div class="rating">
          <?php for ($i = 1; $i <= 5; $i++) { ?>
          <?php if ($product['rating'] < $i) { ?>
          <span class="fa fa-stack"><i class="fa fa-star-o fa-stack-2x"></i></span>
          <?php } else { ?>
          <span class="fa fa-stack"><i class="fa fa-star fa-stack-2x"></i><i class="fa fa-star-o fa-stack-2x"></i></span>
          <?php } ?>
          <?php } ?>
        </div>
        <?php } ?>
        <?php if ($product['price']) { ?>
        <p class="price">
          <?php if (!$product['special']) { ?>
          <?php echo $product['price']; ?>
          <?php } else { ?>
          <span class="price-new"><?php echo $product['special']; ?></span> <span class="price-old"><?php echo $product['price']; ?></span>
          <?php } ?>
          <?php if ($product['tax']) { ?>
          <span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
          <?php } ?>
        </p>
        <?php } ?>
      </div>

    </div>
  </div>
  <?php } ?>
</div>

Similarly, in the admin section, we have three files for the module

  1. admin/controller/module/futureproducts.php
  2. admin/language/english/module/futureproducts.php
  3. admin/view/template/module/futureproducts.tpl

Codes of “Future Products” modules of the admin layer’s  controller file:

Go to admin/controller/module/futureproducts.php

<?php
class ControllerModuleFutureProducts extends Controller {
   private $error = array();
   public function index() {
      $this->load->language('module/futureproducts');
      $this->document->setTitle($this->language->get('heading_title'));
      $this->load->model('extension/module');
      if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
         if (!isset($this->request->get['module_id'])) {
            $this->model_extension_module->addModule('futureproducts', $this->request->post);
         } else {
            $this->model_extension_module->editModule($this->request->get['module_id'], $this->request->post);
         }
         $this->cache->delete('product');
         $this->session->data['success'] = $this->language->get('text_success');
         $this->response->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'));
      }
      $data['heading_title'] = $this->language->get('heading_title');
      $data['text_edit'] = $this->language->get('text_edit');
      $data['text_enabled'] = $this->language->get('text_enabled');
      $data['text_disabled'] = $this->language->get('text_disabled');
      $data['entry_name'] = $this->language->get('entry_name');
      $data['entry_limit'] = $this->language->get('entry_limit');
      $data['entry_width'] = $this->language->get('entry_width');
      $data['entry_height'] = $this->language->get('entry_height');
      $data['entry_status'] = $this->language->get('entry_status');
      $data['button_save'] = $this->language->get('button_save');
      $data['button_cancel'] = $this->language->get('button_cancel');
      if (isset($this->error['warning'])) {
         $data['error_warning'] = $this->error['warning'];
      } else {
         $data['error_warning'] = '';
      }
      if (isset($this->error['name'])) {
         $data['error_name'] = $this->error['name'];
      } else {
         $data['error_name'] = '';
      }
      if (isset($this->error['width'])) {
         $data['error_width'] = $this->error['width'];
      } else {
         $data['error_width'] = '';
      }
      if (isset($this->error['height'])) {
         $data['error_height'] = $this->error['height'];
      } else {
         $data['error_height'] = '';
      }
      $data['breadcrumbs'] = array();
      $data['breadcrumbs'][] = array(
         'text' => $this->language->get('text_home'),
         'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], 'SSL')
      );
      $data['breadcrumbs'][] = array(
         'text' => $this->language->get('text_module'),
         'href' => $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL')
      );
      if (!isset($this->request->get['module_id'])) {
         $data['breadcrumbs'][] = array(
            'text' => $this->language->get('heading_title'),
            'href' => $this->url->link('module/futureproducts', 'token=' . $this->session->data['token'], 'SSL')
         );
      } else {
         $data['breadcrumbs'][] = array(
            'text' => $this->language->get('heading_title'),
            'href' => $this->url->link('module/futureproducts', 'token=' . $this->session->data['token'] . '&module_id=' . $this->request->get['module_id'], 'SSL')
         );
      }
      if (!isset($this->request->get['module_id'])) {
         $data['action'] = $this->url->link('module/futureproducts', 'token=' . $this->session->data['token'], 'SSL');
      } else {
         $data['action'] = $this->url->link('module/futureproducts', 'token=' . $this->session->data['token'] . '&module_id=' . $this->request->get['module_id'], 'SSL');
      }
      $data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL');
      if (isset($this->request->get['module_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
         $module_info = $this->model_extension_module->getModule($this->request->get['module_id']);
      }
      if (isset($this->request->post['name'])) {
         $data['name'] = $this->request->post['name'];
      } elseif (!empty($module_info)) {
         $data['name'] = $module_info['name'];
      } else {
         $data['name'] = '';
      }
      if (isset($this->request->post['limit'])) {
         $data['limit'] = $this->request->post['limit'];
      } elseif (!empty($module_info)) {
         $data['limit'] = $module_info['limit'];
      } else {
         $data['limit'] = 5;
      }
      if (isset($this->request->post['width'])) {
         $data['width'] = $this->request->post['width'];
      } elseif (!empty($module_info)) {
         $data['width'] = $module_info['width'];
      } else {
         $data['width'] = 200;
      }
      if (isset($this->request->post['height'])) {
         $data['height'] = $this->request->post['height'];
      } elseif (!empty($module_info)) {
         $data['height'] = $module_info['height'];
      } else {
         $data['height'] = 200;
      }
      if (isset($this->request->post['status'])) {
         $data['status'] = $this->request->post['status'];
      } elseif (!empty($module_info)) {
         $data['status'] = $module_info['status'];
      } else {
         $data['status'] = '';
      }
      $data['header'] = $this->load->controller('common/header');
      $data['column_left'] = $this->load->controller('common/column_left');
      $data['footer'] = $this->load->controller('common/footer');
      $this->response->setOutput($this->load->view('module/futureproducts.tpl', $data));
   }
   protected function validate() {
      if (!$this->user->hasPermission('modify', 'module/futureproducts')) {
         $this->error['warning'] = $this->language->get('error_permission');
      }
      if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 64)) {
         $this->error['name'] = $this->language->get('error_name');
      }
      if (!$this->request->post['width']) {
         $this->error['width'] = $this->language->get('error_width');
      }
      if (!$this->request->post['height']) {
         $this->error['height'] = $this->language->get('error_height');
      }
      return !$this->error;
   }
}

Codes of “Future Products” modules of the admin layer’s language file:

Go to admin/language/english/module/futureproducts.php

<?php
// Heading
$_['heading_title']    = 'Future Products';
// Text
$_['text_module']      = 'Modules';
$_['text_success']     = 'Success: You have modified Future Products module!';
$_['text_edit']        = 'Edit Future Products Module';
// Entry
$_['entry_name']       = 'Module Name';
$_['entry_limit']      = 'Limit';
$_['entry_image']      = 'Image (W x H) and Resize Type';
$_['entry_width']      = 'Width';
$_['entry_height']     = 'Height';
$_['entry_status']     = 'Status';
// Error
$_['error_permission'] = 'Warning: You do not have permission to modify Future Products module!';
$_['error_name']       = 'Module Name must be between 3 and 64 characters!';
$_['error_width']      = 'Width required!';
$_['error_height']     = 'Height required!';

Codes of “Account Login” modules of the admin layer’s template file:

Go to admin/view/module/futureproducts.tpl

<?php echo $header; ?><?php echo $column_left; ?>
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <div class="pull-right">
        <button type="submit" form="form-bestseller" data-toggle="tooltip" title="<?php echo $button_save; ?>" class="btn btn-primary"><i class="fa fa-save"></i></button>
        <a href="<?php echo $cancel; ?>" data-toggle="tooltip" title="<?php echo $button_cancel; ?>" class="btn btn-default"><i class="fa fa-reply"></i></a></div>
      <h1><?php echo $heading_title; ?></h1>
      <ul class="breadcrumb">
        <?php foreach ($breadcrumbs as $breadcrumb) { ?>
        <li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
        <?php } ?>
      </ul>
    </div>
  </div>
  <div class="container-fluid">
    <?php if ($error_warning) { ?>
    <div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> <?php echo $error_warning; ?>
      <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>
    <?php } ?>
    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title"><i class="fa fa-pencil"></i> <?php echo $text_edit; ?></h3>
      </div>
      <div class="panel-body">
        <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form-bestseller" class="form-horizontal">
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-name"><?php echo $entry_name; ?></label>
            <div class="col-sm-10">
              <input type="text" name="name" value="<?php echo $name; ?>" placeholder="<?php echo $entry_name; ?>" id="input-name" class="form-control" />
              <?php if ($error_name) { ?>
              <div class="text-danger"><?php echo $error_name; ?></div>
              <?php } ?>
            </div>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-limit"><?php echo $entry_limit; ?></label>
            <div class="col-sm-10">
              <input type="text" name="limit" value="<?php echo $limit; ?>" placeholder="<?php echo $entry_limit; ?>" id="input-limit" class="form-control" />
            </div>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-width"><?php echo $entry_width; ?></label>
            <div class="col-sm-10">
              <input type="text" name="width" value="<?php echo $width; ?>" placeholder="<?php echo $entry_width; ?>" id="input-width" class="form-control" />
              <?php if ($error_width) { ?>
              <div class="text-danger"><?php echo $error_width; ?></div>
              <?php } ?>
            </div>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-height"><?php echo $entry_height; ?></label>
            <div class="col-sm-10">
              <input type="text" name="height" value="<?php echo $height; ?>" placeholder="<?php echo $entry_height; ?>" id="input-height" class="form-control" />
              <?php if ($error_height) { ?>
              <div class="text-danger"><?php echo $error_height; ?></div>
              <?php } ?>
            </div>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-status"><?php echo $entry_status; ?></label>
            <div class="col-sm-10">
              <select name="status" id="input-status" class="form-control">
                <?php if ($status) { ?>
                <option value="1" selected="selected"><?php echo $text_enabled; ?></option>
                <option value="0"><?php echo $text_disabled; ?></option>
                <?php } else { ?>
                <option value="1"><?php echo $text_enabled; ?></option>
                <option value="0" selected="selected"><?php echo $text_disabled; ?></option>
                <?php } ?>
              </select>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>
<?php echo $footer; ?>

Please let us know if you have any questions or concerns. Please don’t forget to post your questions or comments so that we can add extra topics and Opencart free module. You can follow us at our twitter account @rupaknpl and subscribe to our YouTube channel for opencart tutorials.

Drupal Select Node by EntityFieldQuery by translate language

While working as drupal developer in multi language Drupal 7 site you may find EntityFieldQuery class which allows finding entities based on entity properties and keep on getting confused with the propertyCondition and entityCondition for language translation.

Below example of entity field query helps me to find node main language specific featured blog post and

  global $language;
  $query = new EntityFieldQuery;
  $query->entityCondition('entity_type', 'node')
      ->entityCondition('bundle', $bundletype)
      ->propertyCondition('status', NODE_PUBLISHED) // in case you need it
      ->propertyCondition('language', $language->language)
      ->fieldCondition('field_featured_blog', 'value', '1', "=")
      ->propertyOrderBy('changed', 'DESC')
      ->range(0,1);
  $query->execute();

Below will find data as per the translated entity based language featured blog.

  global $language;
  $query = new EntityFieldQuery;
  $query->entityCondition('entity_type', 'node')
      ->entityCondition('bundle', $bundletype)
      ->propertyCondition('status', NODE_PUBLISHED)
      ->entityCondition('language', $language->language)
      ->fieldCondition('field_featured_blog','value', '1', "=")
      ->propertyOrderBy('created', 'DESC');
  $query->execute();

Drupal EntityFieldQuery by language

When you do print_r($query), then you will get following:

EntityFieldQuery Object
(
    [altered] => 1
    [entityConditions] => Array
        (
            [entity_type] => Array
                (
                    [value] => node
                    [operator] => =
                )

            [bundle] => Array
                (
                    [value] =>
                    [operator] => 
                )

            [language] => Array
                (
                    [value] => en
                    [operator] => =
                )

        )

    [fieldConditions] => Array
        (
            [0] => Array
                (
                    [field] => Array
                        (
                            [translatable] => 1
                            [entity_types] => Array
                                (
                                )

                            [settings] => Array
                                (
                                    [allowed_values] => Array
                                        (
                                            [0] => 
                                            [1] => 
                                        )

                                    [allowed_values_function] => 
                                    [entity_translation_sync] => 
                                )

                            [storage] => Array
                                (
                                    [type] => field_sql_storage
                                    [settings] => Array
                                        (
                                        )

                                    [module] => field_sql_storage
                                    [active] => 1
                                    [details] => Array
                                        (
                                            [sql] => Array
                                                (
                                                    [FIELD_LOAD_CURRENT] => Array
                                                        (
                                                            [field_data_field_featured_blog] => Array
                                                                (
                                                                    [value] => field_featured_blog_value
                                                                )

                                                        )

                                                    [FIELD_LOAD_REVISION] => Array
                                                        (
                                                            [field_revision_field_featured_blog] => Array
                                                                (
                                                                    [value] => field_featured_blog_value
                                                                )

                                                        )

                                                )

                                        )

                                )

                            [foreign keys] => Array
                                (
                                )

                            [indexes] => Array
                                (
                                    [value] => Array
                                        (
                                            [0] => value
                                        )

                                )

                            [id] => 260
                            [field_name] => field_featured_blog
                            [type] => list_boolean
                            [module] => list
                            [active] => 1
                            [locked] => 0
                            [cardinality] => 1
                            [deleted] => 0
                            [columns] => Array
                                (
                                    [value] => Array
                                        (
                                            [type] => int
                                            [not null] => 
                                        )

                                )

                            [bundles] => Array
                                (
                                    [node] => Array
                                        (
                                            [0] => 
                                            [1] => 
                                        )

                                )

                        )

                    [column] => value
                    [value] => 1
                    [operator] => =
                    [delta_group] => 
                    [language_group] => 
                )

        )

    [fieldMetaConditions] => Array
        (
        )

    [propertyConditions] => Array
        (
            [0] => Array
                (
                    [column] =>
                    [value] => 1
                    [operator] => 
                )

        )

    [order] => Array
        (
            [0] => Array
                (
                    [type] => property
                    [specifier] =>
                    [direction] => DESC
                )

        )

    [range] => Array
        (
        )

    [pager] => Array
        (
        )

    [deleted] => 
    [fields] => Array
        (
            [0] => Array
                (
                    [translatable] => 1
                    [entity_types] => Array
                        (
                        )

                    [settings] => Array
                        (
                            [allowed_values] => Array
                                (
                                    [0] => 
                                    [1] => 
                                )

                            [allowed_values_function] => 
                            [entity_translation_sync] => 
                        )

                    [storage] => Array
                        (
                            [type] => field_sql_storage
                            [settings] => Array
                                (
                                )

                            [module] => field_sql_storage
                            [active] => 1
                            [details] => Array
                                (
                                    [sql] => Array
                                        (
                                            [FIELD_LOAD_CURRENT] => Array
                                                (
                                                    [field_data_field_featured_blog] => Array
                                                        (
                                                            [value] => field_featured_blog_value
                                                        )

                                                )

                                            [FIELD_LOAD_REVISION] => Array
                                                (
                                                    [field_revision_field_featured_blog] => Array
                                                        (
                                                            [value] => field_featured_blog_value
                                                        )

                                                )

                                        )

                                )

                        )

                    [foreign keys] => Array
                        (
                        )

                    [indexes] => Array
                        (
                            [value] => Array
                                (
                                    [0] => value
                                )

                        )

                    [id] => 260
                    [field_name] => field_featured_blog
                    [type] => list_boolean
                    [module] => list
                    [active] => 1
                    [locked] => 0
                    [cardinality] => 1
                    [deleted] => 0
                    [columns] => Array
                        (
                            [value] => Array
                                (
                                    [type] => int
                                    [not null] => 
                                )

                        )

                    [bundles] => Array
                        (
                            [node] => Array
                                (
                                    [0] =>
                                    [1] =>
                                )

                        )

                )

        )

    [count] => 
    [age] => FIELD_LOAD_CURRENT
    [tags] => Array
        (
        )

    [metaData] => Array
        (
        )

    [orderedResults] => Array
        (
        )

    [executeCallback] => 
)

Full details of EntityFieldQuery at:
https://api.drupal.org/api/drupal/includes%21entity.inc/class/EntityFieldQuery/7.x

The function defaults to either = or IN depending on the value param as an array or string.
https://api.drupal.org/api/drupal/includes%21entity.inc/function/EntityFieldQuery%3A%3ApropertyCondition/7.x

 

 

Convert node id to full redirect url in drupal

Convert node id to full redirect url in drupal

$link=url(drupal_get_path_alias('node/nodeid', array('absolute' => TRUE));
echo $link;

In above code node/nodeid need to be something like node/1 or so.

Line Delimited JSON (LDJ) protocol

The protocol that use newlines to separate messages, we’ll call this protocol Line Delimited JSON (LDJ). There are no line breaks in JSON messages. Although JSON is whitespace agnostic it ignores whitespace outside of string value.

Serializing Messages with JSON

Let’s develop the message-passing protocol that uses JSON to serialize messages. Each message is a JSON-serialized object, which is a hash of key-value pairs. Here’s an example JSON object with two key-value pairs:

{"key":"value","anotherKey":"anotherValue"}

The net-watcher service we’ve been developing in this chapter sends two kinds of messages that we need to convert to JSON:
When the connection is first established, the client receives the string
Now watching target.txt for changes…
Whenever the target file changes, the client receives a string like this: File “target.txt” changed: Sat Jan 12, 2013, 12:35:52 GMT-0500 (EST)
We’ll encode the first kind of message this way:

{"type":"watching","file":"target.txt"}

The type field indicates that this is a watching message the specified file is now being watched.
The second type of message is encoded this way:

{"type":"changed","file":"target.txt","timestamp":1358175733785}

Here the type field announces that the target file has changed. The timestamp field contains an integer value representing the number of milliseconds since midnight, January 1, 1970. This happens to be an easy time format to work within JavaScript. For example, you can get the current time in this format with Date.now().

To relieve the client program from the danger of split JSON messages, we’ll implement Line Delimited JSON (LDJ) buffering client module. Then we’ll incorporate it into the network-watcher client.

First, let’s have a look at how the Node does inheritance. The following code sets up LDJClientto inherit from EventEmitter.

const
    events=require('events'),
    util=require('util'),
    //clientconstructor
    LDJClient=function(stream){
        events.EventEmitter.call(this);
    };
util.inherits(LDJClient,events.EventEmitter);

LDJClient is a constructor function, which means other code should call new LDJClient(stream) to get an instance. The stream parameter is an object that emits data events, such as a Socket connection. Inside the constructor function, we call the EventEmitter constructor on this. That line of code is roughly equivalent to calling super() in languages with classical inheritance.

Finally, we call util.inherits() to make LDJClient’s prototypal parent object the EventEmitterprototype. If this sounds cryptic to you, don’t worry. It’s like saying classLDJClientinherits from EventEmitter in languages with a classical inheritance model. It means that if you look for a property on an LDJClientand it’s not there, the EventEmitteris the next place to look

Exporting Functionality in a Module
Let’s pull together the previous code samples and expose LDJClientas a module. Open a text editor and insert the following: /ldj.js

"usestrict";
const
    events=require('events'),
    util=require('util'),
//clientconstructor
    LDJClient=function(stream){
        events.EventEmitter.call(this);
        let
            self=this,
            buffer='';
        stream.on('data',function(data){
            buffer+=data;
            letboundary=buffer.indexOf('\n');
            while(boundary!==-1){
                letinput=buffer.substr(0,boundary);
                buffer=buffer.substr(boundary+1);
                self.emit('message',JSON.parse(input));
                boundary=buffer.indexOf('\n');
            }
        });
    };
report erratum •discuss
Extending Core Classes in Custom Modules • 37
www.it-ebooks.info
util.inherits(LDJClient,events.EventEmitter);
//exposemodulemethods
exports.LDJClient=LDJClient;
exports.connect=function(stream){
    returnnewLDJClient(stream);
};

To create an LDJClientinstance.
Code to use the LDJ module will look something like this:

const
    ldj=require('./ldj.js'),
    client=ldj.connect(networkStream);
client.on('message',function(message){
    //takeactionforthismessage
});

Account login module for free OpenCart version 2.0

“Account login module for free OpenCart version 2.0” is another opencart free extensions when it is enabled you will be able to see the login form only when the customer is not logged in and if the customer is logged in then the form will be replaced with account links.

When the customer is not logged in you will see a form like this:

account login form display

When logged in it will be seen the link the image below:

account login form display
account_login_form_display

Download Account Login Form display free module from the link below:

Download Account Login Show as Module OpenCart free module

Installation:

  1. Unzip the downloaded folder.
  2. Upload the files in the root folder to your server, no file is overwritten.
  3. Then activate the “Account Login” module.

Activating the “Account Login” module:

  1. After uploading files to servers, it’s time to install the “Account Login” module
  2. We are showing the “Account Login” module at the right column of the Home page (Home Layout) but you can show it wherever you like as this acts as a normal module.
  3. Go to Admin section
  4. Then click on Extensions on the left menu
  5. After that Click Modules and go to “Account Login” in the modules list
  6. Then click the Green button for the “Account Login” to install the module (see the image below)installation_of_module
  7. Then click the blue edit button
  8. After that, you will see the form which has the status field, select “Enabled” and then click the Save button.
  9. Your module is active and is ready to use in the layout.

Setup layout for the sidebar “Account Login” module at the right column of home page:

  1. From the admin section go to System >> Design >> Layouts.
  2. You will see a list of layouts, from which edit the “Home” layout.
  3. Then click Blue add the button to add rows at the module section which is shown in the image below:
    siderbar_shopping_cart_installation
  4. Second, you choose the “Account Login” in the module column and Column right in the Position column and insert the sort order as required.
  5. Then click save button

Your custom home page is ready with the “Account Login” module in the right column. Likewise, you can show in many other layouts and pages.

Codes of “Account Login” modules of the presentation layer’s controller:

Go to catalog/controller/module/accountlogin.php

<?php
class ControllerModuleAccountlogin extends Controller {
	public function index() {
		$this->load->language('module/accountlogin');

		$data['heading_title'] = $this->language->get('heading_title');

		$data['text_register'] = $this->language->get('text_register');
		$data['text_login'] = $this->language->get('text_login');
		$data['text_logout'] = $this->language->get('text_logout');
		$data['text_forgotten'] = $this->language->get('text_forgotten');
		$data['text_accountlogin'] = $this->language->get('text_accountlogin');
		$data['text_account'] = $this->language->get('text_account');
		$data['text_edit'] = $this->language->get('text_edit');
		$data['text_password'] = $this->language->get('text_password');
		$data['text_address'] = $this->language->get('text_address');
		$data['text_wishlist'] = $this->language->get('text_wishlist');
		$data['text_order'] = $this->language->get('text_order');
		$data['text_download'] = $this->language->get('text_download');
		$data['text_reward'] = $this->language->get('text_reward');
		$data['text_return'] = $this->language->get('text_return');
		$data['text_transaction'] = $this->language->get('text_transaction');
		$data['text_newsletter'] = $this->language->get('text_newsletter');
		$data['text_recurring'] = $this->language->get('text_recurring');

		$data['logged'] = $this->customer->isLogged();
		$data['register'] = $this->url->link('account/register', '', 'SSL');
		$data['login'] = $this->url->link('account/login', '', 'SSL');
		$data['logout'] = $this->url->link('account/logout', '', 'SSL');
		$data['forgotten'] = $this->url->link('account/forgotten', '', 'SSL');
		$data['accountlogin'] = $this->url->link('account/account', '', 'SSL');
		$data['account'] = $this->url->link('account/account', '', 'SSL');
		$data['edit'] = $this->url->link('account/edit', '', 'SSL');
		$data['password'] = $this->url->link('account/password', '', 'SSL');
		$data['address'] = $this->url->link('account/address', '', 'SSL');
		$data['wishlist'] = $this->url->link('account/wishlist');
		$data['order'] = $this->url->link('account/order', '', 'SSL');
		$data['download'] = $this->url->link('account/download', '', 'SSL');
		$data['reward'] = $this->url->link('account/reward', '', 'SSL');
		$data['return'] = $this->url->link('account/return', '', 'SSL');
		$data['transaction'] = $this->url->link('account/transaction', '', 'SSL');
		$data['newsletter'] = $this->url->link('account/newsletter', '', 'SSL');
		$data['recurring'] = $this->url->link('account/recurring', '', 'SSL');

		$data['email'] = $this->language->get('email');
		$data['returningcustomer'] = $this->language->get('returningcustomer');
		$data['password'] = $this->language->get('password');
		$data['forget'] = $this->language->get('forget');
		$data['register'] = $this->language->get('register');

		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/accountlogin.tpl')) {
			return $this->load->view($this->config->get('config_template') . '/template/module/accountlogin.tpl', $data);
		} else {
			return $this->load->view('default/template/module/accountlogin.tpl', $data);
		}
	}
}

Codes of “Account Login” modules of the presentation layer’s language file:

Go to catalog/language/english/module/accountlogin.php

<?php
// Heading
$_['heading_title']    = 'Account Login';

// Text
$_['text_register']    = 'Register';
$_['text_login']       = 'Login';
$_['text_logout']      = 'Logout';
$_['text_forgotten']   = 'Forgotten Password';
$_['text_account']     = 'My Account';
$_['text_edit']        = 'Edit Account';
$_['text_password']    = 'Password';
$_['text_address']     = 'Address Book';
$_['text_wishlist']    = 'Wish List';
$_['text_order']       = 'Order History';
$_['text_download']    = 'Downloads';
$_['text_reward']      = 'Reward Points';
$_['text_return']      = 'Returns';
$_['text_transaction'] = 'Transactions';
$_['text_newsletter']  = 'Newsletter';
$_['text_recurring']   = 'Recurring payments';

$_['email']            = 'E-mail';
$_['returningcustomer']= 'Returning Customer';
$_['password']         = 'Password';
$_['forget']           = 'Forgotten Password?';
$_['register']         = 'Register New Account?';

Codes of “Account Login” modules of the presentation layer’s template file:

Go to catalog/view/theme/default/module/accountlogin.php

<?php if(!$logged){ ?>
<div class="col-sm-12">
  <div class="well">
    <p><strong><?php echo $returningcustomer; ?></strong></p>
    <form action="index.php?route=account/login" method="post" enctype="multipart/form-data">
      <div class="form-group">
        <label class="control-label" for="input-email"><?php echo $email; ?></label>
        <input type="text" name="email" value="" placeholder="<?php echo $email; ?>" id="input-email" class="form-control" autocomplete="off" style="cursor: auto; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QsPDiEFu6xIcAAAAXhJREFUOMvNk8FLVFEUxn/ffRdmIAla1CbBFDGCpoiQWYlBLty7UHAvEq2HYLhveDMws2/TIly6E9SdIEj+AVYgRaTgXhe2C968x2nhTOjow8pNZ/ede/ide893Lvx3UavVhkMIk30dQqiGECpF9e68CCG8LpfL3yStAAIk6Z2kT3Ect68C+AGdSroFVEII82aWSXoGYGYHVwE0qOM43pU0BXw3s1zSI2AnSZKXhYB6vT7inLvd7XZ/eu8fOOe2JEW9zjkwZ2bHkoayLDtpt9ufLzzBe/8GWC6VSpc7nIE2pLPLeu/fA0uDQ3T/6pp6039uZnfN7Ieke1EUrQOu3/VawPloNBrbwIyZ7TvnLvg/+mKOJ3xk88NR4R4sADM92fp9MDRMdXaRxenHVMbuFy8SMAFkZval2Wyu9ZN3Hk4zWx0nAtKsWwxotVrNNE2f5nn+CrB+/nRvlSR5y2EK0TWbSKfT+fo3Lribfr4bA/yfl56y2kkuZX8BjXVyqMs8oFcAAAAASUVORK5CYII=); background-attachment: scroll; background-position: 100% 50%; background-repeat: no-repeat;">
      </div>
      <div class="form-group">
        <label class="control-label" for="input-password"><?php echo $password; ?></label>
        <input type="password" name="password" value="" placeholder="<?php echo $password; ?>" id="input-password" class="form-control" autocomplete="off" style="cursor: auto; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QsPDiEFu6xIcAAAAXhJREFUOMvNk8FLVFEUxn/ffRdmIAla1CbBFDGCpoiQWYlBLty7UHAvEq2HYLhveDMws2/TIly6E9SdIEj+AVYgRaTgXhe2C968x2nhTOjow8pNZ/ede/ide893Lvx3UavVhkMIk30dQqiGECpF9e68CCG8LpfL3yStAAIk6Z2kT3Ect68C+AGdSroFVEII82aWSXoGYGYHVwE0qOM43pU0BXw3s1zSI2AnSZKXhYB6vT7inLvd7XZ/eu8fOOe2JEW9zjkwZ2bHkoayLDtpt9ufLzzBe/8GWC6VSpc7nIE2pLPLeu/fA0uDQ3T/6pp6039uZnfN7Ieke1EUrQOu3/VawPloNBrbwIyZ7TvnLvg/+mKOJ3xk88NR4R4sADM92fp9MDRMdXaRxenHVMbuFy8SMAFkZval2Wyu9ZN3Hk4zWx0nAtKsWwxotVrNNE2f5nn+CrB+/nRvlSR5y2EK0TWbSKfT+fo3Lribfr4bA/yfl56y2kkuZX8BjXVyqMs8oFcAAAAASUVORK5CYII=); background-attachment: scroll; background-position: 100% 50%; background-repeat: no-repeat;">
        <a href="index.php?route=account/forgotten"><?php echo $forget; ?></a></div>
      <input type="submit" value="Login" class="btn btn-primary">
    </form>
    <p>
    <br />
    <a href="<?php echo $registerlink; ?>"><?php echo $register; ?></a>
    </p>
  </div>
</div>

<?php }else{ ?>
<div class="list-group">
  <?php if (!$logged) { ?>
  <a href="<?php echo $login; ?>" class="list-group-item"><?php echo $text_login; ?></a> <a href="<?php echo $register; ?>" class="list-group-item"><?php echo $text_register; ?></a> <a href="<?php echo $forgotten; ?>" class="list-group-item"><?php echo $text_forgotten; ?></a>
  <?php } ?>
  <a href="<?php echo $account; ?>" class="list-group-item"><?php echo $text_account; ?></a>
  <?php if ($logged) { ?>
  <a href="<?php echo $edit; ?>" class="list-group-item"><?php echo $text_edit; ?></a> <a href="<?php echo $password; ?>" class="list-group-item"><?php echo $text_password; ?></a>
  <?php } ?>
  <a href="<?php echo $address; ?>" class="list-group-item"><?php echo $text_address; ?></a> <a href="<?php echo $wishlist; ?>" class="list-group-item"><?php echo $text_wishlist; ?></a> <a href="<?php echo $order; ?>" class="list-group-item"><?php echo $text_order; ?></a> <a href="<?php echo $download; ?>" class="list-group-item"><?php echo $text_download; ?></a><a href="<?php echo $recurring; ?>" class="list-group-item"><?php echo $text_recurring; ?></a> <a href="<?php echo $reward; ?>" class="list-group-item"><?php echo $text_reward; ?></a> <a href="<?php echo $return; ?>" class="list-group-item"><?php echo $text_return; ?></a> <a href="<?php echo $transaction; ?>" class="list-group-item"><?php echo $text_transaction; ?></a> <a href="<?php echo $newsletter; ?>" class="list-group-item"><?php echo $text_newsletter; ?></a>
  <?php if ($logged) { ?>
  <a href="<?php echo $logout; ?>" class="list-group-item"><?php echo $text_logout; ?></a>
  <?php } ?>
</div>
<?php } ?>

Similarly in the admin section, we have three files for the module

  1. admin/controller/module/accountlogin.php
  2. admin/language/english/module/accountlogin.php
  3. admin/view/template/module/accountlogin.tpl

Codes of “Account Login” modules of the admin layer’s controller file:

Go to admin/controller/module/accountlogin.php

<?php
class ControllerModuleAccountlogin extends Controller {
	private $error = array();

	public function index() {
		$this->load->language('module/accountlogin');

		$this->document->setTitle($this->language->get('heading_title'));

		$this->load->model('setting/setting');

		if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
			$this->model_setting_setting->editSetting('accountlogin', $this->request->post);
			$this->session->data['success'] = $this->language->get('text_success');
			$this->response->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'));
		}

		$data['heading_title'] = $this->language->get('heading_title');

		$data['text_edit'] = $this->language->get('text_edit');
		$data['text_enabled'] = $this->language->get('text_enabled');
		$data['text_disabled'] = $this->language->get('text_disabled');

		$data['entry_status'] = $this->language->get('entry_status');

		$data['button_save'] = $this->language->get('button_save');
		$data['button_cancel'] = $this->language->get('button_cancel');

		if (isset($this->error['warning'])) {
			$data['error_warning'] = $this->error['warning'];
		} else {
			$data['error_warning'] = '';
		}

		$data['breadcrumbs'] = array();
		$data['breadcrumbs'][] = array(
			'text' => $this->language->get('text_home'),
			'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], 'SSL')
		);
		$data['breadcrumbs'][] = array(
			'text' => $this->language->get('text_module'),
			'href' => $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL')
		);

		$data['breadcrumbs'][] = array(
			'text' => $this->language->get('heading_title'),
			'href' => $this->url->link('module/accountlogin', 'token=' . $this->session->data['token'], 'SSL')
		);

		$data['action'] = $this->url->link('module/accountlogin', 'token=' . $this->session->data['token'], 'SSL');

		$data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL');

		if (isset($this->request->post['accountlogin_status'])) {
			$data['accountlogin_status'] = $this->request->post['accountlogin_status'];
		} else {
			$data['accountlogin_status'] = $this->config->get('accountlogin_status');
		}

		$data['header'] = $this->load->controller('common/header');
		$data['column_left'] = $this->load->controller('common/column_left');
		$data['footer'] = $this->load->controller('common/footer');

		$this->response->setOutput($this->load->view('module/accountlogin.tpl', $data));
	}

	protected function validate() {
		if (!$this->user->hasPermission('modify', 'module/accountlogin')) {
			$this->error['warning'] = $this->language->get('error_permission');
		}

		return !$this->error;
	}
}

Codes of “Account Login” modules of the admin layer’s language file:

Go to admin/language/english/module/accountlogin.php

<?php
// Heading
$_['heading_title']    = 'Account Login';

$_['text_module']      = 'Modules';
$_['text_success']     = 'Success: You have modified account login module!';
$_['text_edit']        = 'Edit Account Login Module';

// Entry
$_['entry_status']     = 'Status';

// Error
$_['error_permission'] = 'Warning: You do not have permission to modify account login module!';

Codes of “Account Login” modules of the admin layer’s template file:

Go to admin/view/module/accountlogin.php

<?php echo $header; ?><?php echo $column_left; ?>
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <div class="pull-right">
        <button type="submit" form="form-account" data-toggle="tooltip" title="<?php echo $button_save; ?>" class="btn btn-primary"><i class="fa fa-save"></i></button>
        <a href="<?php echo $cancel; ?>" data-toggle="tooltip" title="<?php echo $button_cancel; ?>" class="btn btn-default"><i class="fa fa-reply"></i></a></div>
      <h1><?php echo $heading_title; ?></h1>
      <ul class="breadcrumb">
        <?php foreach ($breadcrumbs as $breadcrumb) { ?>
        <li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
        <?php } ?>
      </ul>
    </div>
  </div>
  <div class="container-fluid">
    <?php if ($error_warning) { ?>
    <div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> <?php echo $error_warning; ?>
      <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>
    <?php } ?>
    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title"><i class="fa fa-pencil"></i> <?php echo $text_edit; ?></h3>
      </div>
      <div class="panel-body">
        <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form-account" class="form-horizontal">
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-status"><?php echo $entry_status; ?></label>
            <div class="col-sm-10">
              <select name="accountlogin_status" id="input-status" class="form-control">
                <?php if ($accountlogin_status) { ?>
                <option value="1" selected="selected"><?php echo $text_enabled; ?></option>
                <option value="0"><?php echo $text_disabled; ?></option>
                <?php } else { ?>
                <option value="1"><?php echo $text_enabled; ?></option>
                <option value="0" selected="selected"><?php echo $text_disabled; ?></option>
                <?php } ?>
              </select>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>
<?php echo $footer; ?>

Please let us know if you have any questions or concerns. Please don’t forget to post your questions or comments so that we can add extra topics and Opencart free module. You can follow us at our twitter account @rupaknpl and subscribe to our YouTube channel for opencart tutorials.

Great experience working with Limelight CRM

We have had great experienced working with Limelight CRM. Here are the following things that we have worked:

  1. Campaign management and offer management
  2. Maintain the servers
  3. Sites are all hosted in RackSpace and have load balancing to balance the visitor’s load.
  4. Maintain security: Uses Cloudflare to maintain security and have performed many other tasks to obtain the best security
  5. Maintain page loads
  6. Integrate limelight in more than 50 websites.
    Uses both the Webform and API form and integrated into the design, sometimes 2-page checkout sometime one-page-checkout
  7. Subscription management of the campaign
    Have not to design the PSD but can perform image changing and editing as per the necessity of the site.
  8. Bootstrap uses for responsiveness
  9. Upsell management for each offer and campaigns
  10. Payment load balancing management
  11. and many more.

Let us know if you have any questions or suggestions or requirements. You can also find us on Twitter and Facebook.

Sidebar column shopping cart for OpenCart Version 2/3

Hi, today we are publishing another free Opencart module “Sidebar Shopping Cart” and we made this for OpenCart version 2.0.3.1. Problem is we cannot edit js file with vQmod so you need to override the common.js file. But we have described where you need to put the extra code below in this post.

JS/CSS files are rendered at the browser level, not at the server level, so vQmod has no effect on these files. You can, however, create new files and use vQmod to alter the tpl files to point to these new CSS/JS files.

Output after installing the module is shown as in the image below:

sidebar shopping cart
Sidebar Shopping Cart

You can see how we copied the header cart section and show it as a module inside the cart box or side shopping cart. You can show anywhere you like as this is a module so you can show at the left column, right column or top content or bottom content.

Download the module from here:

Download Sidebar shopping cart OpenCart free module

Installation:

  1. Unzip the downloaded folder.
  2. Upload the files in the root folder to your server, the common.js file is overwritten so if you have any kind of custom javascript used then please transfer to the file and upload the common.js.
  3. Then activate the Shopping Cart module.

Activating the Sidebar Shopping Cart module:

  1. After uploading files to servers, it’s time to install Sidebar shopping cart module
  2. We are showing the sidebar shopping cart in the right column but you can show it wherever you like as this is acts as a normal module.
  3. Go to Admin section
  4. Then click on Extensions on the left menu
  5. After that Click Modules and go to “Shopping Cart” in the modules list
  6. Then click the green button to install the module (see the image below)
installation of module
installation_of_module

Then click the blue edit button

After that, you will see the form which has the status field, select “Enabled” and then click the Save button.

Your module is active and is ready to use in the layout.

Setup layout for the sidebar shopping cart at home page:

  1. From the admin section go to System >> Design >> Layouts.
  2. You will see a list of layouts, from which edit the “Home” layout.
  3. Then click Blue add the button to add rows at module section which is shown in the image below:
siderbar shopping cart installation
siderbar_shopping_cart_installation

Second, you choose the Shopping Cart in the module column and Column right in the Position column and insert the sort order as required.

Then click save button

Your custom sidebar shopping cart is showing in the right column of the home page. Likewise, you can show in many other layouts and pages.

Codes to added to common.js if you don’t want to override it:

  1. Open catalog/view/javascript/common.js
  2. Find the following lines of code
    $('#cart > ul').load('index.php?route=common/cart/info ul li');
  3. Just below it add following lines of code
    $('#shoppingcart > span').load('index.php?route=module/shoppingcart/info span');
  4. There are around 4 places where you have to add the above code.
  5. Then save the common.js file and upload it to the server and the module works perfectly.
  6. Your module is ready to use in other places except for the product detail page.

Making changes in the product detail page to make our module works:

  1. Go to catalog/view/theme/YOURTHEMENAME/product/product.tpl
  2. Find the following lines of code.
    $('#cart > ul').load('index.php?route=common/cart/info ul li');
  3. Just below it add following lines of code
    $('#shoppingcart > span').load('index.php?route=module/shoppingcart/info span');
  4. Then save and upload to the server and Sidebar shopping cart is ready to be used on the product page also.

Now click add to cart button and see how shopping cart animation changes the details with the use of Ajax functionality.

Let me know if you get any problem with performing the above tasks in the comment so that we can help if you have any.

OpenCart reCAPTCHA to show in registration and contact us page Part 2

In part 1 we showed how to activate google reCaptcha in contact us page, now we show how to show it on the registration page. Although it is not that simple as showing in the contact us page, we have to make some changes in code. For now, we are changing directly into the default file although it is not recommended :). We will try to provide OCMOD soon in the next post so you need to wait for the next post.

Go to the link below to see how to set up in OpenCart version 2.3.0.1
https://webocreation.com/set-google-recaptcha-basic-captcha-opencart-2-3-0-1

SEE for Opencart 3: Set up google reCaptcha in Opencart version 3

Steps are as follows:

Changes to be made at the language file:

  1. First go to catalog/language/english/account/ and open register.php file.
  2. Add the following code to the end of the file.
    $_['text_google_recaptcha']= 'Google reCaptcha';
    $_['error_captcha'] = 'Verification code does not match the image!';
  3. Save the file

Changes to be made at the controller file:

  1. Go to catalog/controller/account/ and open register.php file
  2. Find the following lines of code which is inside the index method
    $data['column_left'] = $this->load->controller('common/column_left');
  3. Just above that code paste following code
    $data['text_google_recaptcha'] = $this->language->get('text_google_recaptcha');
    if (isset($this->error['captcha'])) {
    $data['error_captcha'] = $this->error['captcha'];
    } else { $data['error_captcha'] = ''; }
    if ($this->config->get('config_google_captcha_status')) {
    $this->document->addScript('https://www.google.com/recaptcha/api.js');
    $data['site_key'] = $this->config->get('config_google_captcha_public');
    } else { $data['site_key'] = ''; }
  4. Now find the following lines of code which is inside the validated method.
    // Agree to terms
    if ($this->config->get('config_account_id')) {
    $this->load->model('catalog/information');
    $information_info = $this->model_catalog_information->getInformation($this->config->get('config_account_id'));
    if ($information_info && !isset($this->request->post['agree'])) {
    $this->error['warning'] = sprintf($this->language->get('error_agree'), $information_info['title']); } }
  5. Now above that code paste following code.
    if ($this->config->get('config_google_captcha_status')) {
    $recaptcha = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($this->config->get('config_google_captcha_secret')) . '&response=' . $this->request->post['g-recaptcha-response'] . '&remoteip=' . $this->request->server['REMOTE_ADDR']);
    $recaptcha = json_decode($recaptcha, true);
    if (!$recaptcha['success']) {
    $this->error['captcha'] = $this->language->get('error_captcha');
    }
    }
  6. Save the file and your controller is ready

Changes to be made at the template theme file:

  1. Go to catalog/view/theme/default*/account/ and open register.tpl, default* means if you are not using default theme then it will be theme name you are using.
  2. Find the following line of code
    <?php if ($text_agree) { ?>
  3. Just above the code above, paste the following code
    <fieldset>
    <legend><?php echo $text_google_recaptcha; ?></legend>
    <?php if ($site_key) { ?>
    <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
    <div class="g-recaptcha" data-sitekey="<?php echo $site_key; ?>"></div>
    <?php if ($error_captcha) { ?>
    <div class="text-danger"><?php echo $error_captcha; ?></div>
    <?php } ?>
    </div>
    </div>
    <?php } ?>
    </fieldset>
  4. Save the file

Now go to your registration page and you will see the page like below:

Activate google recaptcha at registration page in Opencart
Activate google ReCaptcha at registration page in Opencart

Let us know if we missed anything and if you need any help.

Thanks
Rupak Nepali

Laravel Shop Coming Soon

Hi to all,

I have started to read laravel and started it with registering http://laravelshop.com and all my updates will be posted at laravelshop.com. Today I make logo and set up server and register domain. Likewise I set up facebook page https://www.facebook.com/pages/Laravel-Shop/1420260531616136

GitHub page is https://github.com/rupaknepali/laravelshop

Google plus page : https://plus.google.com/+Laravelshop-page/about

Logo designed as below, I am not good at designing but also I managed to make as following taking laravel logo and opencart logo 🙂

laravel shop logo
laravel shop logo

I try to keep you update daily how I am moving with laravel and how i achieve updates in laravelshop.com

Thanks
Rupak Nepali

Create a class diagram for free and store it privately and collaborate with multiple users

I was searching for the best website where I can create a class diagram for free and I found Cacoo which provides a website to create class diagram for free and can store it privately and collaborate with multiple users. Being a developer I have to design a class diagram, flow charts, business organizational chart, matrix diagram, Venn diagram, SWOT diagram, and schedule diagram and many more. I was looking for a free and private class diagram and found this Cacoo and am very happy to use it and it’s drag and drop system is so easy to use.

create class diagram  for free
create class diagram for free

We can draw:

  1. Business Diagram like: Business organizational chart, matrix diagram, Venn diagram, SWOT diagram, and schedule diagram
  2. Flow Chart
  3. Mind Map
  4. Network Map like network diagram and AWS design template
  5. Office layout
  6. Sitemap
  7. Wireframe for different devices
  8. UML where you can draw state machine diagram, use case diagram, sequence diagram, class diagram, activity diagram, package diagram
  9. Database design
  10. Greeting Card design, Happy New Year, happy holidays, happy birthday and many more
  11. Electronics diagrams like Ohm’s law
  12. And also contained User-defined Templates.

So containing many drawing sections, I am happy to use it and hope it keeps on providing a free account. https://cacoo.com/

Bokagiri part 2: Dad called me when he read my previous status and told me

Second-week status Update: Dad called me when he read my previous status and told me following things 🙂

Pachilo status padeyachan buda ley.

Dad ko phone aiyoo.
Choro k cha sarai bigreychas yo sab yeklo pan ley garda vako ho abba bihe garnu parcha, kt ta taliley nai khojiyako chas hola.

Yo sunna sath hindi film ma jasto purai flash back ma gaiyoo…
10 class samma love vaniyako taha thiyana
12 class ma kt thiyana
Abba bachelor ma ta keai hola vaniyako bachelor ma pani khalee boka gang purai sukka.
Kam pani Freelancer vai gariyoo ani kaha bata kt khojnu, dukkha bujiyo abba master garchu vane garna bidesh lagiyo ani Mastery ma k vannu ba sab kali matra thiyee.
Aile kam garna suru gariyoo office ma sabbai budi matra ba. ani maile kasaree KT khojnu. Yo flashback ko douran budaley k k vanee kunni.
Ani mailee Dad ailee time vako chaina vanee.

Dad: Maile tero age ma timi haru tin jana daju vai lai janmai sakiyako thiyee yo ajjai time vako chaina vancha. Bujney lai kasaree bujaunu. Suteako manchelai po uthauna sakincha. Suteako natak garne lai kasaree uthaunu. Ani sun, talai euta warning cha hai Bihe chai Nepal mai aai garnu parche ne. Buda ley yo kura pani milayarai vaniyaka hunu buda lai thaha cha yo programmer ho khale error lai matra dhyan dincha warning lai didaina vaannee.
Ani office kasto cha ta dad ko question.
Babbal cha dad, 2 din dhilo gako thiyee gadi kinee diyo, ani ma pani bato vai laptop pani slow vairako cha vandai chu 🙂. Ani Office ma bachha bachi ko matra kura huncha dad, sab jana budi chan, matra k vaniyako thiyee.
Budaley tero pani kapal ta chaina ta vane peylee halee.

Ani buda pani hasey ma chai mutu mathi dhunga rakhi hasna chai chodina hai.

Yesaree nai beer ko sur ma lekhak vako suchana 🙂

Happy Weekend

कुरोः असारे महिना, हातमा ठेला उठाई खनी तयार पारेको खेतमा

असारे महिना, हातमा ठेला उठाई खनी तयार पारेको खेतमा पानी लगाई, कच्याक–कच्याक गरी थिचेको अालि । अालि थिच्दा थिच्दै भत्केको कान्लो अनि कुद्दै गई  बनाएको कान्लो अनि फेरि उहि कच्याक–कच्याक गरि थिचेको आलि। अनि थिचेको आलि लगाएर टलपल टलपल पारी जमाएको पानी।

अब त्यहि पानीले गलाएको ड्यागहरु सम्माउने काम, पानीलाई level measuring tape मानि जता गहिरो उत्तैबाट ड्याग फाडन सुरु र अग्लो ठाउँबाट होचो ठाउँमा मरि मरि फालेको माटो। जति सम्म बनाउन सक्यो त्यति धेरै धान फल्छ भन्ने सिकाई। यसरी ड्याग सम्माइ, रोपाईको लागि तयार र रोपाई भोलि ।

आज रोपाई, बिहानै अाज उठ बाबु भोलि सुत्लास् झट्टो गरी ब्याडमा चिया पुराइ आउ भनि आमाले अराएको मिठो बोलि।

उठि रातो चियाको थरमस, गिलास लिइ ब्याडमा पुगि, जरामा समाइ काटेको धानको बिउ र बिउ काट्दै जादा कुन सर्कोमा कमिला तिघ्रामा चडि, रातो हुने गरी चिसिक पार्ने। बिउको मुठ्ठा पनि तयार भो, अब बिहानको खाना खाने बेला अनि अाज चाडै सक्नु पर्छ चाडै आएर बाउसे गर्नु है भन्दै सब अा-आफ्नो घर खाना खान।

खाना खाई कोदाली, घुम र पुजाको सरसामान ली पधेरामा गई पुर्व फर्की नाग देवतालाई निगालोमा राखेको कपास चढाइ गरेको पुजा र खेतमा पुगि दुइटा मुठोको बिउ र कलश राखि गरेको पुजासगै निधारमा रातो टिका।

अब रोपारहरु बिउ अोसार्ने, म चाही लाठे बाउसे गर्ने, अाली काटि बाउसे सुरु र जति सकिन्छ त्यति सम्म बनाउनु पर्ने। कोदालीले दायाँ-बायाँ गर्दै समाएर अग्लो देखिएको ठाउँको माटो होचो ठाउँमा फाल्दै अगि बढ्ने। हामी लाठेले सम्माएको ठाउँमा रोपारहरु छुप्लुप छुप्लुप रोप्न सुरु। हामी सम्माउने निउँमा छिन-छिनमा रोपार तिर फालेको माटोले रोपारलाई नित्थुक बनाई रमाइलो गर्ने। रोपारेहरु लामो भाका हाली गीत गाउदै रोप्ने।बर्षायाम पानी परेसँगै घुम अोड्नु र रोकिएसगँ घुम राख्नु।

अोहो त्यो उसिनेको अालुको अचार त्यसमा उसिनेकै हरियो खुर्सानी, भटमास र लसुनको अचार अनि टाइचिन चामलको चिउरा उफ मुखबाट पानि नै निक्लियो नि।

मसला बाढने काम, कसलाई ठुलो नरिवल र धेरै चक्लेट भन्दै कुदा कुद।

योसगँ मुरीका मुरी धान फल्ने आश र भरोसासगँ रातको मिठो निन्द्रा तर पारी पट्टी र जस्ताको छानामा चाही अजै तप तप गरि आवज आइरहेको छ तर पनि मस्त निन्द्रालाई रोक्न सक्ने कोही छैन।

मैले त रोपाई गरी सुत्न थाले तपाईको के छ स्थिति।

मैले नि केहि त गर्नु पर्यो भनि पुरै सोच र planning मा थिए। Plan के भन्दा “भट्टी Valley (BV)”

Weekend, bhanna sath Party, पार्टी भन्ना साथ Beer यो तालि चाहि “Guinness Beer”, Beer हुनासाथ लेखाइ सुरु।

धेरै केटाहरुले किन लेखिन्स भनि सोधे, देशमा भुकम्प गएर थन्थिलो पारेको थियो त्यस लगत्तै तराइ आन्दोलन, देश जरजर अवश्थामा मैले नि केहि त गर्नु पर्यो भनि पुरै सोच र planning मा थिए। Plan के भन्दा “भट्टी Valley (BV)” खोल्ने।

beer plant

क्षेत्रफल २०० रोपनी भन्दा बढि, कुल लागतः २ खर्ब १ रुपया।

१ रुपया चाही मैले जम्मा गरी सके, अब अरु साथी भाइलाई Investment ko सुर्वण अवसर!!!!

Planning चित्रमा देखाइएको छ।
1. पाहडको टुप्पामा भट्टी Hotel in beer bottle-shaped architecture
2. Vatti Bank
3. Cable Car loading/unloading section for भट्टी Hotel called it as CAN 2.
4. Helipad
5. Garden section
6. Water and Bottling Plant
7. Exit Road
8. Poultry farm
9. Cattle farm
10. फापर बारी
11. Parking lot 3
12. Recreation Center
13. कोदो बारी
14. Road
15. Tori Bari
16. Vatti Research and Development
17. Great Wall of Vatti Valley
18. The University of भट्टी
19. Entrance for Vatti Valley
20. Gate 1 is for the cable car
21. Gate 2 is for Road
22. Gate 3 is for Exit
23. Entry Road
24. Parking lot 2
25. Coming soon……..
26. Parking lot 1
27. भट्टी Valley market
28. Exit road
29. Cable car 1 in shape of CAN beer to return from Vatti hotel
30. Cable car 2 in shape of CAN beer to go to Vatti hotel
31. Security 1
32. Security 2

सब कुरा राखि सकेको छैन, नत्र आइडा चोरी होला भन्ने पनि डर छ नि

‪#‎हावाकुरारिलोढेड‬ ‪#‎Kuro‬ haha

Happy Weekend

हिजोसम्म “कहाँ पुग्ने हो दाइ ?” भनेर सोध्ने बसको कन्डक्टर आजदेखी “कहाँ पुग्ने अंकल ?

हिजोसम्म “कहाँ पुग्ने हो दाइ ?” भनेर सोध्ने बसको कन्डक्टर आजदेखी “कहाँ पुग्ने अंकल ? ” पो भन्छ बा ! बुढो भइयो कि क्या हो ?
अनि बुढो भएर अजै Single uff, अनि फेरि सम्झे अनि हासे सोच्दै,
Batman single, Superman single
Spiderman single, Hanuman single
हाम्रा Salman single
भने सी ममा पनि केहि हुनु पर्छ Single हुनुको राज !!!!
Happy Weekend 🙂