Laravel, Revolution Slider - Error when trying to embed - laravel

I am trying to add Revolution Slider to my Laravel instance (per instructions from its creators), and so far, I am getting the following error.
Facade\Ignition\Exceptions\ViewException Argument 2 passed to
Illuminate\Translation\Translator::get() must be of the type array,
string given, called in
/home/sasha/Documents/OffProjects/VetPartnersPrintPortal/project/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php
on line 878 (View:
/home/sasha/Documents/OffProjects/VetPartnersPrintPortal/project/resources/views/home/index.blade.php)
The setup is quite simple (basic instructions).
class HomeController extends Controller
{
/**
* Display a listing of the resource.
*
* #return \Illuminate\Http\Response
*/
public function index()
{
return view('home/index');
}
}
View
<?php
include(app_path() . '/Slider/embed.php');
?>
<!DOCTYPE html>
<html>
<head>
<title>Example of Revslider embedding</title>
<?php RevSliderEmbedder::headIncludes(); ?>
</head>
<body>
<!-- change "example" in the code below to match your slider's alias -->
<?php
RevSliderEmbedder::putRevSlider('test');
?>
</body>
</html>
Does anyone have any idea what's going on here?

Revolution Slider is a Wordpress plugin, pretty sure it won't work with Laravel. If you click the revolution-slider tag on your question, you'll see that all other questions also have wordpress tag attached to them. I would recommend using sliders designed for Laravel, like this one or this one.

Pavel Lint was wrong. The wordpress and all yours plugin was developed in php, js and mysql. And the laravel is a framework for php...
Why the plugins wont work... I use the same revolution sliver in my projects and this work fine. Is this line of js script just include the "#" before param1, title and param2 like this #{{param1}} | .
This is solve the problem. Enjoy!

Related

Have a problem when used route to controller with variable

I used Laravel route as follow.
Route::get('report/centos7/{id}', 'HomeController#centos7');
And then in Controller, I used this code to return View.
\View::make('report/centos7/', $id);
An error occurred as follow.
InvalidArgumentException in FileViewFinder.php line 137:
View [report.centos7.] not found.
I called the URL like this "mysite/laravelproject/public/report/centos7/result_target2"
I using Laravel 5.2
First time I used this code in Controller
return \View::make('report/centos7/'. $id);
But, the CSS and JS is not loaded. I think because of "."
That is why I changed from "." to ","
Route
Route::get('report/centos7/{id}', 'HomeController#centos7');
HomeController
public function centos7($id)
{
//
return \View::make('report/centos7', $id);
}
I had dynamically added "blade.php" into folder view/report/centos7/xxxx.blade.php
I created a new page to list all files in that folder and link each of the files to show the report in blade format.
I hope Laravel route to Controller is can help to access my report in blade format
Thanks for help. I'm a newbie in programming language
Update
I removed {id} in route as follow
Route::get('report/centos7/{id}', 'HomeController#centos7');
To
Route::get('report/centos7/', 'HomeController#centos7');
And removed id in HomeController as well
It works. But, I still want to send $id from Route to HomeController
When I do that I don't know why CSS is not loaded in my blade php.
Please help.
Update (Sovled)
Thank god everyone
If anyone has the same problem as me
I changed my href into the layout as follow and it works.
<link href="{{ URL::asset('theme/vendor/bootstrap/css/bootstrap.min.css') }}" rel="stylesheet">
The main issue is the extra / in your view code:
\View::make('report/centos7/', $id);
If you change it to the following, it should all work correctly:
\View::make('report.centos7', $id);
Make sure that your HTML code is in the resources/views/report/centos7.blade.php file.

How to echo browser locale in laravel 5.2

I want to echo the current set locale in my html tag using blade:
<html lang="{{ $locale }}"></html>
I'm new to Laravel 5 and i was wondering how to accomplish this.
If you are asking for locale set in client's browser, you can use request()->server('HTTP_ACCEPT_LANGUAGE') to get those.
And if you are asking for locale set within your Laravel application, you can get it like this: config()->get('locale')
And if you want to get template name in your Laravel blade, just use like this:
// allow $view_name in views
View::composer('*', function ($view) {
View::share('view_name', $view->getName());
});
On top of what #jszobody just said above, you could also make use of javascript and the jstz package in order to find their locale. Assuming you have jQuery installed, your code could look like the following
<script>
$(function() {
$('html').attr('lang', jstz.determine().locale());
}
</script>

HTML Purifier is breaking SyntaxHighlighter

I'm using the SyntaxHighlighter plugin for CKEditor to insert code into my pages. The plugin uses <pre> tags to contain the code whilst making use of "brush" classes to define the programming language. My problem is that upon submission of the page HTML Purifier is stripping the class attribute from the pre tags, which effectively prevents the syntax highlighting from occurring.
The source code goes from:
<pre class="brush:php;">
<?php echo '<p>Hello World</p>'; ?>
</pre>
to:
<pre>
<?php echo '<p>Hello World</p>'; ?>
</pre>
I'm hoping there is some magical setting to stop HTML Purifier from doing this.
The reason is brush:php is not a valid class name per the HTML4 specification. I guess you could write your own class name validator and override the builtin using http://htmlpurifier.org/docs/enduser-customize.html
But a better solution might be to run the syntax highlighting before you run HTML Purifier!

Using Laravel Blades

i have started working in Laravel, and working with .blade.php templates, but am not able to understand the benefit for using blad.php and also while having a master page, why we put our code in some other pages with #sections and #yeild
like
masterpage.blade.php
<div>
#yeild(section)
</div>
index.balde.php
#section
Hellow world
#endsection
why i need to do it like that? why we can't just put our Text in the same page instead of doing this method, what are the benefits if we code like that.
There are lot of benefits in using Blade with Laravel, please read it here
http://culttt.com/2013/09/02/using-blade-laravel-4/
The short answer for you questions is we do not need Blade engine in any project. However, using it brings many benefits.
Simplify script file
Like other templating engine, Blade engine simplify your PHP scripts by some replacement such as :
<?php echo $foo ?> changed to {{ $foo }} (reduce 8 characters)
<?php if ($condition): ?> changed to #if ($condition) (reduce 6 characters)
<?php echo trans('lang.key') ?> changed to #lang('lang.key') (reduce 11 characters)
...
Try to calculate how many character you can save if using Blade engine in your script.
Another thing I love in Blade engine is that we can create our own custom control structure. If you are tired of typing $var->format('Y-m-d H:i:s') every time you need to output a DateTime object. You can create custom matcher with Blade
Blade::extend(function($view, $compiler)
{
$pattern = $compiler->createMatcher('datetime');
return preg_replace($pattern, '$1<?php echo $2->format('m/d/Y H:i'); ?>', $view);
});
Now, all you need to to is replace $var->format('Y-m-d H:i:s') by #datetime($var).
View inheritant
By supporting section, Blade engine help developer organize their view file in a hierarchical and logical way. Imagine that you have HTML code for some pages of your website: a home page, a category archive page and a single post page. All there page have the same header, footer and sidebar. If we " put our Text in the same page instead of doing this method", the content of there files have a large amount of similarities, which cause any changes in the future very painful.
With Blade sections, create a simple master layout file like that
<html>
<body>
#section('sidebar')
<!-- this is header code -->
#show
#section('sidebar')
<!-- this is sidebar code -->
#show
<div class="container">
#yield('content')
</div>
#section('footer')
<!-- this is footer code -->
#show
</body>
</html>
In the view file for each page, you only need to take care of the main content of the page, instead of other parts.

How to fetch() sub-parts of a Smarty template

Background Smarty is a templating engine that separates the presentation layer from the logic layer of web applications. It is well-suited for the Model-View-Control approach to developing web applications. The View can be represented by Smarty templates, which contain only HTML and Smarty tags. The Control can be implemented by PHP files that serve the appropriate views based on the logic contained within them via PHP code. The View is instantiated by displaying the templates via the display() command. Alternatively, a template can be read in as a variable without displaying it via the fetch() command. The file name of the template is the argument to both these commands.
Issue The fetch() command can read an entire template. In order to read parts/sub-parts of a template, each of these parts would normally needed to be stored in a separate file with its own name that can be the argument to the command. This creates needless files.
Question Is it possible to fetch only parts of a Smarty template by somehow marking sections of the template?
Case example Below I present a sample template file with Smarty and HTML tags, as well as the corresponding controller file with PHP code.
Template file (index.tpl)
<html>
<body>
<div id="sec1">
First section
</div>
<div id="sec2">
Second section
</div>
</body>
</html>
Controller file (index.php)
<?php
$smarty = new Smarty;
$template = $smarty->fetch("index.tpl");
?>
In the example above, the $template variable would contain the full output from the template page. Below is a dump of its contents from the example.
$template => string(255)
"<html><body>
<div id="sec1">First section</div>
<div id="sec2">Second section</div>
</body></html>"
However, suppose I wish to read in the code from each of the DIV containers separately, and store them into separate variables, how could I achieve this? For instance, suppose I have a magical function called fetch_sub(). Here's my expectations of using it.
<?php
$smarty = new Smarty;
$div1 = $smarty->fetch_sub("index.tpl", "sec1");
$div2 = $smarty->fetch_sub("index.tpl", "sec2");
?>
Then $div1, etc would contain only the relevant sub-part, instead of the whole template.
Other info I am not a beginner with Smarty and have a fairly good handle on basic concepts, as well as some of Smarty's advanced concepts. Following is my attempts so far at conceptualizing the problem and getting to a solution. My initial rough idea is to demarcate the template into sections using {capture}, and then somehow reference each of these sections. I present an outline example of the idea below.
{capture name=sec1}
<div id="sec1">
First section
</div>
{/capture}
. . .
Smarty (as of Smarty 3.1) has no built-in feature to allow you achieving your goal. I had proposed something similar in 2011, but we haven't come around to implementing it.
Maybe you can have the generated HTML parsed to DOM and help yourself with xpath, or something like that?
You can try this:
sec1.tpl
<div id="sec1">First section</div>
sec2.tpl
<div id="sec2">Second section</div>
index.tpl
<html><body>
{include file="sec1.tpl"}
{include file="sec2.tpl"}
</body></html>
And then You can fetch parts by invoking:
$smarty = new Smarty;
$div1 = $smarty->fetch("sec1.tpl");
$div2 = $smarty->fetch("sec2.tpl");

Resources