Use a static function so you can run a function within each layout.
Thanks for the response.
I noticed that same variable values are being displayed on different flexible content rows; despite the values in the backed of WP.
How would you go about creating a unique variables inside of the flexible content loop with the controller?
Hey did you end up using this way of getting the name of the current blade template? Because I tried to implement it the exact same way (also using barba.js in my project), but I canāt get it to work. I get the error message āundefined variable: current_template in ā¦/wp-content/uploads/cache/350a511d5b8c77023912d976ba1f2ffcdbf847ee.phpā.
I added the filter in āmy-theme/app/filters.phpā. Maybe Iām missing something?! A pointer would be much appreciated!
sage version: 9.0.1
Are you using Controller?
You should be able to add this to App.php if youāre using Controller.
Hey, I already updated to āsoberwp/controllerā: ā2.0.1ā and followed instructions from other threads for the changed file names etc. So Iām able to get data of simple strings with the controller into my views, but not really sure how to use the filter for the name of the current blade template with the controller. Thatās why I tried to use the filter method in āapp/filters.phpā.
Thatās a good usecase, got some work to finish up, but Iāll take a look at a nicer way of doing this via the App Controller this evening.
@williharder this is quite an easy fix for Controller, so Iām going to push a new version over the weekend.
It will solve this https://github.com/roots/docs/issues/150 and https://github.com/soberwp/controller/issues/80
So in summary add_filter
should work again as expected.
Update: Pushed to dev-master for testing.
@williharder to take this further, the next release (which Iāll tag in the next few hours), is going to have a __before
(and __after
) method which will allow you to interact with Controller params. One of them, is
protected $template;
So in your specific Controller, you could use this lifecycle event
public function __before()
{
var_dump($this->template);
}
I hadnāt needed to learn too much about Blade to stay fairly DRY until now. So I watched the Blade section in this tutorial, and 30-60 minutes of taking notes and watching was so worth it. Really cleared up a couple confusions I had w/ Blade.
Iāve done this guyās tuts before (on Udemy for Vue.js), and he is one of my favorites.
Pluralsite isnāt free, but they do have free trials (no affiliate link or anything sneaky):
Thanks, I was also looking to learn better practices, will definitely check out.
I also found some blade tutorials on Laracast. Components and slots is a cool feature that is probably overlooked but most: https://laracasts.com/series/whats-new-in-laravel-5-4/episodes/6
I recently started using S3-Uploads and I run into this issue. Thanks a lot for mentioning this solution, it worked for me as well. Have you found a better way to counter this issue since you last posted your solution? Thanks!
Thought Iād chime in with my directives package:
Right now there is no documentation and Iām a little pressed on time, but the source code is a quick read to see what is readily available.
For documentation, I will probably just do a MD table or something in the README.md if anyone is feeling froggy.
Hey,
Awesome code, Iām using it right now on one of the sites Iām working on. Have a Quick q.
Did you end up having to use WP_Query for when you wanted pagination? I see get_posts as not working when you want to use pagination.
get_posts
and WP_Query
behave differently.
The first will simply grab an array of posts for you to use and manipulate.
Whereas WP_Query
is more for building out a page to list posts whilst leveraging the rest of the WP API.
In other words: get_posts
has no relation to WP_Query
pagination.
Read more: https://stackoverflow.com/a/24847152/4020364
The only thing that worked for me was:
`add_action('the_post', function() {
global $template;
sage('blade')->share('current_template', basename( $template ,'.blade.php' ));
});`
Hi, we are really trying to understand how to use layouts with @extends / @yield but we ran into a problem during our dev and we canāt figure why itās not working the ways we want toā¦ Here the stackoverflow : https://stackoverflow.com/questions/56046544/blade-sage-9-probem-when-multiple-yield-section
This forum was full of good ideas and inspire a lots of this stuff maybe someone here can help us understand what we did wrong or why this is happenning!
I still struggle with using ACF Repeater Loops in controllers and Iām wondering if anyone would be interested in breaking it down for me in this specific scenarioā¦
I have a repeater using a list of radio options. Depending on the option selected, an ACF file field is shown to prepopulate button text, or an final option to choose other and enter your own button text and file.
Hereās the loop Iām currently working with but would love to use this properly in a controller. Iāve tried many different ways of doing this but just canāt seem to get it to work properly. Thank you.
@if( have_rows('documents') )
@while ( have_rows('documents') )
@php the_row();
$type = get_sub_field('document_type');
$specifications = get_sub_field('specifications');
$floor_plans = get_sub_field('floor_plans');
$survey = get_sub_field('survey');
$land_use = get_sub_field('land_use');
$gis_map = get_sub_field('gis_map');
$parcel_report = get_sub_field('parcel_report');
$document_title = get_sub_field('document_title');
$other = get_sub_field('document_file');
@endphp
@if ($type == 'specifications')
<a href="{{ $specifications }}" class="flex-1 text-white uppercase no-underline p-4 border border-white m-2">Specifications</a>
@elseif ($type == 'floor_plans')
<a href="{{ $floor_plans }}" class="flex-1 text-white uppercase no-underline p-4 border border-white m-2">Floor Plans</a>
@elseif ($type == 'survey')
<a href="{{ $survey }}" class="flex-1 text-white uppercase no-underline p-4 border border-white m-2">Survey</a>
@elseif ($type == 'land_use')
<a href="{{ $land_use }}" class="flex-1 text-white uppercase no-underline p-4 border border-white m-2">Land Use</a>
@elseif ($type == 'gis_map')
<a href="{{ $gis_map }}" class="flex-1 text-white uppercase no-underline p-4 border border-white m-2">GIS Map</a>
@elseif ($type == 'parcel_report')
<a href="{{ $parcel_report }}" class="flex-1 text-white uppercase no-underline p-4 border border-white m-2">Parcel Report</a>
@elseif ($type == 'other')
<a href="{{ $other }}" class="flex-1 text-white uppercase no-underline p-4 border border-white m-2">{{ $document_title }}</a>
@endif
@endwhile
@else
<p class="text-center text-xlg">Sorry, there are no documents associated with this property.</p>
@endif