变量“organization_name”不存在。在调用新的oro动作时

时间:2017-09-30 19:51:55

标签: symfony symfony1 symfony-1.4 orocrm orocommerce

我创建了新的控制器和新视图

<?php

namespace My\ProductBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

class ProductController extends Controller
{
    /**
     * @Route("/GetProducts")
     */
    public function GetProductsAction()
    {
        return $this-&gt;render('MyProductBundle:Product:get_products.html.twig', array(

        ));
    }

}

视图:

 {% extends "::base.html.twig" %}

{% block title %}MyProductBundle:Product:GetProducts{% endblock %}

{% block body %}
&lt;h1&gt;Welcome to the Product:GetProducts page&lt;/h1&gt;
{% endblock %}

尝试访问此操作时/ GetProducts

我收到以下错误:

Variable "organization_name" does not exist. 

堆栈跟踪

    in vendor\oro\customer-portal\src\Oro\Bundle\FrontendBundle\Resources\views\Organization\logo_frontend.html.twig at line 3  -
        {% set route = 'oro_frontend_root' %}
        {% if isDesktopVersion() %}
            {% if organization_name|length %}
                {% set logo = oro_theme_logo() %}
                &lt;h1 class="logo logo-{{ logo ? 'image' : 'text' }}"&gt;
                    &lt;a href="{{ path(route) }}" title="{{ organization_name }}"&gt;

2 个答案:

答案 0 :(得分:1)

艾曼侯赛因。

您应该扩展比::base.html.twig更具体的模板。

例如,您的视图可能看起来像

{% extends 'OroFrontendBundle:actions:view.html.twig' %}

{% block title %}MyProductBundle:Product:GetProducts{% endblock %}

{% block body %}
    <h1>Welcome to the Product:GetProducts page</h1>
{% endblock %}

答案 1 :(得分:0)

{% if organization_name|length %}之前添加另一个条件以检查var是否已定义:{% if organization_name is defined %}