I’m using Sage 10 and installed the sage directives composer dependency. When I try to use @guest I get this error:
ErrorException: Call to undefined function auth() (View: /srv/www/biolayne.com/current/web/app/themes/biolayne_3.0.0/resources/views/partials/home/hero.blade.php) (View: /srv/www/biolayne.com/current/web/app/themes/biolayne_3.0.0/resources/views/partials/home/hero.blade.php) in /srv/www/biolayne.com/current/web/app/uploads/cache/6073fe26b0e42fc88197e41abb3990f11754f7f4.php on line 39
Is there another step I’m missing to get this package hooked up to Sage10? Thanks!
Seems you can’t just return the url of an image size other than raw - all other sizes output an img tag. I’m using the image as inline css background-image so just want the url.
Encountered a caching issue when using @image to grab an acf image field on CPT posts – just loads the first post you visit’s field value until you delete the uploads/cache directory. Then it will load only the current post’s field value until you clear the cache again. Using wp_get_attachment_image doesn’t have the issue.
Am using stoutlogic’s acf-builder, trellis and bedrock.
I am using ACF pro and have image based fields using ID as the data value. When saving a value (image file) to the field and viewing the page, I see the correct image. When editing the same page and deleting/adding a new value/image file to that same field, it updates and shows correctly in the back end, however the front end displays the previous image. Deleting the /uploads/cache folder makes the page display the latest and correct value.
Directives are not executed as PHP; they’re essentially instructions that tell the Blade engine to generate particular PHP when it renders the cached blades. That means you need to be careful with what/how data is passed to them. It sounds like either the directive you’re using or the way you’re passing data to it is causing the ID value present when the cached blade is generated to be “baked in” as a scalar value, not a variable to be evaluated at runtime.
I’ve installed this in Sage 10 as per the instructions but when I use for example @field, it results in a blank page. I’d appreciate any pointers in the right direction.
EDIT:
Nevermind, I’m an idiot. I actually wrote {{ @field('test) }} rather than @field(‘test’).
@Log1x, thanks so much for this project! It’s been fun to implement across all my recent projects.
I’ve got a question that might seem silly… With ACF fields, to echo a field from a specific post = @field('text', 1). Is that for ACF Pro only? I’m assuming this uses the Global Fields feature that’s on the pro license?
Tried to do it on the free version, and I get Notice: Trying to access array offset on value of type null in /srv/www/domain.com/current/web/app/uploads/cache/e9dd69eb86fcd8e1a7fd5f631109a6b2ebcfa139.php on line 34
Thanks so much for your work on this, I love the simplicity of of my markup using these directives. I have an issue I’m wondering if you can help with:
I’m using the @image directive inside a blade template for an ACF block (using mwdelaney/sage-acf-gutenberg-blocks). I’m passing an ACF field name as the first argument ie. @image( 'my_image_field', 'large', ... ). Strangely, when I update the value of this field in the block editor, for example swapping an image, the view isn’t being re-compiled and I continue to see the cached view (with the old field value) when I refresh the page. After running the WP CLI command wp acorn view:clear the view is updated and displays correctly. This issue does not occur if instead of passing the field name as the first argument, I pass the value itself ie. @image( get_field( 'my_image_field', 'large', ... ).
I don’t know much about how views are cached in Sage and I’m struggling to find much information on it, so apologies if this isn’t actually anything to do with your code, but thought perhaps you might be able to shed some light.