New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Undefined view variables creating addon Controller #906

Closed
ianhubbard opened this Issue Aug 27, 2016 · 2 comments

Comments

Projects
None yet
3 participants
@ianhubbard

ianhubbard commented Aug 27, 2016

Steps to reproduce

  1. Create a new Controller addon with php please make:controller AddonName
  2. Create meta.yaml
  3. View addon page in CP at /cp/addons/AddonName

Expected behaviour

The default (empty) index view would display with "Content"

Actual behaviour

PHP error Undefined variable: update_available (View: <snip>/statamic/resources/views/partials/nav-main.blade.php)

There are 3 variable errors - update_available, is_trial and is_unlicensed.

Adding those to the view data array resolves the issue (eg):
return $this->view('index', ['update_available' => false, 'is_trial' => true, 'is_unlicensed' => false]);

Alternatively removing the 2 partials lines @include('partials.nav-main') and @include('partials.alerts') from layout.blade.php also resolves the issue.

Obviously neither of these options is ideal. Grepping the code shows that you are sharing update_available in the Outpost Middleware, but presumably that isn't included for Addon Routes or something? The other 2 variables don't appear:

$ grep -rn "view()->share" *
statamic/core/Http/Middleware/Outpost.php:104:        view()->share('update_available', $this->outpost->isUpdateAvailable());

Server configuration

Operating system:
Debian Stretch (Linux)

Web server:
Nginx

PHP version:
7.0.9-2

Statamic version:
2.1.3

Updated from an older Statamic or fresh install:
From 2.1.2 I think

List of installed addons:
(none other than the base example)

@ianhubbard

This comment has been minimized.

ianhubbard commented Aug 27, 2016

Have just updated to shiny 2.1.5 and still have the same issue.

@jeremykendall

This comment has been minimized.

jeremykendall commented Nov 14, 2016

I just ran into this today running 2.1.17 in Homestead 0.5.0. Any additional info?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment