Forums / Setup & design / Space of the toolbars

Space of the toolbars

Author Message

Pascal France

Sunday 20 August 2006 3:40:44 pm

Hi,

When we set up a right tool which has to be displayed only in certain subtrees, even we are not in these subtrees, a right empty space (or the right column) is kept and displayed.

Is there a way to remove this space when the tool is not showed ?

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

Monday 21 August 2006 12:31:23 am

Hi Pascal

Have a look at the html code - is there still a <div> for the toolbar even though it is empty?
If yes, you just have to include the opening and closing <div> tag within your condition (the one that decides whether to display the toolbar). Alternatively you can capture the output of the toolbar in a set-block and then only use the div tags if the set-block variable has content.

Greetings from Luxembourg

Claudia

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

Pascal France

Tuesday 22 August 2006 2:56:36 am

Hi,

In fact, the problem is that in pagelayout, the system doesn't determine if we are in one of the $show_subtree values but only if tools are set or not.

If someone has already coded something to add this function, this could help me.

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

Pascal France

Tuesday 22 August 2006 6:40:45 am

Hi Marcin,

Thanks a lot.
Your code works fine but:

1°/ the name of the tool section is [Tool_right_node_list_1]
So, if you set 2 node_list tools, you will have [Tool_right_node_list_1] and [Tool_right_node_list_2].
It would be nice the code seeks the $show_subtree values of the 2 tools.

2°/ How to do if I create a new tool which uses $show_subtree too ? In other words, how to do in order the code seeks all the $show_subtree values of all the tools ?

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 7:27:36 am

Maybe something like this (pseudo-code):

$i=1;
$a=array();
while (true)
{
 $t=concat( 'Tool_node_list_', $i );
 $a[] = ezini( $t, 'show_subtree', 'toolbar.ini' )
 $i++;
}

http://ez-publish.pl

Pascal France

Tuesday 22 August 2006 9:44:58 am

Hi Marcin,

I'm trying to adapt your code but I can't use ezini( $var, 'xxx', 'xxx')

Is there a way to use a variable within ezini ?

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

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

Claudia Kosny

Thursday 24 August 2006 2:38:21 pm

Hi Pascal

I had actually placed some tools called Tool_right_nodexxx directly in the tool section for another project earlier on and forgot that this is usually not the case...

Regarding the array: $a now contains the found show_subtree values, but you are right, you do not really need an array here. I just used it because you had it in your code. Once you have found a value for show_subtree you are good, no need to save it in an array.

Regarding the actual problem though I do not have an idea for an solution. I tried to write an extension to do the job. It is very easy to get all show_subtree settings but I could not determine whether the tool (which the setting belongs to) will be actually called upon.
Hopefully I am missing something very obvious, but right now I don't see how to solve your problem. And at the beginning I thought it would be an easy problem...

I would suggest posting a bug report which details your problem. Maybe there is a quick fix which we just don't see.

Good luck

Claudia

Pascal France

Friday 25 August 2006 12:07:01 am

Hi Claudia,

The problem is indeed less easy than it could seem.

Thank you very much for your contribution.

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