Pascal France
|
Monday 21 August 2006 7:24:05 am
Hi Claudia, In the source code (when the node-list tool is not displayed) I can see that:
<div id="columns">
<hr class="hide" />
<div id="rightmenu">
<div id="rightmenu-design">
<h3 class="hide">Right menu</h3>
<div id="toolbar-right">
<div class="toolbar-design">
<div class="toolbar-item last">
</div>
</div>
</div>
</div>
</div>
<hr class="hide" />
<div id="maincontent" class="maincontent-noleftmenu">
if I don't set any tool, the source code is:
<div id="columns">
<hr class="hide" />
<hr class="hide" />
<div id="maincontent" class="maincontent-nomenus">
The template used to display the node-list tool is design/standard/templates/toolbar/full/node_list.tpl
{* DO NOT EDIT THIS FILE! Use an override template instead. *}
<div class="toolbar-item {$placement}">
{section show=or($show_subtree|count_chars()|eq(0),
fetch(content, node, hash( node_id, $module_result.node_id ) ).path_string|contains( concat( '/', $show_subtree, '/' ) ),
$requested_uri_string|begins_with( $show_subtree ))}
{default current_user=fetch('user','current_user')}
{cache-block keys=array($tool_id, $current_user.role_id_list|implode( ',' ), $current_user.limited_assignment_value_list|implode( ',' ))}
{default limit=5}
{section show=$sort_by|count|eq( 0 )}{set sort_by='published'}{/section}
{let node_list=cond( $treelist_check|eq( 'yes' ),
fetch( content, tree, hash( parent_node_id, $parent_node,
limit, $limit,
class_filter_type, exclude,
class_filter_array, array( 'folder' ),
sort_by, array( $sort_by, false() ) ) ),
fetch( content, list, hash( parent_node_id, $parent_node,
limit, $limit,
class_filter_type, exclude,
class_filter_array, array( 'folder' ),
sort_by, array( $sort_by, false() ) ) ) )}
<div class="toollist">
<div class="toollist-design">
<h2>{$title}</h2>
<div class="content-view-children">
{section name=Node loop=$node_list sequence=array(bglight,bgdark)}
{node_view_gui view=listitem content_node=$Node:item}
{/section}
</div>
</div>
</div>
{/let}
{/default}
{/cache-block}
{/default}
{/section}
</div>
In pagelayout.tpl, the code which calls the tools is:
{section show=ezini( 'Toolbar_right', 'Tool', 'toolbar.ini' )|count}
<div id="rightmenu">
<div id="rightmenu-design">
<h3 class="hide">Right menu</h3>
<div id="toolbar-right">
<div class="toolbar-design">
{tool_bar name=right view=full}
</div>{* id="toolbar-design" *}
</div>{* id="toolbar-right" *}
</div>{* id="rightmenu-design" *}
</div>{* id="rightmenu" *}
{/section}
So, if I well understand what you mean, I have to modify the code of node_list.tpl like that:
{* DO NOT EDIT THIS FILE! Use an override template instead. *}
{section show=or($show_subtree|count_chars()|eq(0),
fetch(content, node, hash( node_id, $module_result.node_id ) ).path_string|contains( concat( '/', $show_subtree, '/' ) ),
$requested_uri_string|begins_with( $show_subtree ))}
<div id="rightmenu">
<div id="rightmenu-design">
<h3 class="hide">Right menu</h3>
<div id="toolbar-right">
<div class="toolbar-design">
<div class="toolbar-item {$placement}">
....
....
....
....
</div>{* class="toolbar-item" *}
</div>{* id="toolbar-design" *}
</div>{* id="toolbar-right" *}
</div>{* id="rightmenu-design" *}
</div>{* id="rightmenu" *}
{/section}
But this doesn't work. The right empty space is always kept. However, now, the code source (when the node-list tool is not displayed) is:
<div id="columns">
<hr class="hide" />
<hr class="hide" />
<div id="maincontent" class="maincontent-noleftmenu">
Did I forgot something ? Regards Pascal
Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish
|
Marcin Drozd
|
Tuesday 22 August 2006 3:17:09 am
Hi Pascal
I think the problem is with <div id="maincontent" class="maincontent-noleftmenu"> Did U try use this code (or similar, this is only an idea :) ) in the pagelayout.tpl
{let $show_subtree=ezini( 'Tool_node_list', 'show_subtree', 'toolbar.ini' )}
{*because, there isnt $show_subtree in pagelauoyt.tpl*}
{* $show_subtree is only in node_list.tpl *}
{section show=or($show_subtree|count_chars()|eq(0),
fetch(content, node, hash( node_id, $module_result.node_id ) ).path_string|contains( concat( '/', $show_subtree, '/' ) ),
$requested_uri_string|begins_with( $show_subtree ))}
<div id="maincontent" class="maincontent-noleftmenu">
{section-else}
<div id="maincontent" class="maincontent-nomenus">
{/section}
{/let}
http://ez-publish.pl
|
Claudia Kosny
|
Tuesday 22 August 2006 12:37:20 pm
Hi Pascal, try it like this (as usual not tested, may contain typos):
{* fetch all available tools, go though each tool and check whether it is a node listing,
then fetch the value of show_subtree. If the show-subtree value of one of the tools is in the path of the currently viewed node, set show_menu to true *}
{def $currentNode = fetch('content', 'node', hash('node_id', $module_result.node_id))
$allTools = ezini('Tool', 'AvailableToolArray', 'toolbar.ini')
$show_subtree = false()
$show_menu = false()}
{foreach $allTools as $tool}
{$tool} <br />
foo{ezini('Tool_right_node_list_1', 'show_subtree', 'toolbar.ini')}bar
{if $tool|contains('node_list_')}
{set $show_subtree = ezini($tool, 'show_subtree', 'toolbar.ini')}
{$show_subtree} <br />
{if and($show_subtree|is_integer,
or($currentNode.path_string|contains(concat('/', $show_subtree, '/')),
$currentNode.path_string|ends_with(concat('/', $show_subtree))))}
{set $show_menu=true()}
{break}
{/if}
{/if}
{/foreach}
At the end $show_menu should hold the info on which style to display. Greetings from Luxembourg Claudia
|
Pascal France
|
Wednesday 23 August 2006 10:58:06 am
Hi Claudia, First: I'm not a developper.
What I wanted to say is that it seems ezini doesn't accept variable in its syntax. So:
{set $show_subtree = ezini($tool, 'show_subtree', 'toolbar.ini')}
won't work. When I sent my previous post, I had written this code (it was just a test):
{def $i=0 $a=array()}
{while ne($i, 5)}
{def $t=concat('Tool_right_node_list_',$i) $a=array(ezini($t,'show_subtree','toolbar.ini'))}
{$a[$i]}
{set $i=inc($i)}
{/while}
$t doesn't work but if I replace it with 'Tool_right_node_list_1' then {$a[$i]} return the right value. Regards Pascal
Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish
|
Claudia Kosny
|
Wednesday 23 August 2006 12:07:25 pm
Hi Pascal, You are right, it was quite a big chunk of code I posted (as I see now I even left some debug irrelevant output in there, sorry for that). The reason why I posted it was actually to show you that I could fetch the ezini settings using variables. So here the relevant excerpt of the code:
{def $allTools = ezini('Tool', 'AvailableToolArray', 'toolbar.ini')
$show_subtree = false()}
{foreach $allTools as $tool}
{if $tool|contains('Tool_right_node_list_')}
{set $show_subtree = ezini($tool, 'show_subtree', 'toolbar.ini')}
show_subtree setting is: {$show_subtree} <br />
{/if}
{/foreach}
This fetches all the name of all available tools, goes through each of them and once the name of the tool contains the string 'Tool_right_node_list_' it fetches the setting for show_subtree.
There are a few reasons why your code is not working (if you look at the debug output should see have some errors). First you cannot use {def in a loop, you have to def the variable $t before the loop and then just update it during the loop. The way you use arrays is not correct either (look up the docu if you are interested in that). Therefore ezini does never get a correct $t.
Another problem doing it your way is that you get error messages if the toolbar with one of the numbers between 0 and 5 does not exist. So if you add a toolbar you have to change your code. Nevertheless, here your code cleaned up a bit:
{def $i=0
$a=array()
$t=''}
{while ne($i, 5)}
{set $t = concat('Tool_right_node_list_',$i)}
{set $a = $a|append(ezini($t, 'show_subtree', 'toolbar.ini'))}
{set $i = inc($i)}
{/while}
{foreach $a as $key => $setting}
setting for toolbar number {$key} is {$setting} <br />
{/foreach}
Hopefully I have made it a bit clearer now. If not just tell me - I'll try my best. Claudia
|
Pascal France
|
Thursday 24 August 2006 1:23:57 am
Hi Claudia, Think you very much. Really. Well, it seems something can't work in your code:
{def $allTools = ezini('Tool', 'AvailableToolArray', 'toolbar.ini')
$show_subtree = false()}
{foreach $allTools as $tool}
{if $tool|contains('Tool_right_node_list_')}
$tool can't contain 'Tool_right_node_list_' because it's only [Tool_<place_of_the_tool>_<tool_name>_<order_of_the_tool>] which can contain 'Tool_right_node_list_' I wrote this code:
{def $toolname = ezini('Tool', 'AvailableToolArray', 'toolbar.ini')
$fulltoolname = ''
$show_subtree = false()
$i = 0
$a=array()
}
{while ne($i,5)}
{foreach $toolname as $toolnames}
{set $fulltoolname = concat('Tool_right_',$toolnames,'_',$i)}
$fulltoolname: {$fulltoolname}<br />
{set $show_subtree = ezini($fulltoolname, 'show_subtree', 'toolbar.ini')}
{if ne($show_subtree, 0)}
{set $a=$a|append($show_subtree)}
{/if}
{/foreach}
{set $i=inc($i)}
{/while}
{undef}
The only thing which doesn't work is the use of the array $a but I don't understand how to use it here (whereas the example of its use you give me works fine). The difficulty is that we have to find one event of show_subtree (the first one we find is sufficient to know there is a tool on the right or the left) of an array of which we don't know the name in advance. Moreover, the name contains the order of the tool, so once we found the name [Tool_<place_of_the_tool>_<tool_name>_] we have to find its order. Regards Pascal
Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish
|