Post by Weiqunw » Sat Oct 10, 2015 7:39 pm

We got the Override engine in our OC 1.5.6.4 shop, it is working with no problems.

But now I installed the AutomatedNewsletter 1.6 module by iSenselabs, when I want to create a new template i'm getting the following error:

Notice: Undefined offset: 1 in /home/puchshopte/domains/puchshop.de/public_html/test/system/library/variable_stream.php on line 66
Notice: Undefined offset: 1 in /home/puchshopte/domains/puchshop.de/public_html/test/system/library/variable_stream.php on line 87

I contacted iSenselabs but they said we have to contact the developer of the variable_stream.php, so of the override engine.
Can you help us?

User avatar
New member

Posts

Joined
Wed Jul 10, 2013 3:29 pm
Location - Arnhem, the Netherlands

Post by JNeuhoff » Sat Oct 10, 2015 8:42 pm

Weiqunw: Send me a PM with your OpenCart and FTP login details, and I can take a look at it. Looks like the AutmatedNewsletter somehow deviates from the standard MVC OpenCart design and tries to use a GLOBAL variable.

MHC Web Design
Override Engine * Integrated VQMod * Multilingual SEO * Instant Option Price Calculator * TrustPilot Reviews * Download Options * Free Download Buttons * Export/Import Tool * Template Switcher PHP/Twig


User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Weiqunw » Mon Oct 12, 2015 4:29 pm

JNeuhoff thanks for your reply.
I'm gonna send you a PM!

User avatar
New member

Posts

Joined
Wed Jul 10, 2013 3:29 pm
Location - Arnhem, the Netherlands

Post by matthew123 » Thu Oct 22, 2015 3:32 pm

Hi all

Trying to apply an override to a view, outside of the default template.

Folder structure is correct as far as I can see. Docu doesn't mention amendment of views, only model, controller and language files.

Is it as simple placing a .tpl in the correct folder structure of override/override_name/catalog/view/theme/theme_name/template/product/product.tpl

Thanks!

Newbie

Posts

Joined
Thu Oct 22, 2015 3:26 pm

Post by spanishdude » Tue Oct 27, 2015 7:07 pm

How can I install vQmod with override engine?

Newbie

Posts

Joined
Sat Mar 09, 2013 2:53 pm

Post by JNeuhoff » Wed Oct 28, 2015 6:27 am

matthew123 wrote:Hi all

Trying to apply an override to a view, outside of the default template.

Folder structure is correct as far as I can see. Docu doesn't mention amendment of views, only model, controller and language files.

Is it as simple placing a .tpl in the correct folder structure of override/override_name/catalog/view/theme/theme_name/template/product/product.tpl

Thanks!
Templates can only be modified in the controller, in the overridden method preRender. See FAQ at http://www.mhccorp.com/opencart/override-engine-oc2 or in the readme.txt file.

MHC Web Design
Override Engine * Integrated VQMod * Multilingual SEO * Instant Option Price Calculator * TrustPilot Reviews * Download Options * Free Download Buttons * Export/Import Tool * Template Switcher PHP/Twig


User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by JNeuhoff » Wed Oct 28, 2015 6:37 am

spanishdude wrote:How can I install vQmod with override engine?
When the Override Engine extends a class, the original parent class is possibly first modified by VQmod, before being included.

Before installing the Override Engine, you should clear the modifications cache via the admin backend at Extensions > Modifications,

You can then simply install our integrated VQmod, or the external VQmod.

MHC Web Design
Override Engine * Integrated VQMod * Multilingual SEO * Instant Option Price Calculator * TrustPilot Reviews * Download Options * Free Download Buttons * Export/Import Tool * Template Switcher PHP/Twig


User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by budgetneon » Fri Feb 19, 2016 9:05 pm

Took a look at this for extending the cart, but it appears that you're not fronting system/library/cart.php in the same way that you are doing for other base classes.

Is this correct?

That is, I can't extend the Cart class using the override engine, right?

New member

Posts

Joined
Sat Sep 20, 2014 11:32 pm


Post by JNeuhoff » Fri Feb 19, 2016 10:01 pm

budgetneon wrote:Took a look at this for extending the cart, but it appears that you're not fronting system/library/cart.php in the same way that you are doing for other base classes.

Is this correct?

That is, I can't extend the Cart class using the override engine, right?
Actually you can! For example, on one of our web sites we use a special free item shipping extension which needed an extended Cart class, like this:
  • override
    • shipping_free_item
      • system
        • library
          • cart.php
where the extended Cart class looks like this:

Code: Select all

<?php
class shipping_free_item_Cart extends Cart {


	// overridden method
	public function __construct($registry) {
		parent::__construct($registry);
		$this->log = $registry->get('log');
		$this->config = $registry->get('config');
	}


	// overriden method
	public function getWeight() {
		$weight = parent::getWeight();
		.....
		}

		return $weight;
	}
	.....
}
?>

User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by budgetneon » Fri Feb 19, 2016 10:56 pm

Perfect, thank you for the quick reply and detailed help.

New member

Posts

Joined
Sat Sep 20, 2014 11:32 pm


Post by budgetneon » Fri Feb 19, 2016 11:06 pm

Sorry, one more question.

I will likely make this override engine module a requirement for our page cache module. As of opencart 2.1.x, opencart no longer maintains a cart session variable, which we depended on to tell if the cart was empty or not. Long story, but because it's a page cache, it runs before the opencart engine, so we need a generic non-opencart method to check if the cart is empty of not. This override engine sounds like the cleanest way to restore the cart session variable.

If I make the override engine a dependency, I would like to be able to programmatically check that the override engine is installed+active...so we can show an error on our module status page if it's not. What's the best way to do that...hopefully in a way that it won't change in the future?

New member

Posts

Joined
Sat Sep 20, 2014 11:32 pm


Post by JNeuhoff » Fri Feb 19, 2016 11:45 pm

budgetneon wrote: If I make the override engine a dependency, I would like to be able to programmatically check that the override engine is installed+active...so we can show an error on our module status page if it's not. What's the best way to do that...hopefully in a way that it won't change in the future?
I usually check for the existence of a factory class instance, e.g.

Code: Select all

if (!empty($this->factory)) {
    // Override Engine is installed
}
BTW.: Can't you just use

Code: Select all

if ($this->cart->hasProducts()) {
    // cart is not empty
}
to check whether the cart is empty or not?

MHC Web Design
Override Engine * Integrated VQMod * Multilingual SEO * Instant Option Price Calculator * TrustPilot Reviews * Download Options * Free Download Buttons * Export/Import Tool * Template Switcher PHP/Twig


User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by budgetneon » Sat Feb 20, 2016 12:00 am

JNeuhoff wrote: I usually check for the existence of a factory class instance, e.g.

Code: Select all

if (!empty($this->factory)) {
    // Override Engine is installed
}
Perfect, thank you.
JNeuhoff wrote:
BTW.: Can't you just use

Code: Select all

if ($this->cart->hasProducts()) {
    // cart is not empty
}
to check whether the cart is empty or not?
Not in a pagecache, no. The idea is that a page cache would be as lean as possible....specifically not running any opencart code, at all, when a request comes in. That was possible prior to opencart 2.1.x, but not after.

We modify the top of the index.php file for opencart, and if we're serving a cached page out, we return() before any opencart code is run. That makes a page served from cache very lightweight...no database calls at all, etc. (https://github.com/budgetneon/v2pagecac ... stallation)

New member

Posts

Joined
Sat Sep 20, 2014 11:32 pm


User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by theme » Thu Mar 10, 2016 5:37 pm

How to use override-engine for opencart-2-2-0-0

Newbie

Posts

Joined
Thu Mar 10, 2016 5:23 pm

Post by JNeuhoff » Sat Mar 12, 2016 2:37 am

theme wrote:How to use override-engine for opencart-2-2-0-0
Just to follow up on your question you posted in the comments section of the Override Engine extension:
theme wrote: I have installed new open cart version 2.2.0.0. Then added override engine for 2.2.0.0.
I have declare new variable in /override/test1/controller/common/header.php

Code: Select all

<?php
class test1_ControllerCommonHeader extends ControllerCommonHeader {
	public function preRender( $template_buffer, $template_name, &$data ) {
		if ($template_name != $this->config->get('config_template').'/template/common/header.tpl') {
			return parent::preRender( $template_buffer, $template_name, $data );
		}

		$this->load->language( 'common/header' );
		$data['text_menu'] = $this->language->get( 'text_menu' );

		// call parent method
		return parent::preRender( $template_buffer, $template_name, $data );
	}
}
?>
Opencart 2.2.0.0 doesn't use the config_theme setting any more, hence the $this->config->get('config_theme') call will only get you a NULL. Normally I use this kind of code for what you are trying to accomplish:

Code: Select all

<?php
class test1_ControllerCommonHeader extends ControllerCommonHeader {
	public function preRender( $template_buffer, $template_name, &$data ) {
		
		// only modify if controller uses the 'header.tpl' template
		if (!$this->endsWith( $template_name, '/template/common/header.tpl' )) {
			return parent::preRender( $template_buffer, $template_name, $data );
		}

		// new text_menu variable
		$this->load->language( 'common/header' );
		$data['text_menu'] = $this->language->get( 'text_menu' );

		// call parent method
		return parent::preRender( $template_buffer, $template_name, $data );
	}


	private function endsWith( $haystack, $needle ) {
		if (strlen( $haystack ) < strlen( $needle )) {
			return false;
		}
		return (substr( $haystack, strlen($haystack)-strlen($needle), strlen($needle) ) == $needle);
	}

}
?>

MHC Web Design
Override Engine * Integrated VQMod * Multilingual SEO * Instant Option Price Calculator * TrustPilot Reviews * Download Options * Free Download Buttons * Export/Import Tool * Template Switcher PHP/Twig


User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Burt65 » Mon Mar 14, 2016 7:01 pm

JNeuhoff wrote:
straightlight wrote:Already did.
URL please? Where in OpenCart extensions?

UPDATE: 2 weeks later, and still no reply from straightlight, I think his improved version simply doesn't exist :)

Are you kidding me??? :choke: I just went through the whole 14 pages anxiously hoping to se the Url link and......nothing.

Oh well, maybe next year.... :ponder:

Over 95% of all computer problems can be traced back to the interface between the keyboard and the chair...


User avatar
Active Member

Posts

Joined
Mon Nov 18, 2013 3:23 pm
Location - Oz

Post by theme » Tue Apr 12, 2016 1:48 pm

I wan to add two new position options (middle_left) in layout. i have done bellow code in override/theme/admin/controller/design/layout.php
(when i click on add module button in layout form in position drop down middle_left options are added, but for previously added layout positions, in positions drop down (middle_left) is not added

Code: Select all

$str_search=array('<?php if ($layout_module[\'position\'] == \'column_right\') { ?><option value="column_right" selected="selected"><?php echo $text_column_right; ?></option><?php } else { ?><option value="column_right"><?php echo $text_column_right; ?></option><?php } ?>','html += \'    <option value="column_right"><?php echo $text_column_right; ?></option>\';');

$str_replace=array('<?php if ($layout_module[\'position\'] == \'column_right\') { ?>
                    <option value="column_right" selected="selected"><?php echo $text_column_right; ?></option>
                    <?php } else { ?>
                    <option value="column_right"><?php echo $text_column_right; ?></option>
                    <?php } ?>
             <?php if ($layout_module[\'position\'] == \'middle_left\') { ?>
                    <option value="middle_left" selected="selected"><?php echo $text_middle_left; ?></option>
                    <?php } else { ?>
                    <option value="middle_left"><?php echo $text_middle_left; ?></option>
                    <?php } ?>','html += \'    <option value="column_right"><?php echo $text_column_right; ?></option>\';
    html += \'    <option value="middle_left"><?php echo $text_middle_left; ?></option>\';');
        $template_buffer = str_replace($str_search,$str_replace,$template_buffer);
where i'm i going wrong?

Newbie

Posts

Joined
Thu Mar 10, 2016 5:23 pm

Post by JNeuhoff » Tue Apr 12, 2016 5:01 pm

You shouldn't use str_replace for finding multiple lines which has a high chance of failure because of the whitespaces and line endings, the latter differ depending on the operating system, e.g. "\n" on Linux or "\r\n" on Windows.

Use the modifier helper class instead, like this:

Code: Select all

		// modify the the template, to add support for the 'middle_left' option

		$this->load->helper( 'modifier' );
		$search = '<option value="column_right"><?php echo $text_column_right; ?></option>';
		$offset = 1;
		$index = 1;
		$add = <<<'EOT'
                    <?php if ($layout_module['position'] == 'column_middle') { ?>
                    <option value="column_middle" selected="selected"><?php echo $text_column_middle; ?></option>
                    <?php } else { ?>
                    <option value="column_middle"><?php echo $text_column_middle; ?></option>
                    <?php } ?>
EOT;
		$template_buffer = Modifier::modifyStringBuffer( $template_buffer, $search, $add, 'after', $offset, $index );

		$search = '<option value="column_right"><?php echo $text_column_right; ?></option>';
		$offset = 0;
		$index = 2;
		$add = <<<'EOT'
    html += '    <option value="column_right"><?php echo $text_column_right; ?></option>';
EOT;
		$template_buffer = Modifier::modifyStringBuffer( $template_buffer, $search, $add, 'after', $offset, $index );

User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by theme » Wed Apr 13, 2016 2:48 pm

Thanks JNeuhoff. Your solution worked.
I have one more issue. I want to give link for related products, of product where all related products will be displayed of particular product. I have created link & added new function info() as bellow in override/creta/catalog/controller/product/product.php

Code: Select all

public function preRender( $template_buffer, $template_name, &$data ) {
      if (!$this->endsWith( $template_name, '/template/product/product.tpl' )) {
      return parent::preRender( $template_buffer, $template_name, $data );
    }     
$data['related_list']= $this->url->link('product/product/info', 'product_id=' . $product_id);
 return parent::preRender( $template_buffer, $template_name, $data );
}
public function info($pro_id){
  $data['products'] = array();
  $this->response->setOutput($this->load->view('product/related_list.tpl', $data));
}
But on front end when i click on view button I'm getting message THE PAGE YOU REQUESTED CANNOT BE FOUND!

Newbie

Posts

Joined
Thu Mar 10, 2016 5:23 pm
Who is online

Users browsing this forum: No registered users and 11 guests