i try to to show data from database article...the content is contain html tags and long text..
so i want make a read more and convert tag html to html view..
this is my code is run :
{{ HTML::decode($show->content) }}
{{ str_limit($show->content, $limit=100, $end=' ...') }}
i try this :
{{ HTML::decode(str_limit($show->content,$limit=100, $end=' ...')) }}
{{ str_limit(HTML::decode($show->content),$limit=100, $end=' ...') }}
but not show ( blank )
annyone can help me to fix it??
thank u b4
Is {{ $show->content }} returning any data to format?
Is your template is .blade?
Maybe it placed somewhere in HTML, where it is not visible?
Try to use this construction with some predefined string to find out if it works. Here is working example:
{{ str_limit('Some big text', $limit = 5, $end='...') }}
Related
UPDATE
refering to Oleg Butuzov answer i can solve my first problem with :
{{ $paginator := .Paginate (where .Site.RegularPages ".Params.yt" ">" "") 1 }}
but i have new problem that its listing all post on content folder Hugo that contain param "yt", and then i solve my problem from Official Hugo Discusion here https://discourse.gohugo.io/t/complex-where-filter-using-and-or-not/5758/3 from #bep reply.
and here.. how to filtering where HUGO with two condition :
{{ $paginator := .Paginate (where (where .Site.RegularPages ".Params.yt" ">" "") ".Params.type" "post") 1 }}
i update and clearing this Question because its realy hard to find about this Hugo Question and i hope its can solve your problem too.. thx :)
======= ORIGINAL QUESTION ======
how to filter "where" for Variable $Paginator to only listing post that contain Custom param "yt"?
{{ $paginator := .Paginate (where .Site.RegularPages "Type" "post") 2 }}
{{ range $paginator.Pages }}
{{ .Params.yt }}
{{ end }}
{{ template "_internal/pagination.html" . }}
my Hugo Template structure :
conten/Post/
---- post1.md
---- post2.md
theme/layout/post/gameplay.html
then
post1.md
---
Title: Title 1
type: post
yt: ytchannelid
---
post2.md
---
Title: Tile 2
type: post
---
thanks before :)
You can use combination of .Params and comparison operators.
So, for example, I want to show the only projects with forks on the project page.
{{ define "content" }}
{{ range first 6 (where .Paginator.Pages ".Params.Forks" ">" "") }}
<div class="inner">
<pre>[{{.Params.Forks}}]</pre>
<hr>
</div>
{{ end }}
{{ end }}
see more at where manual page.
I have a table with many columns and some of those columns have spaces in their names (i.e. 'Provider First Name'). I know the syntax to use these in Blade helpers and am using this in other parts of my app: {{$provider->{'Provider First Name'} }}. This works fine in other parts.
I have the following in my ProviderController:
public function show($id)
{
$provider = NPIData::where('NPI', $id)->first();
$providers = NPIData::all();
return view ('profiles.provider', compact('provider', 'providers'));
}
I have brought in the NPIData Model to the controller.
I have the following in my provide.blade.php file:
#extends('layouts.profiles')
#section('content')
<div>
{{ $provider->NPI }}
{{$provider->{'Provider First Name'} }}
</div>
#endsection
Oddly, the NPI will pull in, but the 'Provider First Name' does not. I have tried many other columns with spaces and none of them work. I even copied and pasted from other parts of my app where the syntax to pull these in works and it does not work here.
Instead of:
{{$provider->{'Provider First Name'} }}
Try this:
#php
$providerFirstName = $provider->{'Provider First Name'};
#endphp
{{ $providerFirstName }}
UPDATE
If not you can always go with array access:
{{ $provider['Provider First Name'] }}
I am using Laravel 5.7 I am having a variable stored in the database and would like to have it evaluated by Blade before rendering.
Database
Field: name, Value: {{ $organisername }}
I am pulling out this piece of data into a Blade template like this.
<h4>1. Registration</h4>
<br />
{{ $job->organisername }}
Chrome then displays {{ $organisername }} instead of evaluating {{ $organisername }}.
1. Registration
{{ $organisername }}
If I type {{ $organisername }} into the Blade template, it gets evaluated to John when the page is rendered..
1. Registration
John
I'm using TinyMCE to input {{ $organisername }} into the textarea, and it gets saved into a Database, if that helps.
If by evaluate you mean to do some consistency for your variable, know that this Blade echo statement "{{ }}" already does that with htmlspecialchars, like explained in the docs:
https://laravel.com/docs/5.7/blade#displaying-data
Blade templates are compiled down into PHP before they evaluate. Essentially, blade compiles:
{{ $job->organisername }}
Into
<?php echo e($job->organisername); ?>
Once you understand this and how PHP evaluates variables, you should be able to understand why you can't set Blade constructs in the database and have them evaluated when it's printed.
It's basically the same as echoing a literal string:
<?php echo '{{ $organisiername }}'; ?>
You wouldn't want Blade or PHP evaluating any expression they come across as they print, that would potentially be very insecure.
I have database, with columns image and alttag. I want to use them in laravel blade view. I try something like this:
{{ HTML::image('images/{{ $item->image }}', $alt="{{ $item->alttag }}") }}
But syntax isn't correct. If i just echo image and alttag like this:
<h1>{{ $item->alttag }}</h1>
then they are correct. I wonder what is wrong in my code.
You used blade syntax in a PHP string. Watch the compiled blade templates to see where you did go wrong.
In short. Try this:
{{ HTML::image('images/'. $item->image, $alt = $item->alttag) }}
or equally short:
{{ HTML::image("images/{$item->image}", $alt = $item->alttag) }}
{{ Form::text('username', Input::old('username')) }}
This is my code, I want to add Username as placeholder in the text box. I already use bootstrap in the project.
I tried to use the example
{{ Form::text('username', 'Username', Input::old('username')) }}
But it gives a default value which needs to be deleted and then the user has to type his value. I want something like how it shows up on Twitter.com etc. Which gets erased once user types into it.
{{ Form::text('username', Input::old('username'), array('placeholder'=>'Username')) }}
This works for Laravel 4!!
{{ Form::text('username', null, array('placeholder'=>'Username' )); }}
Use:
{{ Form::text('txtUsername', '',array('class'=>'input', 'placeholder'=>'Username')) }}
Been a while since this was updated but with Former for Laravel the way to do this would be:
Former::text('field')->placeholder('langfile.path.to.placeholder.text')))
The lang file would be called langfile.php with the array containing:
<?php
return array (
'path.to.placeholder.text' => 'Some Placeholder Text.'
);
In case somebody wonders how this should work for a password field:
{{ Form::password('password', array('placeholder'=>'Password')) }}