4

I'm trying to clear ce_cache of a category given a specific entry's set of categories. This doesn't seem to work and I think it's because the {categories} tag pair isn't quite a full implementation of the parse_variables() function. Any thoughts on how to accomplish the following?

{exp:channel:entries channel="channel" 
    sort="desc" 
    orderby="entry_date"
    dynamic="no"
    limit="1"
    offset="1"
    disable="category_fields|custom_fields|member_data"}

    {categories}
    {exp:ce_cache:clear items="local/category/{category_url_title}" refresh="1"}
    {/categories}

{/exp:channel:entries}
2

It might be a parse order issue. If so, using Stash should work to save the categories into a variable list, and then you can run the ce_cache:clear when outputting the list (this is untested):

{!--   cache a list of the category url titles   --}
{exp:stash:set_list 
    name="cached_cat_url_title" 
    parse_tags="yes"
    trim="yes"  
}
    {categories}
        {stash:cat_url_title}{category_url_title}{/stash:cat_url_title}
    {/categories}
{/exp:stash:set_list}

{!--   output the list of category url titles, breaking the cache for each one   --}
{exp:stash:get_list 
    name="cached_cat_url_title"
    parse_tags="yes"
    process="end"
}   
    {exp:ce_cache:clear items="local/category/{cat_url_title}" refresh="1"}
{/exp:stash:get_list}

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.