Ayman Hussein
Ayman Hussein

Reputation: 3857

Variable "organization_name" does not exist. when call new oro action

I created new controller and new view

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

        ));
    }

}

view:

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

when try to access this action /GetProducts

I got the following error:

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;

Upvotes: 0

Views: 298

Answers (2)

Mykolai Miasnikov
Mykolai Miasnikov

Reputation: 46

Ayman Hussein.

You should extend more specific template than ::base.html.twig.

For example, your view can looks like

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

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

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

Upvotes: 1

before {% if organization_name|length %} add another condition to check if the var is already defined or not: {% if organization_name is defined %}

Upvotes: 0

Related Questions