【问题标题】:Converting a site from a PHP site into a full LemonStand e-commerce site将网站从 PHP 网站转换为完整的 LemonStand 电子商务网站
【发布时间】:2011-11-28 16:29:27
【问题描述】:

全新 LemonStand,它是我开发客户网站的领跑者。

第一个使用 LemonStand 的候选网站是我用 PHP 构建的新网站。

我已经从 LemonStand CMS 中提取了所有非电子商务页面(例如关于和联系方式)。

但现在我正在尝试将简单的 PHP 包含的内容转换为部分内容:.

例子:

<? include 'standard_include.php'; ?>

<? include 'header.php'; ?>

到 LemonStand 的

<? $this->render_partial('standard_include') ?>

<? $this->render_partial('header') ?>

我得到一个与未定义变量相关的未处理异常:

这就是我的页面/模板开头的样子

<?php
require_once('lib/php/configuration.php');
$pagetype = 'home';
$subpagetype = 'index';
$titleValue = 'Client Name';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title><?php echo $titleValue ?></title>    

<? $this->render_partial('standard_include') ?>

</head>

<body>

<? $this->render_partial('header') ?>

在页面加载过程的后期(与 PHP 包含相比),部分是否才会呈现?

我是否错误地使用了部分?如果是这样,我该怎么做才能将 PHP 包含到 LemonStand 后门系统中?

【问题讨论】:

  • 发现一件有点被埋没了。也许我应该使用 Blocks 而不是 partials?
  • @John Watson,它是Undefined variable: pagetype 我认为 render_partial 发生在页面开始渲染之后,而 include 发生在之前,因此它具有 pagetype 的值。我认为解决方案是保留它们。我只是无法在他们的管理/后端系统中拥有每个文件。

标签: php e-commerce


【解决方案1】:

我从未使用过 Lemonstand,但如果它的 MVC 像其他 MVC 系统一样工作,那么您需要将 standard_include 所需的变量注入到视图中。比如:

$this->renderPartial('standard_include', array('pagetype'=>$pagetype, ...)) ?>

否则分部将无法访问您在父模板中定义的变量,因为分部在不同的上下文中呈现。

PHP include 的工作方式不同。它只是在执行脚本之前将包含的文件插入到位。

【讨论】:

  • 很遗憾,这不适用于我们的设置方式。
【解决方案2】:

我认为 render_partial 发生在页面开始渲染之后,而 include 发生在之前,因此它具有 pagetype 的值。

我认为解决方案是保留它们。我只是无法在他们的管理/后端系统中拥有每个文件。

对于常见元素,包含 LemonStand 的模板似乎没有做任何事情,只是将它们内联,这显然不是在整个网站上更改页眉或页脚等内容的最佳选择。

【讨论】:

    猜你喜欢
    • 2011-06-11
    • 1970-01-01
    • 2023-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多