I use Laravel 5 with internationalization. Within the array where I store my key => values of all the languages used in the site I would like to add some html for styling the text:
lang_de.php
'error_message' => '<b>This is </b><br>a custom error<span style="color:red; font-weight: bold">message</span>',
This does not seem working for me. Any ideas what is wrong?
In my blade file I load it like this:
{!! trans('site.error_message') !!}
Thank you
Related
I have 3 views:
post/index.blade.php
post/container.blade.php
layouts/app.blade.php
Index view #expands('layout.app') and also #include('container'). The Idea behind the container is to use the same structure to show posts in different views. But the thing is that container.blade.php is not going to be 100% the same on each view. So I thought maybe I can add an #yield('append') on the container.blade.php so that way I could add more on that post container, using #section(). Like this:
inside the index.blade.php
#extends('layouts.app')
#section('content')
#include('post.container')
#section('append')
<p>This is not being outputted correctly.</p>
#endsection
#endsection
This #section('append') belongs to, or actually matches the #yield('append') on the container.blade.php. The question is how can this be done? How to add #section('') that should belong to #include() files in this case container.blade.php?
You can pass data to the #Include
#php $data=[
'title' => "test title",
'description' => ""
] #endphp
#extends('layouts.app')
#section('content')
#include('post.container', $data)
#endsection
Good afternoon!
I am working on a project that has displaying images of the national parks. I have called the National Parks api and get back an array of all the national parks in the database. But I am trying to display the image using the URL provided that is currently embedded in the object in an array of objects marked 'images'.
images-array
This is my code in Vue.js:
<template>
<ul class="list">
<li v-for="park in parks" :key="park.parkCode" >
<img :src="park.images[0].url"/>
<h4>{{park.name}}</h4>
</li>
</ul>
</template>
But every time I run it, I get this error...
Error in render: "TypeError: Cannot read property 'url' of undefined"
I know it is probably something stupid simple, but my brain can't seem to figure it out.
Thank you in advance!
You should check the response.
If park object includes images like
{ ..., "images" : ['image.png','image2.png], ...}
you should try park.images[0]
if it looks like
{ ..., "images" : [{'url':'image.png'},{'url':'image2.png'}], ...}
it should be ok.
I'm using voyager in a laravel 7 shopping app for the description of all products.
I want to output the field for the description of the product
#section('description', {!! $item->description !!} )
and
for the facebook share = og:description" content="{!! $item->description !!}">
When I use {!! $item->description !!} in the body, no problem. But in the tag the output always read the p tag and all style form the description.
The weird thing is it's working find on localhost but not on the server. I tried various combination of solution with the same result. I feel there's a quick or maybe it's just not possible?
try html_entity_decode() ref link https://www.php.net/manual/en/function.html-entity-decode.php
{!! $item->description !!}
to
{!! html_entity_decode($item->description) !!} // it will render html
If you are using laravel 7/8 you can create a blade component then you can simple call
<x-editor :content="$description></x-editor>
check out this laravel docs
try this:
{{strip_tags(trim($item->description)}}
I have already seen a few different approaches for storing
textarea and checkbox and then showing them on edit view and show view...
but I am still not satisfied and would like to hear from You, how do you handle the unchecked checkbox and
especially the textarea security on show and edit with some wysiwyg plugin like ckeditor or tinymce?
For example for checkboxes I am using this setter;
public function setActiveAttribute($value): void
{
$this->attributes['active'] = $value ? 1 : 0;
}
Is this the best way to do it?
And for textarea on submit I allow everything and then on edit view I show it like this:
{!! Form::textarea($key, htmlentities($value), ['class' => 'form-control ckeditor-field']) !!}
and on show view I'm using a Purifier (link below) and I show it like this
{!! \Purifier::clean($value) !!}
So I just wanted to know what are the best practices? Is this fine what I'm doing?
https://github.com/mewebstudio/Purifier
I am creating documentation for my blade based components in a laravel project and would like to display syntax highlighted blade code snippets as part of the documentation a la something like this:
I have installed graham-campbell/markdown package and I try use it inside a .blade.php file as follows:
(Do not mind the escape character)
However, the output I get is as follows:
You can wrap the Blade in a #verbatim directive and use Highlight JS with a style you like
<p>You can use the laravel code template like this</p>
#markdown
```php
#verbatim
#include('components.inputs.text', [
'name' => 'input_name',
'label' => 'testing',
])
#endverbatim
```
#endmarkdown
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.10/styles/a11y-dark.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.10/highlight.min.js"></script>
<script>
hljs.initHighlightingOnLoad();
</script>
Result
Hope this helps