Forums / Developer / wash a string like in a url

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).

eZ debug

Timing: Jan 18 2025 16:27:13
Script start
Timing: Jan 18 2025 16:27:13
Module start 'content'
Timing: Jan 18 2025 16:27:13
Module end 'content'
Timing: Jan 18 2025 16:27:13
Script end

Main resources:

Total runtime0.1486 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0083 587.7109180.8359
Module start 'content' 0.00830.0041 768.546997.8828
Module end 'content' 0.01240.1360 866.4297527.7734
Script end 0.1485  1,394.2031 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00352.3796200.0002
Check MTime0.00150.9958200.0001
Mysql Total
Database connection0.00130.900010.0013
Mysqli_queries0.104870.52561410.0007
Looping result0.00140.94141390.0000
Template Total0.135791.410.1357
Template load0.00070.479210.0007
Template processing0.134990.793910.1349
Override
Cache load0.00050.315010.0005
Sytem overhead
Fetch class attribute can translate value0.00100.666310.0010
XML
Image XML parsing0.00030.199310.0003
General
dbfile0.00191.2624200.0001
String conversion0.00000.008030.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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