Post by abdullahTR » Wed Sep 04, 2024 11:01 pm

Hello.

Theme : Journal 3
Opencart : 3.0.4.0

Normally I was always using 3.0.3.2. There was no problem.

I decided to try opencart 3.0.4.0 on my test domain by installing everything from scratch. Everything is working stably, I'm having problems with only 2 plugins. I tried all php versions and it didn't work.

Code: Select all

$file = modification( DIR_TEMPLATE . $filename . ‘.twig’ );


I tried this did not work.

There is no problem with the plugin's files, I checked how many times.

This is the error, but I can't see any details, so I can't figure out what exactly is causing it.

Notice: Error: Could not load template extension/shipping/xshippingpro! in /home/demo/domains/democom/public_html/v1/system/system/storage/modification/system/library/template/twig.php on line 58

Notice: Error: Could not load template extension/module/promotionModule/promotion_stats! in /home/demo/domains/demo.com/public_html/v1/system/system/storage/modification/system/library/template/twig.php on line 58

These are the line 58 codes where the error appears

Code: Select all

trigger_error('Error: Could not load template ' . $filename . '!');
How can I solve this problem?

/system/library/template/twig.php //file content

Code: Select all

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

	public function set($key, $value) {
		$this->data[$key] = $value;
	}
	
	public function render($filename, $code = '') {
		if (!$code) {
			$file = DIR_TEMPLATE . $filename . '.twig';

			if (defined('DIR_CATALOG') && is_file(DIR_MODIFICATION . 'admin/view/template/' . $filename . '.twig')) {	
                $code = file_get_contents(DIR_MODIFICATION . 'admin/view/template/' . $filename . '.twig');
            } elseif (is_file(DIR_MODIFICATION . 'catalog/view/theme/' . $filename . '.twig')) {
                $code = file_get_contents(DIR_MODIFICATION . 'catalog/view/theme/' . $filename . '.twig');
            } elseif (is_file($file)) {
				$code = file_get_contents($file);
			} else {
				throw new \Exception('Error: Could not load template ' . $file . '!');
				exit();
			}
		}

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

		try {
			$loader = new \Twig\Loader\ArrayLoader(array($filename . '.twig' => $code));

            // Journal Theme Modification
            if (defined('JOURNAL3_ACTIVE')) {
                $j3loader = new \Twig\Loader\FilesystemLoader([], '');

			    if (defined('DIR_CATALOG') && is_dir(DIR_MODIFICATION . 'admin/view/template/')) {
			        $j3loader->addPath(DIR_MODIFICATION . 'admin/view/template/');
		        } elseif (is_dir(DIR_MODIFICATION . 'catalog/view/theme/')) {
			        $j3loader->addPath(DIR_MODIFICATION . 'catalog/view/theme/');
		        }

		        $j3loader->addPath(DIR_TEMPLATE);

			    $loader = new \Twig\Loader\ChainLoader(array($loader, $j3loader));
            }
		    // End Journal Theme Modification
            

			$twig = new \Twig\Environment($loader, $config);

			return $twig->render($filename . '.twig', $this->data);
		} catch (\Exception $e) {
			trigger_error('Error: Could not load template ' . $filename . '!');
			exit();
		}	
	}	
}
Last edited by abdullahTR on Thu Sep 05, 2024 11:38 pm, edited 1 time in total.

New member

Posts

Joined
Tue May 12, 2020 8:44 pm

Post by IP_CAM » Thu Sep 05, 2024 12:13 am


My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by ADD Creative » Thu Sep 05, 2024 12:22 am

Check you have .twig files for the two templates in the errors. Check using the default theme.

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by abdullahTR » Thu Sep 05, 2024 1:05 am

ADD Creative wrote:
Thu Sep 05, 2024 12:22 am
Check you have .twig files for the two templates in the errors. Check using the default theme.
The same error is present in the default theme. I also throw the twig file in the original installation file, but it does not fix. I get this error in the admin panel, not on the front face.

New member

Posts

Joined
Tue May 12, 2020 8:44 pm

Post by abdullahTR » Thu Sep 05, 2024 1:06 am

IP_CAM wrote:
Thu Sep 05, 2024 12:13 am
https://support.journal-theme.com/
I'm using the 3.0.3.2 dedejournal theme, no problem. 3.0.4.0 had a problem for some reason.

New member

Posts

Joined
Tue May 12, 2020 8:44 pm

Post by ADD Creative » Thu Sep 05, 2024 5:13 am

Adding $e->getMessage() to the trigger error string (or removing the try catch) might give you a better idea what the actual error is.

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by abdullahTR » Thu Sep 05, 2024 4:02 pm

ADD Creative wrote:
Thu Sep 05, 2024 5:13 am
Adding $e->getMessage() to the trigger error string (or removing the try catch) might give you a better idea what the actual error is.

Code: Select all

Fatal error: Uncaught Twig\Error\SyntaxError: Unexpected token "name" of value "if" ("end of statement block" expected) in "extension/shipping/xshippingpro.twig" at line 181. in /home/demo/domains/demo.com/public_html/v1/system/depo/vendor/twig/twig/src/TokenStream.php:76 Stack trace: #0 /home/demo/domains/demo.com/public_html/v1/system/depo/vendor/twig/twig/src/TokenParser/ForTokenParser.php(41): Twig\TokenStream->expect() #1 /home/demo/domains/demo.com/public_html/v1/system/depo/vendor/twig/twig/src/Parser.php(170): Twig\TokenParser\ForTokenParser->parse() #2 /home/demo/domains/demo.com/public_html/v1/system/depo/vendor/twig/twig/src/Parser.php(83): Twig\Parser->subparse() #3 /home/demo/domains/demo.com/public_html/v1/system/depo/vendor/twig/twig/src/Environment.php(490): Twig\Parser->parse() #4 /home/demo/domains/demo.com/public_html/v1/system/depo/vendor/twig/twig/src/Environment.php(518): Twig\Environment->parse() #5 /home/demo/domains/demo.com/public_html/v1/system/depo/vendor/twig/twig/src/Environment.php(350): Twig\Environment->compileSource() #6 /home/demo/domains/demo.com/public_html/v1/system/depo/vendor/twig/twig/src/Environment.php(312): Twig\Environment->loadTemplate() #7 /home/demo/domains/demo.com/public_html/v1/system/depo/vendor/twig/twig/src/Environment.php(280): Twig\Environment->load() #8 /home/demo/domains/demo.com/public_html/v1/system/depo/modification/system/library/template/twig.php(122): Twig\Environment->render() #9 /home/demo/domains/demo.com/public_html/v1/system/depo/modification/system/library/template.php(59): Template\Twig->render() #10 /home/demo/domains/demo.com/public_html/v1/vqmod/vqcache/vq2-system_depo_modification_system_engine_loader.php(133): Template->render() #11 /home/demo/domains/demo.com/public_html/v1/admin/controller/extension/shipping/xshippingpro.php(542): Loader->view() #12 /home/demo/domains/demo.com/public_html/v1/vqmod/vqcache/vq2-system_depo_modification_system_engine_action.php(79): ControllerExtensionShippingXshippingpro->index() #13 /home/demo/domains/demo.com/public_html/v1/admin/controller/startup/router.php(26): Action->execute() #14 /home/demo/domains/demo.com/public_html/v1/vqmod/vqcache/vq2-system_depo_modification_system_engine_action.php(79): ControllerStartupRouter->index() #15 /home/demo/domains/demo.com/public_html/v1/vqmod/vqcache/vq2-system_depo_modification_system_engine_router.php(134): Action->execute() #16 /home/demo/domains/demo.com/public_html/v1/vqmod/vqcache/vq2-system_depo_modification_system_engine_router.php(123): Router->execute() #17 /home/demo/domains/demo.com/public_html/v1/system/framework.php(179): Router->dispatch() #18 /home/demo/domains/demo.com/public_html/v1/vqmod/vqcache/vq2-system_startup.php(104): require_once('/home/muratozda...') #19 /home/demo/domains/demo.com/public_html/v1/admin/index.php(23): start() #20 {main} thrown in /home/demo/domains/demo.com/public_html/v1/system/depo/vendor/twig/twig/src/TokenStream.php on line 76
I cancelled the try-catch blog. This way I got full errors.

I solved my 1st problem by asking chatgpt. Thank you also for the solution you gave.

New member

Posts

Joined
Tue May 12, 2020 8:44 pm

Post by abdullahTR » Thu Sep 05, 2024 4:28 pm

Code: Select all

Fatal error: Uncaught Twig\Error\LoaderError: Template "extension/module/promotionModule/stats_page/tab_promotions.twig" is not defined in "extension/module/promotionModule/promotion_stats.twig" at line 45. in /home/demo/domains/demo.com/public_html/v1/system/depo/vendor/twig/twig/src/Loader/ArrayLoader.php:63 Stack trace: #0 /home/demo/domains/demo.com/public_html/v1/system/depo/vendor/twig/twig/src/Environment.php(264): Twig\Loader\ArrayLoader->getCacheKey() #1 /home/demo/domains/demo.com/public_html/v1/system/depo/vendor/twig/twig/src/Environment.php(312): Twig\Environment->getTemplateClass() #2 /home/demo/domains/demo.com/public_html/v1/system/depo/vendor/twig/twig/src/Environment.php(435): Twig\Environment->load() #3 /home/demo/domains/demo.com/public_html/v1/system/depo/vendor/twig/twig/src/Extension/CoreExtension.php(1340): Twig\Environment->resolveTemplate() #4 /home/demo/domains/demo.com/public_html/v1/system/depo/cache/template/46/46a3a6f858752e19b21387a6f0e2615be393ce08dc03353915467e5e526ab1c0.php(168): twig_include() #5 /home/demo/domains/demo.com/public_html/v1/system/depo/vendor/twig/twig/src/Template.php(394): __TwigTemplate_c3496ae6d60b8ead998ce4ea83f3a27d9d589f3a8af0fbfe1eb12973777f5409->doDisplay() #6 /home/demo/domains/demo.com/public_html/v1/system/depo/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling() #7 /home/demo/domains/demo.com/public_html/v1/system/depo/vendor/twig/twig/src/Template.php(379): Twig\Template->display() #8 /home/demo/domains/demo.com/public_html/v1/system/depo/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\Template->render() #9 /home/demo/domains/demo.com/public_html/v1/system/depo/vendor/twig/twig/src/Environment.php(280): Twig\TemplateWrapper->render() #10 /home/demo/domains/demo.com/public_html/v1/system/depo/modification/system/library/template/twig.php(122): Twig\Environment->render() #11 /home/demo/domains/demo.com/public_html/v1/system/depo/modification/system/library/template.php(59): Template\Twig->render() #12 /home/demo/domains/demo.com/public_html/v1/vqmod/vqcache/vq2-system_depo_modification_system_engine_loader.php(133): Template->render() #13 /home/demo/domains/demo.com/public_html/v1/admin/controller/extension/module/promotion.php(426): Loader->view() #14 /home/demo/domains/demo.com/public_html/v1/vqmod/vqcache/vq2-system_depo_modification_system_engine_action.php(79): ControllerExtensionModulePromotion->index() #15 /home/demo/domains/demo.com/public_html/v1/admin/controller/startup/router.php(26): Action->execute() #16 /home/demo/domains/demo.com/public_html/v1/vqmod/vqcache/vq2-system_depo_modification_system_engine_action.php(79): ControllerStartupRouter->index() #17 /home/demo/domains/demo.com/public_html/v1/vqmod/vqcache/vq2-system_depo_modification_system_engine_router.php(134): Action->execute() #18 /home/demo/domains/demo.com/public_html/v1/vqmod/vqcache/vq2-system_depo_modification_system_engine_router.php(123): Router->execute() #19 /home/demo/domains/demo.com/public_html/v1/system/framework.php(179): Router->dispatch() #20 /home/demo/domains/demo.com/public_html/v1/vqmod/vqcache/vq2-system_startup.php(104): require_once('/home/demo...') #21 /home/demo/domains/demo.com/public_html/v1/admin/index.php(23): start() #22 {main} thrown in /home/demo/domains/demo.com/public_html/v1/system/depo/vendor/twig/twig/src/Loader/ArrayLoader.php on line 63
This is my 2nd problem but chatgpt said no problem.
These are the codes in the file in the specified error. How can I solve this?

Code: Select all

<table class="table">
    <thead>
    <tr>
        <th>İsim</th>
        <th>Durum</th>
        <th>Misafir Kullanımı</th>
        <th>Üye Kullanımı</th>
        <th>Toplam Kullanım</th>
        <th>Sıralama</th>
        <th>Eylem</th>
    </tr>
    </thead>
    <tbody>
    {% for promo in promotion %}
    <tr>
        <td style="width:40%;">
            {{ promo.name }}
        </td>
        <td>
            <label class="switch">
                <input onChange="changeStatus(this);" {{ promo.status and promo.status == 'yes' ? 'checked="checked"' : '' }}  data-module-id="{{ promo.module_id }}" type="checkbox">
                <div class="slider round"></div>
            </label>
        </td>
        <td>
            {{ promo.uses.guests ? promo.uses.guests : '0' }}
        </td>
        <td>
            {{ promo.uses.customers ? promo.uses.customers : '0' }}
        </td>
        <td>
            {{ promo.uses.total ? promo.uses.total : '0' }}
        </td>
        <td>
            {{ promo.general_settings.sort_order ? promo.general_settings.sort_order : '0' }}
        </td>
        <td>
            <a href="{{ promo.link }}" data-toggle="tooltip" title="" class="btn btn-primary" data-original-title="Edit"><i class="fa fa-pencil"></i></a>
            <a onclick="confirm('Are you sure?') ? location.href='{{ promo.delete_link }}' : false;" data-toggle="tooltip" title="" class="btn btn-danger" data-original-title="Delete"><i class="fa fa-trash-o"></i></a>
        </td>
    </tr>
    {% else %}
    <tr>
        <td colspan="7" style="text-align: center;font-size:16px; padding-top: 30px; padding-bottom: 0;" colspan="6"> Kampanya oluşturmak için Kampanya Oluştur butonuna basınız.</td>
    </tr>
    {% endfor %}
    </tbody>
</table>

<div class="row">
    <div class="col-sm-12">
        <hr>
        <a href="{{ addnew }}" data-toggle="tooltip" title="Add new promotion" class="btn btn-info"><i class="fa fa-plus"></i>&nbsp;&nbsp;Kampanya Oluştur</a>
    </div>
</div>

New member

Posts

Joined
Tue May 12, 2020 8:44 pm

Post by ADD Creative » Thu Sep 05, 2024 5:28 pm

That suggests their is an issue with that extensions Twig template. It's possible it's not compatible with the later version of Twig included in 3.0.4.0.

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by JNeuhoff » Thu Sep 05, 2024 5:31 pm

Is there any reason why you won't contact the extension and/or theme author on this?

Anyway, the error message is clear enough, there is no extension/module/promotionModule/promotion_stats.twig file on your OpenCart server.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by abdullahTR » Thu Sep 05, 2024 5:50 pm

JNeuhoff wrote:
Thu Sep 05, 2024 5:31 pm
Is there any reason why you won't contact the extension and/or theme author on this?

Anyway, the error message is clear enough, there is no extension/module/promotionModule/promotion_stats.twig file on your OpenCart server.
/admin/view/template/extension/module/promotionModule

There is this file ‘promotion_stats.twig’ in ftp inside here.

I didn't want to deal with the producer if it was something I could solve myself.

New member

Posts

Joined
Tue May 12, 2020 8:44 pm

Post by ADD Creative » Thu Sep 05, 2024 8:03 pm

The second error suggests extension/module/promotionModule/stats_page/tab_promotions.twig is being included in extension/module/promotionModule/promotion_stats.twig at line 45. If this is the case and both files exist see viewtopic.php?t=219092.

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by JNeuhoff » Thu Sep 05, 2024 8:11 pm

@AddCreative: Well spotted. The extension author should however update it to not using '{% include %}' directives in the templates. Symfony Twig is bad enough, but in this case the sub-templates should be loaded in the controller, not in the twig template.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by abdullahTR » Thu Sep 05, 2024 9:03 pm

ADD Creative wrote:
Thu Sep 05, 2024 8:03 pm
The second error suggests extension/module/promotionModule/stats_page/tab_promotions.twig is being included in extension/module/promotionModule/promotion_stats.twig at line 45. If this is the case and both files exist see viewtopic.php?t=219092.
https://github.com/opencart/opencart/pu ... 1007184568

the solution in this link worked. I'm sorry to have troubled you. Thank you very much for your help.

Currently, there is no problem left on the front face and back face.

For those who will have this kind of problem, the contents of the twig.php file are like this.

Code: Select all

try {
    //$loader = new \Twig\Loader\ArrayLoader(array($filename . '.twig' => $code));
    $loader1 = new \Twig\Loader\ArrayLoader(array($filename . '.twig' => $code));
    $loader2 = new \Twig\Loader\FilesystemLoader(array(DIR_TEMPLATE)); // to find further includes
    $loader  = new \Twig\Loader\ChainLoader(array($loader1, $loader2));

    // Journal Theme Modification
    if (defined('JOURNAL3_ACTIVE')) {
        $j3loader = new \Twig\Loader\FilesystemLoader([], '');

        if (defined('DIR_CATALOG') && is_dir(DIR_MODIFICATION . 'admin/view/template/')) {
            $j3loader->addPath(DIR_MODIFICATION . 'admin/view/template/');
        } elseif (is_dir(DIR_MODIFICATION . 'catalog/view/theme/')) {
            $j3loader->addPath(DIR_MODIFICATION . 'catalog/view/theme/');
        }

        $j3loader->addPath(DIR_TEMPLATE);

        // Journal3 loader'ı mevcut loader ile birleştir
        $loader->addLoader($j3loader);
    }
    // End Journal Theme Modification

    $twig = new \Twig\Environment($loader, $config);

    return $twig->render($filename . '.twig', $this->data);
} catch (\Exception $e) {
    trigger_error('Error: Could not load template ' . $filename . '!');
    exit();
}

New member

Posts

Joined
Tue May 12, 2020 8:44 pm

Post by JNeuhoff » Thu Sep 05, 2024 9:20 pm

Glad to hear you managed to resolve it. Please add '[SOLVED]' to the beginning of this original form thread title.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am

Who is online

Users browsing this forum: No registered users and 32 guests