Use Sober controller for custom module

I would like to ask if you know a way to use the controls for modules that are not in the partials folder, for example:

I have a file: theme-name/resources/views/components/banner.blade.php whit this code

@php 
    var_dump($banner_content);
@endphp

then theme-name/app/Controllers/Components/Banner.php
<?php

namespace App\Controllers\Components; 

trait Banner 
{ 
    public function banner_content()
    { 
        return "this is a banner";
    }
}

and then theme-name/app/Controllers/App.php

<?php
namespace App\Controllers;

use Sober\Controller\Controller;

class App extends Controller
{

    use Components\Banner;
}

but i always get this error:
Notice : Undefined variable: banner_content

Does anyone know if there is a way to use controls with this structure? that is to have a custom folder.

Thanks

soberwp/controller matches against the WordPress template hierarchy, not individual blade files. The components mentioned in the documentation only relate to modularizing logic, they do not connect to component blades.

If you want that functionality, you might look at Sage 10, which allows for this through the use of Composers: https://roots.io/working-with-composers-in-sage-10/

Thanks a lot, just waiting sage 10 stable :+1:

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