Skip to content

Anyone get this working with view composers for each theme? (overlapping view names) #128

@michaelsoutherton

Description

@michaelsoutherton

We're trying to use multiple view composers along with this package to help clean up our controllers. The problem is that we can't figure out how to conditionally load only the view composer we want when some of our view names are exactly the same.

Here's a couple different homepages for platforms that each need very different data:

/resources/themes/platform-one-theme/pages/index.blade.php
/resources/themes/platform-two-theme/pages/index.blade.php

The view name for each of those homepages is 'pages.index'

So in our ComposerServiceProvider.php, we have:

View::composer(['pages.index'], 'App\Http\ViewComposers\Platform-One-ViewComposer');
View::composer(['pages.index'], 'App\Http\ViewComposers\Platform-Two-ViewComposer');

...and our problem is that both of those will both be loaded. How can we conditionally apply only the view composer for our theme? It looks like we don't have access to request within ComposerServiceProvider, and it doesn't seem to work with middleware.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions