I have found this browser detection library Laravel/Blade.
I have composer installed it in the sage theme directory but don’t know how to then integrate it so I can use the blade languages for it in templates?
Anyone know how it could be done?
I have tried adding this to my app/App.php
but no joy?
What is the error? class not found?
My two cents here: I would use a multilanguage plugin like Polylang and then use the WordPress locale in the theme:
After a few bits and bats I have managed to get it working.
After the composer install just adding this to app/controllers/App.php
use hisorange\BrowserDetect\Parser as Browser;
class App extends Controller
public function browser()
return new Browser;
// other stuff...
This then allows me to call the libraries functions in my blade templates like so…
<p>This is a desktop</p>
@ben Do you think this browser detection library could be included as part of the Sage core so we could use the blade syntax in the layouts/partials?
My two cents here: Feature detection over browser detection (https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Feature_detection)
Yeah I totally get that client-side browser detection is a solid way to go about this in general but what I was more interested in was with how library detects devices:
and its use in blade templates
<p>This is the MOBILE template!</p>
<p>This is the TABLET template!</p>
<link rel="stylesheet" href="tablet.css" title="Reduce the page size, load what the user need">
<p>This is the DESKTOP template!</p>
The blade stuff is only useable in a full Laravel framework but for me and other developers I know this could cut down on quite a lot the output of HTML, CSS and JS when building fully responsive websites. My thought being that server-side detection would be faster and wouldn’t need JS or CSS to be loaded before detection occurs?
Admittedly I’m only testing out this library for fun at the moment but if it proves to be of real use in a production environment, I was just curious as to its potential in Sages core.
I doubt this would be included in Sage core. If you want to use it, Sage 10 is more deeply integrated with Laravel tools and might support it.
This topic was automatically closed after 42 days. New replies are no longer allowed.