laravel-shortcodes
laravel-shortcodes copied to clipboard
Is it possible to return a variable then is it on the view?
propose
return "<?php $test = {$value}; ?>";
I don't understand your question.
see screenshot
Let me see, what I can do.
so I want to use $variable in the view like {{ $variable }}
So why need Shortcode? You can use create Blade Extended.
https://laravel.com/docs/6.x/blade#extending-blade
this is what I'm trying to achieve
[webapp id='123123' collection='listofteams']
@foreach ($listofteams as $item)
<li>name</li>
@endforeach
Nice idea, dude. This feature can be added, but I don't think I can do it earlier :(
But you can create a shortcode and pass the collection, and shortcode will output the FOREACH as a result. :)
yes, I already made those things. but I want to change the layout in every collections. that's why we want it to foreach in the view.
But you can add one more attribute like [webapp wrap="li" parent="ul"]
this way you can create multiple layouts. So it could be DIV or LI or anything.
Also, you can pass a partial view name like [webapp view="orders.grid"]
and class function would be like:
$view = view($viewname)->render();
return $view
I think it would work.
Thank you for helping me on this but I think it would be much easier if the we can use the variable that was return in shortcode or return a php tag(like what is in my screenshot).