2017-09-30 1 views
0

Ich habe neue Controller und neue AnsichtDie Variable "organisationsname" existiert nicht. wenn Anruf neue oro Aktion

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

     )); 
    } 

} 

Ansicht:

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

, wenn versuchen, diese Aktion für den Zugriff auf/GetProducts

Ich habe folgende Fehlermeldung:

Variable "organization_name" does not exist. 

Stapel 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

Sie Zweig verwendet haben? Variablen wie organisationsname werden normalerweise als Teil des Renderaufrufs gesendet. Aber in diesem Fall scheint es ein globaler Zweig zu sein? Wahrscheinlich sollten Sie die Oro-Konfigurationsdokumente überprüfen. Das Markieren Ihrer Frage als symfony1 scheint auch etwas seltsam zu sein. – Cerad

Antwort

0

vor {% if organization_name|length %} eine weitere Bedingung hinzu, wenn die var definiert ist bereits zu überprüfen oder nicht: {% if organization_name is defined %}

1

Ayman Hussein.

Sie sollten spezifischere Vorlage als ::base.html.twig erweitern.

Zum Beispiel Ihre Ansicht kann sieht aus wie

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

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

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