I'm having a difficult time figuring this out.

There's a section in a website with events. Visitors can vote for these events, 24 hours before and after it happens. Longer before that, it has a 'attend'-button. Afterwards, it shows the average score.

As I always do, I use Croxton's stash plugin. This section, ofcourse, shouldn't be stashed.

So, at first, I had this:

<div> {if {current_time format="%U"} - {event_time format="%U"} < -86400} {facebook_link} {/if} {if {current_time format="%U"} - {event_time format="%U"} < 86400 && {current_time format="%U"} - {event_time format="%U"} > -86400} <p>Voting open</p> {/if} {if {current_time format="%U"} - {event_time format="%U"} > 86400} <p style="color: black;">{exp:bol_voting:stats entry="{event_id}"}</p> {/if} </div>

Now, ofcourse, because these sections get stashed, the time-checks don't matter. If we reach the time-frame in which people can vote, nothing will happen. Also, the eventual average score returned by bol_voting will be stashed.

I didn't want that, so I wrapped it in a {stash:nocache} wrapper. All my variables, as well as my custom bol_voting module, don't get parsed anymore (event_time and facebook_link).

Anyone can save me here?



Carefully "unescape" the variables you want to be cached, so e.g.

  {if {current_time format="%U"} - {/stash:nocache}{event_time format="%U"}{stash:nocache} < -86400}
  {if {current_time format="%U"} - {/stash:nocache}{event_time format="%U"}{stash:nocache} < 86400 && {current_time format="%U"} - {/stash:nocache}{event_time format="%U"}{stash:nocache} > -86400}
    <p>Voting open</p>
  {if {current_time format="%U"} - {/stash:nocache}{event_time format="%U"}{stash:nocache} > 86400}
    <p style="color: black;">{exp:bol_voting:stats entry="{/stash:nocache}{event_id}{stash:nocache}"}</p>

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.