caffeinated / themes Goto Github PK
View Code? Open in Web Editor NEW:art: Laravel Themes package with support for the Caffeinated Modules package.
Home Page: https://caffeinatedpackages.com
License: MIT License
:art: Laravel Themes package with support for the Caffeinated Modules package.
Home Page: https://caffeinatedpackages.com
License: MIT License
This code does not work.
Module front controller
Theme::setLayout('catalog::modules.catalog.layout');
so, too,
Theme::setLayout('modules.catalog.layout');
Hi there,
My components are just being rendered as text on my page:
@component_pageheader('My Awesome Page Header')
I am using the default setup as pr. described in the docs:
\Component::register('pageheader', function($title) {
return "<h1 class=\"page-header\">{$title}</h1>";
});
In my view:
@component_pageheader('My Awesome Page Header')
The components.php file is at the root of my directory, in this case its called "bootstrap". Am I missing something here ?
Hello,
I can't use this module https://github.com/caffeinated/modules
Module is return null value when use Theme::view, are you have solution?
Thank you
When I tried to upgrade my app to L5.2 following this document, it failed on the first step (composer update) because Laravel 5.2 changed some dependencies with newer versions while it seems this module is not compatible with those.
Problem 1
- Conclusion: remove laravel/framework v5.2.5
- Conclusion: don't install laravel/framework v5.2.5
- caffeinated/themes v2.0 requires illuminate/config 5.1.* -> satisfiable by illuminate/config[v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22, v5.1.25,v5.1.6, v5.1.8].
- caffeinated/themes v2.0.1 requires illuminate/config 5.1.* -> satisfiableby illuminate/config[v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22, v5.1.25, v5.1.6, v5.1.8].
- don't install illuminate/config v5.1.1|don't install laravel/framework v5.2.5
- don't install illuminate/config v5.1.13|don't install laravel/framework v5.2.5
- don't install illuminate/config v5.1.16|don't install laravel/framework v5.2.5
- don't install illuminate/config v5.1.2|don't install laravel/framework v5.2.5
- don't install illuminate/config v5.1.20|don't install laravel/framework v5.2.5
- don't install illuminate/config v5.1.22|don't install laravel/framework v5.2.5
- don't install illuminate/config v5.1.25|don't install laravel/framework v5.2.5
- don't install illuminate/config v5.1.6|don't install laravel/framework v5.2.5
- don't install illuminate/config v5.1.8|don't install laravel/framework v5.2.5
- Installation request for laravel/framework == 5.2.5.0 -> satisfiable by laravel/framework[v5.2.5].
- Installation request for caffeinated/themes ~2.0 -> satisfiable by caffeinated/themes[v2.0, v2.0.1].
I'm not sure should I upgrade to 5.2 anyway but since my project is at the very early beginning I thought I could upgrade before having to refactor any large portion of code (if I decide to upgrade later).
Hello @kaidesu ,
I have your module plugin with your theme plugin.
Within my core module I try to do this: return \Theme::view('modules.core.index');
But it always show my view from modules and not from theme. In theme I have defined the view within public/themes/modules/core/index
Can u help me ?
Hi,
theme package works fine with options from the config file, where I have left default option for paths: paths.absolute => public_path('themes')
. And it works great, I have created default template in the public/themes
directory, added template files etc...
Now, for some part of my application, I need to use different theme directory. Let's say I have "system themes" and "user themes". I noticed you have two methods setPath($path)
and setActive($theme)
. Both are chainable and I should use it like this (in my controller):
private $theme;
public function __construct(\Caffeinated\Themes\Themes $theme)
{
parent::__construct();
$this->theme = $theme;
}
public function getRegister()
{
return $this->theme->setPath(public_path('clients'))->setActive('defaults')->view('users.account.register');
}
I've tried adding this part $this->theme->setPath(public_path('clients'))->setActive('defaults')
to the constructor, but I get the same error View [] not found.
The weird thing is if I dd getPath():
public function getRegister()
{
dd($this->theme->getPath());
return $this->theme->setPath(public_path('clients'))->setActive('defaults')->view('users.account.register');
}
I get the correct path "/home/vagrant/www/project/public/clients"
.
But, when I try this:
public function getPath()
{
dd($this->path);
return $this->path ?: $this->config->get('themes.paths.absolute');
}
I get null
. I'm struggling with this for couple days, and I would appreciate any help you can provide. Probably I don't see something so obvious :)
laravel 5.2
Caffeinated\Themes\Themes.php online 378
Solution : laravel/framework#11479
change url() to url('/')
hi, please update it to laravel 5.2 .
view()->composer() and Theme::view()->composer() aren't working.
I've created a great structure to choose and render my themes. Within a middleware, i call Theme::setActive() and Theme::setLayout(); based on the actual namespace.
It's working fine but i found something that looks like a bug:
After setting the default active theme and the default layout name through the middleware , i want to let some of my controller methods to be able to modify which theme to render. So i call Theme::setActive() again from my controller.
The problem is: only the active theme is being selected, but the name of the active layout is retrieving the old theme.
Example:
// Middleware
Theme::setActive('landing');
Theme::setLayout('layouts.default');
// Controller
Theme::setActive('other');
when i call $theme_layout from my view, i get "landing::layouts.default" instead of "other::layouts.default".
I know that i can call Theme::setLayout() again from my controller to resolve this, but i don't think this will be a good practice. Maybe is better if we can perform some changes to the method "getLayout()" of the "Theme" class, to check again for the active layout, before setting the $theme_layout.
Hi, Everything is working fine but theme assets can't load it showing right url
http://domain.com/themes/admin/assets/bootstrap/css/bootstrap.min.css
in header but when i click on it and open it i got not found error.
Please help me
I can't seem to get the Theme::setLayout($layout)
to work
Theme::setLayout
always returns false, so I cant do @extend($theme_layout)
File structure:
/laravel/public/themes/standard/views/layouts/default.blade.php
Inside Controller.php
public function __construct() {
$theme = config('themes.active');
\Theme::setActive($theme);
dd(\Theme::setLayout('layouts.default'));
}
I've also tried extend('standard::layouts.default')
and it throws
ErrorException thrown with message "No hint path defined for [standard]. (View: /laravel/app/Modules/Dashboard/Resources/Views/dashboard.blade.php)"
How to Use "Themes" module for sending mail through Mail::send() function?
I have 3 pages
page.blade.php
page2.blade.php
page3.blade.php
in folder laravel\app\Modules\Blog\Resources\Views
master.blade.php in folder laravel\public\themes\bootstrap\views
how include page.blade.php include into to master.blade.php
Hi, guys!
I get this error when publishing vendors:
[League\Flysystem\Exception] Impossible to create the root directory "".
Anyone having the same issue?
Any way to do this?
Actually the cascade-style to finding the desired view file works fine but if I need to load public/themes/active-theme/views/welcome.blade.php
file but not found in theme, I want to load from resources/views/defaultTheme/welcome.blade.php
instead resources/views/welcome.blade.php
Thanks, sorry for my bad english and my ignorance. Greetings.
i have a three modules
how create master.blade.php for all modules
I have to config my themes to have base path as URL, i.e.:
'base' => url( 'public/themes'),
now the generated asset URL when calling Theme::asset() is:
"/http://localhost:8888/laravel/....
any possible solution ?
Thanks.
So we have a project that uses Caffeinated Modules and Themes (great stuff!) with Laravel Spark. I ran into an issue with this package combination that I thought was worth sharing with you.
According to the Themes documentation we put in the controller something like:
Theme::setLayout('layouts.master');
...
return Theme::view('route', $data);
In the blade we put this:
@extends($theme_layout)
But, in Spark we don't have access to all controllers (at least not without getting really under the hood). But this was easy to resolve by putting the Theme::setLayout
line into our AppServiceProvider.php
's boot method, and instead of using $theme_layout
I use this in my blades:
@extends(\Theme::getLayout())
With this all appears to work as expected. Might be worth updating the docs?
Hi, how can i get current theme url for using assets?
Thanks
What about introduce a reserved keyword for @extends, @include, etc. that represents the current theme? So, after you rename the theme, you haven't to replace the name in all views.
An example with a theme named "caffeinated":
// Now
@extends('caffeinated::layout')
@include('caffeinated::layout')
// Proposal
@extends('current::layout')
@include('current::layout')
If you set a theme that doesn't physically exist it will error out.
No hint path defined for [theme]
I didn't see a sanity check in the docs, did I miss it?
Thanks!
Would it be possible to add the ability to share assets between themes but yet still maintain the ability to have assets only for that theme?
Or ... did I miss something again ๐
According to the laravel docs, error pages should sit under resources/views/errors
with the error code as filename.
Where do I place the error pages with this module?
I use abort(404)
in my controllers.
I was wondering if "Theme::setProperty" can be sued without having to set the theme.json file to 777?
How set a layout in a controller ?
Here my controller
namespace App\Modules\Blog\Http\Controllers;
use App\Http\Controllers\Controller;
class BlogController extends Controller
{
public function home()
{
return '111';
exit;
}
}
how take a css , javascript in in folder with module htdocs\laravel\public\themes\bootstrap\assets\css\
please help me!
I want to show a section to have all my theme showing a preview image, I'm doing a @foreach to collect all my themes but if i try to do Theme::asset() just the first preview image is showing in all themes. any idea?
I have installed caffeinated themes (and caffeinated modules) and everything works as it should. However, I can't seem to find the Child/parent inheritance in the documentation. And this is exactly what I'm looking for: a simple theme manager with parent/child inheritance.
Hello,
We are trying to use the themes but we have an issue.
In the controller we call the view with
return Theme::view('pages.auth.login');
And the view has the next code
@extends('layouts.simple')
@section('content')
<div class="body bg-gray">
@include ('includes.errors', array('errors' => $errors))
</div>
@stop
When we call the page, and error appears.
ErrorException in FileViewFinder.php line 140: View [layouts.simple] not found. (View: /home/vagrant/www/Laravel5/web/public/themes/admin/views/pages/auth/login.blade.php)
we have the simple.blade.php in the directory. /home/vagrant/www/Laravel5/web/public/themes/admin/views/layouts/simple.blade.php
Please, can you confirm the we can use the @extends
and @include
Blade methods in a view.
Thanks in advance
Any documentation? :)
Hi,
I'm not sure if the behaviour that I'm watching is what i should expect or is not working properly.
Hi have setted two testing themes. One is a child of the other.
In my test controler i'm doing something like this:
public function about(){
#return view('pages.about');
Theme::setActive('base');
Theme::setLayout('layouts.sidebar');
return Theme::view('pages.about');
}
I also have , in the views folder (in each theme) a template like this:
themes\base\views\pages\about.blade.html
themes\other\views\pages\about.blade.html
When accesing the view using the base theme (Theme::setActive('base')) i got what expected.
If i change the theme:
> Theme::setActive('other')
I got what expected (the other theme template)
If a remove the "other" theme template, I got the fallback template (from base theme).
Till now , everything is ok.
The problem comes with the assets.
I get the parent theme asset, not diference if I'm on using the parent or child theme.
I get the CSS if the file exists in the current theme.
So, if i have "custom.css" defined in my parenttheme and not in my child theme. I do not get it.
What I'm expecting is that, if i have the "custom.css" in my theme (child) a can get it. And if the file is not present in the child theme, i got the fallback to the parent theme.
Tha is what is happening with views...
I'm quite sure I'm doing something wrong...
Any help will be appreciate.
Thanks a lot for your time.
Hi,
I can't require with Laravel 5.4.9, I got this result :
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for caffeinated/themes ^3.0 -> satisfiable by caffeinated/themes[v3.0].
- Conclusion: remove laravel/framework v5.4.9
- Conclusion: don't install laravel/framework v5.4.9
- caffeinated/themes v3.0 requires illuminate/view 5.3.* -> satisfiable by illuminate/view[v5.3.0, v5.3.16, v5.3.23, v5.3.4].
- don't install illuminate/view v5.3.0|don't install laravel/framework v5.4.9
- don't install illuminate/view v5.3.16|don't install laravel/framework v5.4.9
- don't install illuminate/view v5.3.23|don't install laravel/framework v5.4.9
- don't install illuminate/view v5.3.4|don't install laravel/framework v5.4.9
- Installation request for laravel/framework (locked at v5.4.9, required as 5.4.*) -> satisfiable by laravel/framework[v5.4.9].
Installation failed, reverting ./composer.json to its original content.
Hi, thanks for this package. It helps me a lot. I'm not speak english.
Env: L5.4, PHP 5.6, caffeinated/themes:^3.0
When developing I can use Theme::asset
to get css and js file, but in production I often used .version() when build asset.
Theme::asset('css/app.css');
// http://localhost/themes/theme-name/assets/css/app.css
My workaround, add a helper function:
if (!function_exists('theme_assets')) {
/**
* @param string $asset
*
* @throws \Exception
*
* @return \Illuminate\Support\HtmlString
*/
function theme_assets($asset)
{
return mix(preg_replace('!/{2,}!', '/', sprintf(
'/%s/%s/assets/%s',
config('themes.paths.base'),
Theme::getActive(),
$asset
)));
}
}
It's would be nice to get asset also version asset with Theme::asset
.
Any support for this? Thanks.
edit note: add caffeinated/themes version
Hi,
does anyone use Laracast Utilities package with themes?
By default in resources folder there is lang folder.. How to use lang folder in themes...where to keep this folder in theme directory structure and how to access those lang files...is there any way to do this?
If theme name and module name is simple , and module view file and theme view file is simple then load module view files
It seems Theme::view()
is not finding the view inside of a themes folder even if it exists. Folder structure is as so: public/themes/default/views/welcome.blade.php
. The active theme is set as default, and the $views
array outputs:
'theme' => string 'default::welcome' (length=16)
'parent' => string 'default::welcome' (length=16)
'module' => null
'base' => string 'welcome' (length=7)
$this->viewFactory->exists($view)
returns false on all accounts until base, where it finds it.
No idea if this is a bug, or if I'm just missing something.
Hi, i'd like to customize my views directory to use a subfolder when in the theme was not found the view, so if the view doesn't exist search in views/store folder.
Is there a way to do this?
Regards
I used version 3. It makes redirect to view in the controller.
return Theme::view('frontend.index', compact( 'var1', 'var2', ))->render();
But how to make redirect to view with version v4.0.2?
Thanks @kaidesu
Hi. First, thank you for this awesome package.
But all others packages use default View facade. Why not to override View facade to use Theme facade instead?
Or how can I do?
Thanks!
InvalidArgumentException in FileViewFinder.php line 140: View [] not found.
in FileViewFinder.php line 140
at FileViewFinder->findInPaths('', array(false)) in FileViewFinder.php line 77
at FileViewFinder->find('') in Factory.php line 145
at Factory->make(null, array('theme_layout' => 'bootstrap::admin.app')) in Themes.php line 228
at Themes->renderView(null, array()) in Themes.php line 210
Would be nice to have commands to generate theme folder structures along with any necessary files (theme.json)
Hi @kaidesu,
how can I extend a dynamic view ? For example:
In my CMS I have a module "Core". This module integrate for example the view "core.index" and extend the theme "bootstrap::master".
How can I make "bootstrap" dynamically based on the selected customer layout in backend ?
Greetings.
Can we have a simple starter kit for both twig and blade to understand how the whole setup needs to be done?
I've noticed that compacting variables twice is causing the second set to be skipped.
If I don't set the theme method on the view I can compact variables at both the repository and controller levels.
This really isn't an issue so to say but I like trying to keep view variables away from the model/repository layers. (I prefer a strict MVC old school approach which ends up with a slightly fatter controller and a slimmer model.)
Here's what I got:
view:
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="{{ trans('kotoba::general.command.close') }}"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">
{{ $modal_title }}
</h4>
</div>
<div class="modal-body">
<p>
{{ $modal_body }}
</p>
</div>
controller:
return Theme::View('menus::menus.edit',
$this->menu_repo->edit($id));
repository:
$menu = $this->model->find($id);
$lang = Session::get('locale');
$modal_title = trans('kotoba::general.command.delete');
$modal_body = trans('kotoba::general.ask.delete');
$modal_route = 'admin.menus.destroy';
$modal_id = $id;
$model = '$menu';
return compact(
'lang',
'menu',
'modal_title',
'modal_body',
'modal_route',
'modal_id',
'model'
);
The issue I have with this is that I'm pushing view variables down into the Model/Repository layer.
controller:
$modal_title = trans('kotoba::general.command.delete');
$modal_body = trans('kotoba::general.ask.delete');
$modal_route = 'admin.menus.destroy';
$modal_id = $id;
$model = '$menu';
return Theme::View('menus::menus.edit',
$this->menu_repo->edit($id),
compact(
'modal_title',
'modal_body',
'modal_route',
'modal_id',
'model'
));
repository:
$menu = $this->model->find($id);
$lang = Session::get('locale');
return compact('menu', 'lang');
Just wondering what your thoughts are on this ๐
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.