ledesma
ledesma

Reputation: 378

Limit string in laravel

I am limiting a string in laravel if it's bigger than 50 and showing a button read more.

{!! str_limit($val['body'], $limit = 50, $end = '....... <div class="post-more"><a href='.url("/".$post->slug).' class="btn btn-primary">Read More</a></div>') !!}

My question is, using that way i bring the user to another page. How could I just show the rest of the string when the user hits the Read More button?

Upvotes: 0

Views: 735

Answers (1)

HenryTK
HenryTK

Reputation: 1287

PHP is for request-response transactions (I know it can be used for scripting as well before you PHP nerds pipe up), so pure PHP solutions won't produce the required behaviour. You need to use Javascript for this. Some hardcore individuals have even written libraries for this kind of thing: https://github.com/jedfoster/Readmore.js

Upvotes: 1

Related Questions