2017-09-30 20 views
0

J'ai créé nouveau contrôleur et nouvelle vueLa variable "nom_organisation" n'existe pas. lorsque l'appel nouvelle action oro

<?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(

     )); 
    } 

} 

Vue:

{% 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 %} 

lorsque vous essayez d'accéder à cette action/GetProducts

J'ai eu l'erreur suivante:

Variable "organization_name" does not exist. 

Stack Trace

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; 
+1

Avez-vous utilisé brindille avant? Des variables telles que nom_organisation sont normalement envoyées dans le cadre de l'appel de rendu. Mais dans ce cas, il semble être une brindille globale? Probablement devrait vérifier les documents de config Oro. Marquer votre question comme symfony1 semble un peu étrange aussi. – Cerad

Répondre

0

avant {% if organization_name|length %} ajouter une autre condition pour vérifier si le var est déjà défini ou non: {% if organization_name is defined %}

1

Ayman Hussein.

Vous devez étendre un modèle plus spécifique que ::base.html.twig.

Par exemple, votre vue peut ressemble

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

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

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