This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Slasher
I'm trying to get {{img_path}} variable data inside php code block
{% for image in gallery %}
{% set path = '/storage/app/media' %}
{% set gallerySlug = record.gallery_folder %}
{% set tilda = '/' %}
{% set combinedLink = path ~ gallerySlug ~ tilda ~ image %}
{% set link = path ~ image %}
<div class="grid-item wow fadeInUp" data-wow-duration="1s" data-wow-delay="0s" data-tilt data-tilt-speed="250" data-tilt-max="5" data-tilt-perspective="250">
<a href="{{combinedLink}}" target="_blank"><img src="{{combinedLink | resize(1000)}}" alt="Camera: {{img_path}}"/></a>
</div>
{% endfor %}
function onEnd() { $this["img_path"] =$this["image"]; // To be accessed here }
JeffGoldblum
You're better off in that case generating the variable in PHP first and then passing it to Twig instead of the other way round
Slasher
I managed to generate same variable in PHP but the problem is that variable {{img_path}} inside that for loop stops at first iteration, but when it's outside that twig loop then PHP iterations works.
It there any workaround for this?
1-3 of 3