Coder Social home page Coder Social logo

Comments (4)

atnaples avatar atnaples commented on August 16, 2024

Did you find a solution?

Nothing wrong with vqMod or ocMod

I believe it's another step to block any changes/modifications of the greatest OpenCart code.

The problem with /system/library/template/twig.php file
modification.xml does not work and DOES NOT help
The system renders template only from original directories ONLY, I hope I am right

Try to replace the content of this file with the code below, I's helped me

<?php
namespace Template;
final class Twig {
	private $data = array();

	public function set($key, $value) {
		$this->data[$key] = $value;
	}
	
	public function render($template, $cache = false) {
				
		$loader = new \Twig\Loader\FilesystemLoader();
		
		// specify where to look for templates
		if (defined('DIR_CATALOG') && is_dir(DIR_MODIFICATION . 'admin/view/template/')) {	
			$loader->addPath(DIR_MODIFICATION . 'admin/view/template/');
		} elseif (is_dir(DIR_MODIFICATION . 'catalog/view/theme/')) {
			$loader->addPath(DIR_MODIFICATION . 'catalog/view/theme/');
		}
		
		$loader->addPath(DIR_TEMPLATE);

		// initialize Twig environment
		$config = array(
			'autoescape'  => false,
			'debug'       => false,
			'auto_reload' => true,
			'cache' 			=> false
		);

		if ($cache) {
			$config['cache'] = DIR_CACHE . 'template/';
		}
		
		// echo ($cache? 'true': 'false'), ' --- '; print_r($config);
		$this->twig = new \Twig\Environment($loader, $config);
		
		try {
			// load template
			$template = $this->twig->loadTemplate($template . '.twig');
			
			return $template->render($this->data);
		} catch (Exception $e) {
			trigger_error('Error: Could not load template ' . $template . '!');
			exit();	
		}	
	}	
}

from vqmod.

condor2 avatar condor2 commented on August 16, 2024

I don't use VQMOD. It was just a suggestion for developer to add compatibility.

from vqmod.

tmtung144 avatar tmtung144 commented on August 16, 2024

up

from vqmod.

MarvinKlein1508 avatar MarvinKlein1508 commented on August 16, 2024

Too add compatibility you can install this extension.
https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=39911

Alternativly add this code in vqmod_opencart.xml

<file path="system/library/template/twig.php" error="skip" info="fix Core Opencart twig files modification">
	<operation>
		<search><![CDATA[$file = DIR_TEMPLATE . $filename . '.twig';]]></search>
		<add position="replace"><![CDATA[$file = modification( DIR_TEMPLATE . $filename . '.twig' );
		if( class_exists('VQMod') ) {
			$file = \VQMod::modCheck($file);
		}
		]]></add>
	</operation>
</file>

A implemented fix for this would be nice.

from vqmod.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.