0

I tried to insert a custom field variable, Stash here, a simple custom field as a text field works fine (the value is parsed), but when I use a pair tag (as Fluid, Grid or another add-on), or a Stash variable, the value is never parsed:

{exp:ce_img:single src="{text_ee_field}"}

{exp:ce_img:pair src="{text_ee_field}"}
    <img src="{made}" />
{/exp:ce_img:pair}

give

<img src="http_lorempixel.com/400/200_400_200.jpg">
<img src="http_lorempixel.com/400/200_400_200.jpg">

Using a variable (Stash, EE, Low Var....), or a tag pair from Grid, Fluid, or other addons, doesn't work, I get blank code.

{exp:stash:set name="image"}http://lorempixel.com/400/200/{/exp:stash:set}

{exp:ce_img:single src="{exp:stash:get name="image"}"}

{exp:ce_img:pair src="{exp:stash:get name="image"}"}
    <img src="{made}" />
{/exp:ce_img:pair}

What could be the problem ?? A parse order ?? Priority ?? I tried parse="inward", priority="0". Even tried a Stash embed method with the parse="start" parameter, with no results.

1

Stash is very useful sometimes, but also is notorious for exactly this kind of obscure fail behaviour. Just look at the kind of questions asked about stash in this forum and you will see that you are not alone in encountering baffling behaviour.

There probably is a cute / concise solution to your problem: I'm not sure I have such for you, but do have two suggestions:

  1. you might want to try wrapping your ce-img code within a stash parse tag - this simple coerces EE to evaluate whatever it contains multiple times, and can sometimes fix the kind of issue you are having - more here.
  2. A better solution (I think at least) would be to replace stash with a layout variable - means splitting your template into (at least) two parts, but you can then access the values you save on the first template in the layout stack on subsequent templates - so just save your image definition on the first template in the sequence and recall it in your CE Image tag later on. More on layout templates and variables here.

Why are layout variables better? I think because they work, and because solutions that do not rely on an add-on are usually better than ones that do. You can't always avoid them, but in my view if you can you should!

HTH

| improve this answer | |
  • Hi Jcogs, thanks a lot for your reply ! I'm using exactly the same EE Template Layouts with first template in the layout stack on subsequent templates, with Stash. With this Stash layout Template Layouts (almost exactly the same as the EE one ), I've never had bit trouble because always I find a solutions using Stash parsing order or priority. Whoever the variable system, EE native, Stash, Low var, inside the CE Image src="{my_field}", only simple text fields, {segment_x}, are processed. A var or a tag pair is not processed. So, a more robust EE var system would be wonderful. – Stéphane May 26 '19 at 2:51
  • ........ I prefer not using PHP tricks, hacks, too buggy and unsafe. Stash is an extraordinary variables system, so powerful when we understand the concept. But yes, sometimes (it's very rare) could be as you said obscure. But always I find solution. As CE Image is so powerful, i try to understand why a var or a tag pair is not processed inside the src="{my_field}". The {my_field} works inside {exp:ce_img:pair src=""}{my_field}{/exp:ce_img:pair} and not as a parameter.... Thanks very helpful response. I guess would be nice to suggest a more powerful EE variable system. – Stéphane May 26 '19 at 3:10
  • We each have to find the way of doing things that works best for us. Stash was indispensable in EE2, but increasingly less so I think as EE has matured since then. The built in layout variables are an effective solution to the kind of thing you are trying to do (as far as I can tell from what you say), and have a much clearer instantiation process, making it easier to debug issues like this one. Encourage you to give it a go - especially if you are already using EE template layout in the design. – JCOGS Design May 26 '19 at 11:54
  • I'm totally agree with you. EE has evolved a lot, no longer needs, of a ton of addons. Since EE is OpenSource the EE activity and productivity awakened ! Really great. – Stéphane May 26 '19 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.