Forums / Setup & design / Dynamic Body ID

Dynamic Body ID

Author Message

Nathan Kelly

Thursday 12 May 2005 4:58:04 pm

Hi there,
I have searched the forums pretty extensively for the past 2 days looking for an answer to my problem (the first of many I imagine) but with no success, though maybe if I was a little more familiar with the EZsyntax I may have seen the answer in my travels.

Quite simply I need to be able to dynamically pull the body id from the current page URI, the reason for this is my menu is constructed with some very complex CSS to achieve the look I need.

So far I have found that I am able to pull the node name into the id="" but the problem with this is that some of my pages have more than one word in the name; for example the output would look like this-

<body id="about us">

    <div id="navigation">
    ....
    contents
    ....
    </div>

</body>

This is not much good to me for the obvious reason that CSS selectors are useless with a space in them. So I noticed EzP inserts a "_" into the spaces when cleaning up the URI therefore the page URI is the ideal element for an ID.

<body id="about_us">

    <div id="navigation">
    ....
    contents
    ....
    </div>

</body>

I have tried many different variations of the following code but to no avail, the best I have managed is something like "products/mens_wear", and extracting a portion of the name is no good because my top level navigation is so varied for example-
Products | About Us | Members Login etc...

{section loop=$node.path_array offset=2}
{let page_name=fetch( content, node, hash( node_id, $item ) )}
{run-once}
<body id="{$page_name.name}">
{/run-once}
{/let}
{/section}

The main problem I am having is that the offset dose not seem to be relative to the actual node I am viewing if that makes any sense, so if I was to navigate to "Products/mens_wear" the node name would still be "products" not "mens_wear".

I hope I have made this clear if not please let me know and I will try to be more descriptive.

Any help is very much appreciated thankyou for your time.

Pardon me while I burst into flames...

Nathan Kelly

Thursday 12 May 2005 5:05:34 pm

Oh one more thing, this code seems to do the same thing-

{let page_name=fetch( content, node, hash( node_id, $module_result.node_id ) )}

<body id="{$page_name.url_alias}">
{/let}

As I said I am not very familiar with the syntax so I really have no idea what the difference is with these 2 snippets.

cheers.

Pardon me while I burst into flames...

Xavier Dutoit

Friday 13 May 2005 12:50:24 am

Hi,

I'd suggest not to use the url_alias on the css (they can be modified by the user, but the node id

eg <div id="node_{$node.node_id}">

would produce id="node_2"

X+

http://www.sydesy.com

Nathan Kelly

Friday 13 May 2005 1:16:53 am

Thanks for your reply Xavier,

I had originally intended to use the node id but I was unsure if this would be the best way, and now that you mention it, it seems more logical as I hadn't considered the lack of persistence in the url_alias.

On that note just for my own clarification, is the node id persistent, that is will it ever change and if so what action would likely do so?

Cheers!

Pardon me while I burst into flames...

Roy Bøhmer

Friday 13 May 2005 5:32:00 am

The node-id is persistent, BUT an article can exist on several different places in the node-tree and therefore have several different node-ids.

A scenario could be that you
1)Publish an article with node-id=100.
2)Make a co-location of the same article, and now have node_id=100 AND node-id=200.
3)Then you make node-id=200 the primary node, and delete the node-id=100.
Now you only have node-id=200. If you use node-id in the url it will seems like the article has changed node-id.

Object-id on the other hand will be persistent.

Roy

Nathan Kelly

Sunday 15 May 2005 5:25:05 pm

Ok, thanks for that info Roy that clears up my main question for now but I'm sure I will have plenty more to come yet ;).

Cheers.

Pardon me while I burst into flames...

eZ debug

Timing: Jan 19 2025 03:43:15
Script start
Timing: Jan 19 2025 03:43:15
Module start 'content'
Timing: Jan 19 2025 03:43:17
Module end 'content'
Timing: Jan 19 2025 03:43:17
Script end

Main resources:

Total runtime1.7924 sec
Peak memory usage4,096.0000 KB
Database Queries205

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0083 588.8438180.8516
Module start 'content' 0.00831.5824 769.6953624.4922
Module end 'content' 1.59060.2016 1,394.1875341.0938
Script end 1.7923  1,735.2813 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00470.2602210.0002
Check MTime0.00160.0911210.0001
Mysql Total
Database connection0.00080.046310.0008
Mysqli_queries1.696594.65292050.0083
Looping result0.00270.14982030.0000
Template Total1.748197.520.8741
Template load0.00220.120020.0011
Template processing1.746097.412420.8730
Template load and register function0.00010.005910.0001
states
state_id_array0.00230.127010.0023
state_identifier_array0.00250.139020.0012
Override
Cache load0.00190.1048490.0000
Sytem overhead
Fetch class attribute can translate value0.00140.076940.0003
Fetch class attribute name0.00130.074980.0002
XML
Image XML parsing0.00130.071640.0003
class_abstraction
Instantiating content class attribute0.00000.0015110.0000
General
dbfile0.00720.4011330.0002
String conversion0.00000.000430.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
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 31
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs