Alexei Pechekhonov
|
Thursday 05 June 2003 7:05:50 am
{cache-block} looks like very helpful feature, but...
i can't belive in restrictions of using it.I i can use cache-block for includes without errors only:
{cache-block keys=array('search_subscribe',$uri_string)}
{include uri="design/my_site/templates/search_subscribe.tpl"} {/cache-block} But when i try make cache for query-arrays - it looks like working and quicker, but i have errors from debugger output:
1. i try to use before {let} statemant, it works, but ....
{cache-block keys=array($current_root, $news_list, $article_list, $event_list, $product_list, $static_list, $DesignKeys:used.node) expiry=28000}
{let
current_root=fetch(content,node,hash(node_id,55))
news_list=fetch(content,tree,hash(parent_node_id,19,limit,5,sort_by,array(published,false()),class_filter_type,include,class_filter_array,array(2,7)))
article_list=fetch(content,tree,hash(parent_node_id,20,limit,5,depth,2,sort_by,array(published,false()),class_filter_type,include,class_filter_array,array(2)))
event_list=fetch(content,tree,hash(parent_node_id,21,limit,5,sort_by,array(published,false()),class_filter_type,include,class_filter_array,array(2,8)))
product_list=fetch(content,tree,hash(parent_node_id,22,limit,5,sort_by,array(published,false()),class_filter_type,include,class_filter_array,array(2,21)))
static_list=fetch(content,list,hash(parent_node_id,55,limit,5,sort_by,$current_root.sort_array ))
}
.... some_page_code....
{/let} {/cache-block}
debugger says:
Error: eZTemplate
Unknown template variable 'current_root' in namespace ''
Error: eZTemplate
Unknown template variable 'news_list' in namespace ''
Error: eZTemplate
Unknown template variable 'article_list' in namespace ''
Error: eZTemplate
Unknown template variable 'event_list' in namespace ''
Error: eZTemplate
Unknown template variable 'product_list' in namespace ''
Error: eZTemplate Unknown template variable 'static_list' in namespace ''
because i use the variables before I set them.
Right, but how should i use cache-block for caching queries?
{let $current_root $news_list $article_list $event_list $product_list $static_list}
then
{set current_root = fetch(content,node,hash(node_id,55))}
{set news_list = fetch(content,tree,hash(parent_node_id,19,limit,5,sort_by,array(published,false()),class_filter_type,include,class_filter_array,array(2,7))) }
... etc
Is that? But in this case {set ...} doesn't want to work, because i have 3 namespaces '', 'First' and 'First:Second' and set-construction, say, :
{set article_list=fetch(content, list, hash(parent_node_id, $First:item.node_id, limit, 10, sort_by, $First:item.sort_array, class_filter_type, include, class_filter_array, array(2,13))) }
doesn't work. :(
Q: how should i use cache-block for caching queries? Did somebody play around? Please ideas...
|
Alexei Pechekhonov
|
Thursday 05 June 2003 9:25:44 am
Thank you, Bard. Now i'm feeling myself more confidence :)
Couldn't you, please, demonstrate your ideas on my example?
Every section on my site has a few lists: menu, line-view, midle-view etc ...
e.g.
loop=list1,
loop=list2,
loop=list3 <--- + some internal loop4
Right? In let/default area i define 3 of them, then i use {set}, but it depends on section, so i need, like you've suggested, to use path/url var ( say $DesignKeys:used.node)for uniquness then cache-block:
{let list1 list2 list3 } {cache-block keys=array($list1, $list2, $list3, $DesignKeys:used.node}
{set list1=fetch(content,list,hash(parent_node_id, $DesignKeys:used.node ...)}
{set list2=fetch(content,list,hash(parent_node_id, $DesignKeys:used.node ....)} {set list3=fetch(content,list,hash( parent_node_id, $DesignKeys:used.node ....)}
some_funny_code ...
{section loop=list1 show=....} show_zone1 {/section}
{section loop=list2 show=....} show_zone2 {/section}
{section loop=list3 show=....} show_zone3 ...internal_loop4... {/section}
. . . . . . . . . . . . . . . . . . . . . .
{/cache-block} {/let}
Yes, the "structure" of lists is the same, but parent_node_id is various from section to section. Please correct me or share, please, another suitable point of view.
|