Cms snippet - smarty vars

ich habe ein snippet, das ich als teil von navi nutzen

eg

<h3><a href=“Uber-Uns/”>Über Uns</a></h3>
<ul>
<li><a href=“Kontakt/”>Kontakt mit Wegbeschreibung</a></li>
</ul>

was ich will ist wenn auf die seiten, die css current haben.
Im nav tpl habe ich

[{if $oContent-&gt;oxcontents__oxtitle-&gt;value == 'Ansprechpartner' || $oContent-&gt;oxcontents__oxtitle-&gt;value == 'Vertriebspartner' }]

…so weit so gut, aber

Habe folgendes probiert, im nav tpl

[{assign var=“classcur” value=‘class=“current”’}]

und dann in cms snippit

<h3><a [{$classcur}] href=“Uber-Uns/”>Über Uns</a></h3>

funktioniert nicht, classcur ist gesetzt, aber nicht in die cms snippet.

auch probiert in nav tpl

[{oxcontent ident=mynav}]
[{oxcontent ident=mynav|replace:‘<!–spoon–>’:$classcur }]

geht nicht

[{assign var=“heremynav” oxcontent ident=mynav}]
[{heremynav|replace:‘<!–spoon–>’:$classcur }]

geht auch nicht.

Es ist bestimmt einfach, aber ich komme nicht drauf.
bitte um hilfe !

ich verstehe es ehrlich gesagt nicht, wäre englisch einfacher für dich?

lol ja :slight_smile:

have a cms snippet in the top navigation, when on one of these pages i would like to set the css class current.
In the navigation template, i can tell when i am on one of my cms pages, what i need to do is pass the css smarty variable to my snippet. The question is how?
If in the nav template i set

[{assign var=“classcur” value=‘class=“current”’}]

It does not appear in the cms snippet (wird nicht ersetzt)

<h3><a [{$classcur}] href=“Uber-Uns/”>Über Uns</a></h3>

included so

[{oxcontent ident=mynav}]

okay, thats the way i manage it:

when you are on a cms page, e.g. Impressum, it returns and renders the azure/tpl/page&info/content.tpl Tempalte
there you can find this code:


[{assign var="oContent" value=$oView->getContent()}]

and because the all other teplates are (they should be!) rendered after this one, they can use $oContent, too.

so somewhere in the navigation you can use the link to the cms page


[{ oxifcontent ident="oximpressum" type="oCont" }]
<li>
<a href="[{ $oCont->getLink() }]" [{if $oView->getClassName()=='content' && $oContent->oxcontents__oxtitle->value==$oCont->oxcontents__oxtitle->value }]class="current"[{/if}] rel="nofollow">[{ $oCont->oxcontents__oxtitle->value|upper }]</a>
</li>
[{/oxifcontent}]

cause the cms page you wants to link to is loaded into $oCont and the actual page you are on in $oContent, you can check if the title of them both are equal. You can also check on idents or oxid, I#m not sure why i did use the title for this purpose.

no not quite what i mean.

In my cms snippet, smarty is not parsed (or php).
Create a manual piece of cms - write the following
[{assign var=“classcur” value=‘test"’}]
[{$classcur}]
<?php echo “test2”; ?>

and when you include this anywhere, nothing is shown?

…another way round it, would be search and replace.
But how do i get this [{oxcontent ident=bartelsnav}] into a smarty variable ?
I tried this
[{assign var=“newtest” value=‘oxcontent ident=bartelsnav’}]
but it does not work

then im still not sure what do you try to reach with this class=“current”

by default php will be ignored when trying to use it in cms pages or teplates, you have to switch it on (in backend)

and you should use smarty tags for php: [{php}] … [{/php}]

anyway, have you heard about oop?

[{oxcontent ident=mynav}]
[{oxcontent ident=mynav|replace:'<!--spoon-->':$classcur }]

all the stuff you tried is kind of black magic

have a look inside the oxcontent function to see which parameter it supports. you will find a hint how to assign it to a variable
core/smarty/plugins/function.oxcontent.php

Hat sich erledigt
got it sorted.
now have in the cms snippet

<li class=“mzr-drop”><a curclass href=“Uber-Uns/”>Über Uns</a>

and then in the navigation template

[{if $oContent->oxcontents__oxtitle->value == ‘Über Uns’}]
[{assign var=“classcur” value=‘class=“current”’}]
[{capture name=“mynav”}]
[{oxcontent ident=bartelsnav}]
[{/capture}]
[{assign var=“shownav” value=$smarty.capture.mynav}]
[{$shownav|replace:‘curclass’:$classcur}]
[{else}]
[{$shownav|replace:‘curclass’:‘’}]
[{oxcontent ident=bartelsnav}]
[{/if}]

which works perfectly, and can easily be expanded for a sub nav too

…might be an easier way to do it, but at least this works