Open BrookeDot opened 1 year ago
hybrid-core version 6 is/has been broken down into separate components rather than a whole system. Personally 5.x works fine.. I don't think is necessary to move to 6..
hybrid-core version 6 is/has been broken down into separate components rather than a whole system.
Yep, I used Hybrid for a long time, (since 1.5 😬 ) this is my first time trying to use 6.0 here are the packages I have installed:
$ composer show
composer/installers v1.12.0 A multi-framework Composer library installer
themehybrid/hybrid-attr 1.0.0 Hybrid Attr provides devs a system for adding filterable attributes. This is sort of like `body_class()`, `post_class()`, and `comment_class()`...
themehybrid/hybrid-contracts 1.0.0 Contracts for the Hybrid Core framework.
themehybrid/hybrid-core 6.0.0 Hybrid Core: A framework for developing modern WordPress plugins and themes.
themehybrid/hybrid-template 1.0.0 Template helper functions.
themehybrid/hybrid-template-hierarchy 1.0.0 Smarter and more flexible template hierarchy for WordPress.
themehybrid/hybrid-template-manager 1.0.0 Custom template registration system for WordPress.
themehybrid/hybrid-theme 1.0.1 A collection of helper functions and filters to aid in theme development.
themehybrid/hybrid-tools 1.0.0 Helper tools and functions.
themehybrid/hybrid-view 1.0.0 System for setting up and rendering theme template files. Views are a bit like a suped-up version of the core WordPress get_template_part() fun...
Personally 5.x works fine.. I don't think is necessary to move to 6..
My main reason to moving is for PHP 8+ compatibility and because the module approach in theory means fewer files since I won't need breadcrumbs or get_the_image for my use case.
so the view should be
$engine = \Hybrid\App::resolve( 'view/engine' );
$engine->display( 'header' );
$engine->display( 'footer' );
or you can use helper function below.
\Hybrid\View\display();
or you can use helper function below. \Hybrid\View\display();
Yeah the theme is based on Mystic so is using:
// // Load header/* template.
\Hybrid\View\display( 'header', Hybrid\Template\hierarchy() );
// // Load content/* template.
\Hybrid\View\display( 'content', Hybrid\Template\hierarchy() );
// // Load footer/* template.
\Hybrid\View\display( 'footer', Hybrid\Template\hierarchy() );
haha, I was about to mention Mystic just now, but looks like you found what you need!
The problem is when upgrading Mystic from Hybrid 5.x to 6.x there is the fatal error. I'm sure it's either a bug in this component, or I'm doing the upgrade wrong. So trying to figure out which it is.
what does your bootstrap-app.php look like, did you add the view provider!
$slug->provider( 'Hybrid\View\Provider::class' );
even if you have those components install through composer, you need to add those specific components as a provider. so soemthing like this below so it becomes available to use!
/**
* Create a new framework instance
*x
* This will create an instance of the framework allowing you to initialize the theme.
*/
$initiator = new \Hybrid\Core\Application();
/**
* Register default providers.
*/
$initiator->provider( Hybrid\Template\Hierarchy\Provider::class );
$initiator->provider( Hybrid\Teplate\Manager\Provider::class );
$initiator->provider( Hybrid\View\Provider::class );
/**
* Register custom providers for the theme.
*/
$initiator->provider( Initiator\Menu\Provider::class );
$initiator->provider( Initiator\Sidebar\Provider::class );
/**
* Create an action hook for child themes.
*/
do_action( 'initiator/child/theme', $initiator );
/**
* Boot the Framework
*/
$initiator->boot();
the hierarchy provider works best with view together. then by adding a filter
add_filter( 'hybrid/template/path', function() {
return 'public/views';
} );
without this filter, i think it defaults to resources/view
did you ever get this resolved!
You'll get that error when the Engine
object is not being resolved. This sounds like a case of the view service provider not having been added as @benlumia007 said here: https://github.com/themehybrid/hybrid-view/issues/4#issuecomment-1347811915
@BrookeDot
If you could share your code, will be able to help you better.
But here are is the relevant bit of code you need in your theme...
/app/bootstrap-app.php
$mythic->register( \Hybrid\Template\Hierarchy\Provider::class );
$mythic->register( \Hybrid\Template\Manager\Provider::class );
$mythic->register( \Hybrid\Theme\Provider::class );
$mythic->register( \Hybrid\View\Provider::class );
/app/Providers/AppServiceProvider.php
use Hybrid\View\Contracts\Engine as EngineContract;
use Hybrid\View\Contracts\View as ViewContract;
and
...
public function register() {
...
// Create aliases for the view and engine.
$this->app->alias( ViewContract::class, 'view' );
$this->app->alias( EngineContract::class, 'view/engine' );
...
/composer.json
...
"require": {
...
"themehybrid/hybrid-theme": "^1.0",
"themehybrid/hybrid-template-manager": "^1.0",
"themehybrid/hybrid-template-hierarchy": "^1.0",
"themehybrid/hybrid-template": "^1.0",
"themehybrid/hybrid-view": "^1.0",
...
},
...
Did anyone get this to work?
@saas786 wote:
use Hybrid\View\Contracts\Engine as EngineContract; use Hybrid\View\Contracts\View as ViewContract;
that does not work for me, tells undefined namespace 'Contracts'
Anyone?
@redactuk Is your code in a public repository? If so, please share the link so I can review it and provide you with accurate feedback.
@redactuk Is your code in a public repository? If so, please share the link so I can review it and provide you with accurate feedback.
No it is not. What I have so far is here: https://github.com/themehybrid/hybrid-view/issues/9 based on your answer above, but clearly what you included above was for hybrid-view 1.x not the latest 2.x
If you want to continue using the legacy view system but with HC v7, refer to the following links:
You don't need the new hybrid-view
v2 for that.
Similarly, if you want to use it with HC v6:
I can try to update both Mythic and Exhale to the latest code, but I think the current code should suffice for your needs.
Here is the latest implementation, and you can also see the prefixing logic applied.
I am attempting to upgrade from Hybird Core 5.x to 6.0 and getting the following error with views:
PHP 8.1 WordPress 6.1
I'm assuming the way a view is called is different for 6.0?