wash a string like in a url

Author Message

Carlos Campderrós

Monday 07 August 2006 10:27:02 am

Hello,

I have an array of arrays for the purpose of generating the menu of my site. I'd like to add 'class="current" to all <li> that are in the path of the current page. For example, if the actual path is: http://mysite/company/about_us/carlos the menu should look like this:

<ul>
  <li><a href="foo">foo</a></li>
  <li class="current"><a href="/company">company</a>
    <ul>
      <li class="current"><a href="/company/about_us">about us</a>
         <ul>
            <li><a href="/company/about_us/someone">someone</a></li>
            <li class="current"><a href="/company/about_us/carlos">carlos/</a></li>
         </ul>
      </li>
    </ul>
    </li>
    <li><a href="/company/bar">bar</a></li>
</ul>

In the array of the menu, every item looks like this:

{def $item = hash(
   "text_to_show", "foo bar",
   "nodeID", 666
)
}

I'd like to process the menu item like this:

{if $node.url_alias|contains($item.text_to_show|SOME_OPERATOR_HERE)}
  <li class="current"><a href={fetch('content','node',hash('node_id',$item.nodeID)).url_alias|ezurl}>{$item.text_to_show</a></li>
{else}
  <li><a href={fetch('content','node',hash('node_id',$item.nodeID)).url_alias|ezurl}>{$item.text_to_show</a></li>
{/if}

Any idea about the SOME_OPERATOR_HERE?

thanks

Carlos Campderrós

Monday 07 August 2006 1:17:53 pm

Hi, regarding this topic, I just discovered the possibility of writing my own template operators (site_admin/setup/templateoperators) via another post in the forum. Now the next question is: which characters are allowed in eZpublish generated URLs? only [a-z0-9_]? I've performed a little test with "weird" characters:
áàä is translated into "aaa"
â is translated into "ea"
èéë is translated into "eee"
ê is translated into "e" (look difference between â and ê)

letter i behaves the same as 'e', while 'o' and 'u' do it like 'a'.

ñ and ç are translated into 'n' and 'c', respectively.

Any other characters in a Spanish keyboard seem to be discarded. Can someone please confirm this?

Marcin Drozd

Monday 07 August 2006 2:29:15 pm

Hi
recur to previous post.
U can use treemenu function with is_selected_method parameter ( http://ez.no/doc/ez_publish/technical_manual/3_8/reference/template_operators/miscellaneous/treemenu )

http://ez-publish.pl

Carlos Campderrós

Tuesday 08 August 2006 10:25:50 am

I saw treemenu first, but it didn't accomplish the requirements, as, for example, I have some nodes of class "Article" that should be shown, and some that shouldn't be shown. Unfortunately I think this can't be done with treemenu, nor can be done a treemenu of only some nodes ID (not classes ID).

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 19:09:32
Script start
Timing: Jan 18 2025 19:09:32
Module start 'layout'
Timing: Jan 18 2025 19:09:32
Module start 'content'
Timing: Jan 18 2025 19:09:32
Module end 'content'
Timing: Jan 18 2025 19:09:32
Script end

Main resources:

Total runtime0.0156 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0072 589.0313152.6250
Module start 'layout' 0.00720.0027 741.656339.4453
Module start 'content' 0.00990.0039 781.101693.3359
Module end 'content' 0.01380.0018 874.437534.3047
Script end 0.0156  908.7422 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002415.0415140.0002
Check MTime0.00116.7326140.0001
Mysql Total
Database connection0.001911.867510.0019
Mysqli_queries0.002516.204330.0008
Looping result0.00000.083910.0000
Template Total0.00159.710.0015
Template load0.00085.017410.0008
Template processing0.00074.628310.0007
Override
Cache load0.00053.378510.0005
General
dbfile0.00021.194880.0000
String conversion0.00000.038140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs