3

I'm having a hard time wrapping my head around this.

I'm using Stash template partials approach, with the needle/haystack technique for replacing variables in content blocks... with CE Cache over the top.

My template looks like this:

{!-- Embed view/layout --}
{stash:embed:layouts:default}

{exp:ce_cache:it id="model"}

  {exp:channel:entries ...}
    {!-- Get video data from matrix field --}
    {cf_page_videos}
      {exp:stash:set name="video-{row_count}" type="snippet"}
        {mx_video}
      {/exp:stash:set}
    {/cf_page_videos}

    {!-- Vars to go in view/layout --}
    {exp:stash:set}

      {stash:title}{title}{/stash:title}

      {stash:content}
        {!-- Parse this so the {video-1}, {video-2} snippets within will work --}
        {exp:stash:parse}
          {cf_page_content}
        {/exp:stash:parse}
      {/stash:content}

    {/exp:stash:set}
  {/exp:channel:entries}

{/exp:ce_cache:it}

My view/layout template looks like this:

{exp:ce_cache:it id="view"}

  <h1>{exp:stash:title}</h1>
  {exp:stash:content}

{/exp:ce_cache:it}

Everything works just fine when CE Cache is disabled.
When I enable it, the 'view' cache fragment shows something like:

<h1>Page Title</h1>
<p>This is the page content</p>
<p>{video-1}</p>
<p>Some more content</p>

If I change {exp:stash:parse} to {exp:stash:parse process="end"}, then the 'view' cache fragment will look something like:

<h1>Page Title</h1>
{d534s5d782yihu542u78fdhs894sh}

I don't know what I need to escape or modify to get this working.
Any suggestions would be appreciated!
Thanks

Update:
The latest version of CE Cache has some Stash-related improvements.
Updating fixed the issue but introduces a Stash bug.
Also, I need to use {exp:stash:parse process="end"}.

I get a PHP error on the first page load, but everything seems to get cached correctly and the subsequent page loads are perfect.
I've taken this up with Mark and will post an update later.

Update 2:
Aaron (CausingEffect) has fixed the issues in the latest version of CE Cache.
The above code works perfectly - provided you use {exp:stash:parse process="end"}.

7
  • 1
    That looks like a lot of caching! :) Why are you using both CE Cache and Stash however? I can imagine that the two together with one inside the other would cause a few problems. – Ian Apr 17 '13 at 19:41
  • I'm not using Stash caching, though. Just using Stash for the template partials approach. – Jason Varga Apr 17 '13 at 20:13
  • I suspect you need to escape out of CE Cache on at least those parts of the page. The weird gibberish is a placeholder string that the EE template parser uses when it's partway through its run. – adrienne Apr 17 '13 at 20:42
  • Adrienne, take a look at the update at the end of the post. Latest version of CE Cache gets most of the way there. – Jason Varga Apr 17 '13 at 21:48
  • Interesting. I've not considered using the two in combination before but potentially it could be quite a powerful combination. It looks like Aaron (CE) may be looking to add a plugin to allow escaping by default in combination with Stash which also looks promising. Let me know what you hear back from Mark. – Ian Apr 18 '13 at 9:35
1

I set up my templates differently from you with regards to CE Cache. I wrap the whole template in CE Cache tags so that includes the embedded layout template too.

Page template

{exp:ce_cache:it id="the-template"}
{embed="layouts/index"}
...rest of page...
{/exp:ce_cache:it}

and then don't wrap the layouts/index template in CE Cache tags but instead use escape tags for bits I don't want cached.

1
  • The latest version of CE Cache fixes the issues I bring up in my question. – Jason Varga Apr 18 '13 at 13:15
0

This issue is fixed by updating CE Cache to the latest version.

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.