[英]using php tags inside opencart html module
I need to call some php vars inside a html module on opencart, but when i use <?php?>
my page renders as <?--?php ?-->
. I need to call some php vars inside a html module on opencart, but when i use
<?php?>
my page renders as <?--?php ?-->
.
is there a way of doing this using the default HTML module of opencart 2.x有没有办法使用 opencart 2.x 的默认 HTML 模块来做到这一点
UPDATED更新
<?--?php ?-->
this comment caused by CKEDITOR. <?--?php ?-->
此评论由 CKEDITOR 引起。 But even without editor PHP will not run in standard OpenCart on client side.但即使没有编辑器 PHP 也不会在客户端的标准 OpenCart 中运行。 Here is a recipe howto deal with custom PHP in HTML module.
这是如何处理 HTML 模块中的自定义 PHP 的配方。
Adding extra field in OpenCart HTML module with PHP support.在支持 PHP 的 OpenCart HTML 模块中添加额外字段。
admin/view/template/extension/module/html.tpl , find admin/view/template/extension/module/html.tpl ,找到
<div class="form-group">
<label class="col-sm-2 control-label" for="input-description<?php echo $language['language_id']; ?>"><?php echo $entry_description; ?></label>
<div class="col-sm-10">
<textarea name="module_description[<?php echo $language['language_id']; ?>][description]" placeholder="<?php echo $entry_description; ?>" id="input-description<?php echo $language['language_id']; ?>" data-lang="<?php echo $lang; ?>" class="form-control summernote"><?php echo isset($module_description[$language['language_id']]['description']) ? $module_description[$language['language_id']]['description'] : ''; ?></textarea>
</div>
</div>
Add after之后添加
<div class="form-group">
<label class="col-sm-2 control-label" for="input-description2<?php echo $language['language_id']; ?>"><?php echo $entry_description; ?> 2</label>
<div class="col-sm-10">
<textarea name="module_description[<?php echo $language['language_id']; ?>][description2]" placeholder="<?php echo $entry_description; ?> 2" id="input-description2<?php echo $language['language_id']; ?>" data-lang="<?php echo $lang; ?>" class="form-control" style="min-height: 400px;"><?php echo isset($module_description[$language['language_id']]['description2']) ? $module_description[$language['language_id']]['description2'] : ''; ?></textarea>
</div>
</div>
This will be field for the second description.这将是第二个描述的字段。
catalog/controller/extension/module/html.php , find目录/控制器/扩展/模块/html.php ,找到
$data['html'] = html_entity_decode($setting['module_description'][$this->config->get('config_language_id')]['description'], ENT_QUOTES, 'UTF-8');
Add after之后添加
$data['html2'] = html_entity_decode($setting['module_description'][$this->config->get('config_language_id')]['description2'], ENT_QUOTES, 'UTF-8');
if (preg_match('|<\?php.+?\?>|isu', $data['html2'])) {
ob_start();
@eval('?>' . $data['html2']);
$data['html2'] = ob_get_contents();
ob_end_clean();
}
This will add a second field and with PHP render.这将添加第二个字段并使用 PHP 渲染。
catalog/view/theme/default(or YOUR_THEME)/template/extentsion/module/html.tpl目录/视图/主题/默认(或 YOUR_THEME)/模板/扩展/模块/html.tpl
Add at the end在最后添加
<?php if($html2) { ?>
<?php echo $html2; ?>
<?php } ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.