[Sage 10] How to handle parent/child theme composers - Code works in parent App but not in child App

Hey all,

I’ve made a child theme for my sage 10 project. All seemed to work fine. :slight_smile: But alas.

I’ve made a composer function in the parent theme in app/View/Composers/App.php Also included it in with()

Then I’ve placed some code in the header.blade to see it I got something.

When activating the parent theme this works fine. But when activating the child theme it only renders part of it. Not the direct variable.

{{\App\View\Composers\App::collapseBreakpoint()}} --
{!! $collapseBreakpoint !!} -- 
{{var_dump($collapseBreakpoint)}}

Parent app renders: lg -- lg -- string(2) "lg"
Child app renders: lg -- -- NULL

I’ve cleaned out the View of the ChildApp namespace.


namespace ChildApp\View\Composers;

use Roots\Acorn\View\Composer;

class ChildApp extends Composer {
    /**
     * List of views served by this composer.
     *
     * @var array
     */
    protected static $views = [
        '*',
    ];

    /**
     * Data to be passed to view before rendering.
     *
     * @return array
     */
    public function with() {
        return [];
    }
}

in composer.json I’ve added the autoloader:

  "autoload": {
    "psr-4": {
      "App\\": "./../my-parent-theme/app/",
      "ChildApp\\": "app/",
    }
  },

I’ve read something on changing the composers in config/view.php. But this array is removed a few version ago.

Should I also change it somewhere else?

This topic was automatically closed after 42 days. New replies are no longer allowed.