Calling Developers!
We are reenergizing our code contribution process! Learn More

What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

It worked well, without passing data from indexcontroller to twig. Looks like passing data to twig f

Options
UPWG882P6
UPWG882P6 Posts: 140 🧑🏻‍🚀 - Cadet

It worked well, without passing data from indexcontroller to twig. Looks like passing data to twig file is failing. Can someone help.

"Template "@HelloWorld/views/index/index.twig" is not defined."
«13

Comments

  • how does the controller look like? and the path to the template?

  • UPWG882P6
    UPWG882P6 Posts: 140 🧑🏻‍🚀 - Cadet
    Options
    /**
     * @param \Symfony\Component\HttpFoundation\Request $request
     *
     * @return \Spryker\Yves\Kernel\View\View
     */
    public function indexAction(Request $request)
    {
        $data = ['helloWorld' => 'Hello Spryker!'];
        return $this->view(
            $data,
            [],
            '@HelloWorld/views/index/index.twig'
        );
    }
    
  • DOes the path of the index.twig as appears in the render view call?

  • UPWG882P6
    UPWG882P6 Posts: 140 🧑🏻‍🚀 - Cadet
    Options
    {% extends template('page-layout-main') %}
    {% define data= {
        helloWorld: _view.helloWorld
    } %}
    {% block content %}
        <div class="row">
            <div class="small-12 columns">
                <h2>{{ data.helloWorld }} </h2>
            </div>
        </div>
    {% endblock %}
    
  • UPWG882P6
    UPWG882P6 Posts: 140 🧑🏻‍🚀 - Cadet
    Options
    /**
     * @param \Spryker\Yves\Router\Route\RouteCollection $routeCollection
     *
     * @return \Spryker\Yves\Router\Route\RouteCollection
     */
    protected function addHelloWorldIndexRoute(RouteCollection $routeCollection): RouteCollection
    {
        $route = $this->buildRoute('/hello-world', 'HelloWorld', 'Index', 'indexAction');
        $routeCollection->add(static::ROUTE_HELLO_WORLD_INDEX, $route);
    
        return $routeCollection;
    }
    
  • can you post a screenshot to the relevant file tree in the project?

  • the views/ directory is missing in the middle there

  • UPWG882P6
    UPWG882P6 Posts: 140 🧑🏻‍🚀 - Cadet
    Options

    Still the same error.. it didnt changed.

  • Unknown
    edited September 2020
    Options

    did you try to clear the cache? vendor/bin/console cache:empty-all

  • UPWG882P6
    UPWG882P6 Posts: 140 🧑🏻‍🚀 - Cadet
    Options

    Did it, still. the same

  • can you send a screenshot of the entire error message?

  • UPWG882P6
    UPWG882P6 Posts: 140 🧑🏻‍🚀 - Cadet
    Options

    sure

  • i am running out of obvious ideas here 🤔

  • also need to leave soon

  • UPWG882P6
    UPWG882P6 Posts: 140 🧑🏻‍🚀 - Cadet
    Options

    We can see tomorrow, I have leave too.

  • UPWG882P6
    UPWG882P6 Posts: 140 🧑🏻‍🚀 - Cadet
    Options

    Have a lovely evening.

  • @U01AHAH9478 still around?

  • thanks! you too! let’s solve it tomorrow!

  • Yeap

  • good morning

  • fresh day, fresh luck! 🙂

  • UPWG882P6
    UPWG882P6 Posts: 140 🧑🏻‍🚀 - Cadet
    Options

    Good morning, restarted my system, its the same .

  • U01AM1YGRC2
    U01AM1YGRC2 Posts: 71 🧑🏻‍🚀 - Cadet
    Options

    Hello 🙂 ASAIK I did the same and had to register the RouteProviderPlugin to an Array. Also I had a bit trouble with the caching at the first time.

  • hi! thanks norman! i think we have the route provider correctly registered, because it tries to load the right template, but fails to do so

  • U01AM1YGRC2
    U01AM1YGRC2 Posts: 71 🧑🏻‍🚀 - Cadet
    Options

    src/Pyz/Yves/Router/RouterDependencyProvider.php

  • U01AM1YGRC2
    U01AM1YGRC2 Posts: 71 🧑🏻‍🚀 - Cadet
    Options

    Ah it fails at twig?

  • but can you please check, @UPWG882P6?

  • yes

  • unfortunately i don’t have time before 1230 😕

  • U01AM1YGRC2
    U01AM1YGRC2 Posts: 71 🧑🏻‍🚀 - Cadet
    Options

    @UPWG882P6 I’m not sure about your HelloWorldRouteProviderPlugin, maybe you forgot to extend from the AbstractRouteProviderPlugin and use the addRoutes Method ? Like --> https://documentation.spryker.com/docs/tutorial-hello-world-scos