Filter Hugo Pagination by Custom Param - go

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.

Related

How to capitalize the parameters that are passed in the URL to whatsapp api web?

I would like to capitalize the parameters I pass in the url to whatsapp api web.
Specifically I have the following href:
href="https://api.whatsapp.com/send?phone={{str_replace(' ', '',$client->telephone_number)}}&text=Hello {{ $client->name }} {{ $client->surname }}, I'm trying to send you a message"
Specifically, I would like {{ $client->name }} {{ $client->surname }} capitalized, for example if I have {{$client->name}} which is Mary and {{$client->surname}} which is Rossi, I would like to have MARY ROSSI.
I have been browsing the internet for some time, but I have not found anything about it.
Could anyone kindly help me?
Make use of PHP strtoupper() function which converts a string to uppercase
So change your code to this:
href="https://api.whatsapp.com/send?phone={{str_replace(' ', '',$client->telephone_number)}}&text=Hello {{ strtoupper($client->name) }} {{ strtoupper($client->surname) }}, I'm trying to send you a message"

Don't show get parameter in blade

In My route:
Route::get('/item/{itemId?}', 'ItemController#index');
Controller returning to:
http://example.com/item/12
But in blade don't showed {{Request::segment(3);}}
Please, help! And sorry for my English
It should be segment(2):
{{ Request::segment(2) }}
And segment(1) will return "item"
Your route has 2 segments! so if you need id it's in segment2
{{ Request::segment(2) }}
segment 1 will be equal to items
{{ Request::segment(1) }} //items

How to the domain url in laravel5

I have to get the domain url (ex. http://www.example.com/) in laravel blade. I've tried using {{ url() }} but it returns the path to my public directory. Is there any one line function to get this? How do I get the domain in blade? Need help. Thanks.
You can also try
{{ Request::server ("SERVER_NAME") }}
{{ Request::server ("SERVER_NAME") }}
Or go with
{{ Request::root() }}

About Laravel - How to use function string in view

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='...') }}

Using HTML Placeholder in Laravel 4

{{ 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')) }}

Resources