prodeveloper / social-share

Sharing to Social Networks for Laravel 5
MIT License
184 stars 67 forks source link

how to use it in blade template. #19

Closed price2b closed 7 years ago

price2b commented 7 years ago

I used the example in the controller and is not giving me any error: return view('static.index')->withSharelinks($sharelinks);

On the other hand I dont know the way I have to use the information in blade template. My idea is to pass the array:

{
    "gplus" : "https://plus.google.com/share?url=http%3A%2F%2Fwww.example.com",
    "twitter" : "https://twitter.com/intent/tweet?url=http%3A%2F%2Fwww.example.com&text=Link+description",
    "facebook" : "https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fwww.example.com&title=Link+description"
}

, any help appreciated.

kevinruscoe commented 7 years ago

the -> withSharelinks($sharelinks) should create a variable called $sharelinks with the contents of $sharelinks. So just echo $sharelinks['gplus'].

I'd actually change the sample to

return view('static.index', [
    'sharelinks' => $sharelinks
]);

then $sharelinks['gplus'] should work as well.

price2b commented 7 years ago

excellent kevin. thank you so much!.