Jump to content

mav_medved

Members
  • Posts

    4
  • Joined

  • Last visited

Community Answers

  1. mav_medved's post in A custom cache key before rendering the page, using a built-in template cache engine was marked as the answer   
    BernhardB, thanks for response!
    A very nice module, I've found it very useful! Thanks for advice!
    But I needed to make cache not for a part of the template, but whole template. (have some specific )
    So I came up with the solution, using this module:
    (maybe someone will find it useful too)


    <?
    $cache = $modules->get("MarkupCache");
    $cache_key = 'page_'.$page->id.'_myvar_'.$my_session_var;

    if (!isset($options['render_for_cache'])){
    $page->template->prependFile = '';
    if (!$output = $cache->get($cache_key)){
    $output = $page->render(array('render_for_cache' => 1, 'prependFile' => '', 'appendFile' => ''));
    $cache->save($output);
    }
    echo $output;
    }
    else{
    ?>

    <!-- here is my plain html/php markup -->

    <?
    }
    ?>

    So now I can make a cache for any template with any cache_key.
    I'm sure it's possible to make a Hook using "before render" for certain templates, so that can make cache and keep the template file clean. (or maybe not )
    Anyway don't want to do it, ask me if someone need it
×
×
  • Create New...