In voyager admin panel how to solve directory separator issue - laravel

I have created a page in the voyager admin panel, but when I tried to retrieve in view the path of the image is like
http://localhost:8000/storage/pages\October2019\eltiRUSN1BArKdXi4uyl.png
you noticed that the first forward slash and then next backward slash, so that's why an image is not displaying in view.
I used this code to print an image.
<div class="header_bg" style="background-image: url('{{ url("storage/$page_data->image") }}');"></div>

Instead of creating a url with url(), maybe you could use Laravel File Storage helpers, like Storage::get('file.jpg');. I believe these work in blade, so in your case, it would be:
<div class="header_bg" style="background-image: url('{{ Storage::get($page_data->image) }}');"></div>

The answer is, this image is set by voyage admin so I have use voyager language.
<div class="header_bg" style="background-image: url('{{Voyager::image($page_data->image)}}');"></div>
to the print image which set from voyager in blade view use this syntax
{{Voyager::image($page_data->image)}}

Related

ck editor content does not displaying as html in frontend

My website is in Laravel. I am makeing about-us page in ckeditor on the Admin side.On the admin end, it works fine. I save the content json_encoded in DB. Issue is that when i want to display it on the front end side it displays the content as string . Have a look at result
what i am doing in blade.php is here
Your current output is escaped(safe-printed) by default, try printing the content by using:
#if (isset($about?->about))
{!! json_decode($about->about) !!}
#endif
Read more: Laravel Docs: Displaying Unescaped Data

Pass image in yield section in laravel

For the <title> I've followed this SO answer This is working perfectly for part but the image is not working
Laravel dynamic page title in navbar-brand
But, Here when I try to make an image dynamic instead of title it's giving me a text instead of an image.
For instance,
header.blade.php
#yield('image')
In another blade, I called image as in section
#section('image', '<img src="http://localhost/appname/public/front/images/heading.png">')
Every page has a dynamic logo so I want to put logo dynamic the same like we're doing in the title.
But the result I'm getting is
<img src="http://localhost/appname/public/front/images/heading.png">
You can do like this
#section('image')
<img src="http://localhost/appname/public/front/images/heading.png">
#endsection

php preg_match value within multiple div

I want to extract the version number of a webserver. the version number is showed on the admin login page.
i tried this:
$content = file_get_contents('URL/login.jsp');
preg_match("/<div class=\"product-version\".*div>/", $content);
echo "content: $content";
It does show the version number but also a large part of the rest of the page.
part of the page i want to have preg_match look in:
<div class="product-logo" style="background-image:url(images/product/icon-system-admin.png)">
<div class="product-version">10.3</div>
</div>
</h2>
Is this possible? or to edit the preg_match to just use the 4 characters after product-version is found?
#Toto that solved it, thanks!
Next thing is to get this working for a bunch of urls.
Want to have the script read urlcustomers.txt in the same directory and show all the version of the webserver for each customer in a table.

Voyager navbar padding problem when override

Problem:
When I override my voyager view using a custom controller. I am getting a padding problem at the top:
problem
Desired output
This is how it should be:
output
My code
browse.blade.php
#extends('voyager::master')
#section('content')
#foreach($exploitants as $exploitant)
{{ $exploitant->exp_nom }}<br>
#endforeach
#endsection>
Don't use <br> inside a loop. It might the one causing the problem. Every browser interpret <br> differently. Try using a fixed px margins instead.
And change #endsection> to #endsection

div background-image in codeigniter use for bootstrap half-slider

I want to use the bootstrap half-slider carousel and I am using codeigniter. In it, it used <div> with background-image instead of <img>, like this
<div class="fill" style="background-image:url('http://placehold.it/1900x1080&text=Slide One');"></div>
In my view used it like this:
<div class="fill" style="background-image:url('../assets/images/image1.jpg')"></div>
However, it doesn't show the image.
Your help will be much appreciated.
Not sure how you have structured your view files, but the reason why the first one is working is probably because it have an absolute path for the image ('http://placehold.it/1900x1080&text=Slide One')
Try using an absolute path to you image in the assets folder.
Instead of:
<div class="fill" style="background-image:url('../assets/images/image1.jpg')"></div>
Try:
<div class="fill" style="background-image:url('<?=base_url('assets/images/image1.jpg')?>')"></div>

Resources