wayfinder printing class as content in accordion - php

I had an old template and I updated MODX core and extras from 2.2 to 2.6.5.
After the update the output has become very strange.
here's my code for accordion:
<li [[+wf.classes]]>
[[+wf.classnames:contains=`livello2`:eq=`livello2`:then=`<a class="goto_scheda" title="[[+wf.pagetitle]]">[[%cat.vai_scheda? &topic=`catalogo` &namespace=`plastitalia`]]</a>`:else=``]]
<a [[+wf.classnames:contains=`livello1`:eq=`livello1`:then=`class="link_tassonomia"`:else=``]] href="[[+wf.link]]" title="[[+wf.pagetitle]]">[[+wf.pagetitle]]</a>
[[+wf.wrapper]]
</li>
and this is the output:
<ul class="sottomenu_catalogo">
<li class="first livello2">
first livello2
<a first="" livello2="" href="/catalogo/packaging/category/product-ml-50" title="Product ml 50">Product ml 50</a>
</li>
<li class="livello2">
livello2
<a livello2="" href="/catalogo/packaging/category/product-ml-80" title="Product ml 80">Product ml 80</a>
</li>
</ul>
Is there someone that has some idea about how to fix this?

I was missing the :or operator so, for some strange reason wayfinder was printing the condition as class.
<li [[+wf.classes]]>
[[+wf.classnames:contains=`livello2`:or:eq=`livello2`:then=`<a class="goto_scheda" title="[[+wf.pagetitle]]">[[%cat.vai_scheda? &topic=`catalogo` &namespace=`plastitalia`]]</a>`:else=``]]
<a [[+wf.classnames:contains=`livello1`:or:eq=`livello1`:then=`class="link_tassonomia"`:else=``]] href="[[+wf.link]]" title="[[+wf.pagetitle]]">[[+wf.pagetitle]]</a>
[[+wf.wrapper]]
</li>

Related

Adding a classy or ID to the prestashop module

I start the adventure with prestashop and I would like to have a problem. I have no idea how to add a classe or ID to the module.
My code is:
<h3>Mini Top Menu</h3>
<ul>
<li>
<a id="link-cms-page-1-3" class="cms-page-link" href=""link1 title="link1">
</a>
</li>
<li>
<a id="link-cms-page-4-3" class="cms-page-link" href="link1" title="link1">
</a>
</li>
<li>
<a id="link-cms-page-5-3" class="cms-page-link" href="link1" title="link1">
</a>
</li>
<li>
<a id="link-product-page-prices-drop-3" class="cms-page-link" href="link1" title="link1">
</a>
</li>
</ul>
I would like to add this <ul> ID and get rid of the <h3> tag
I will add that I use Link Widget.
If I got it right:
You have to search for (menu) module on your theme folder to find .tpl files:
"themes/yourTheme/modules/TargetModule/*.tpl"
if this path not exist then you have to search on "modules/TargetModule/templates/...." to find your file.
Tip: don't forget to clear both PrestaShop and browser cache, after any change on tpls

How to add dropdown CSS class to menus with children in Drupal 7? (without modules)

How can I create a function to scan all menu items from Drupal 7 system and if there is a nested ul, add dropdown CSS classes to the nested ul and add a custom attribute to the parent li container? Im using UIKIT which will automatically create the dropdowns.
Here's my current menu HTML output:
<ul class="menu">
<li class="first last expanded">
<a title="" href="/node/add">Add content</a>
<ul class="menu">
<li class="first leaf">
<a title="article" href="/node/add/article">Article</a></li>
<li class="leaf">
<a title="page" href="/node/add/page">Basic page</a></li>
<li class="last leaf"><a title="blog" href="/node/add/blog">Blog entry</a></li>
</ul>
</li>
</ul>
Here's what I need it to be:
<ul class="menu">
<li class="first last expanded" data-uk-dropdown>
<a title="" href="/node/add">Add content</a>
<ul class="menu uk-dropdown">
<li class="first leaf">
<a title="article" href="/node/add/article">Article</a></li>
<li class="leaf">
<a title="page" href="/node/add/page">Basic page</a></li>
<li class="last leaf"><a title="blog" href="/node/add/blog">Blog entry</a></li>
</ul>
</li>
</ul>
Im looking for the simplest approach possible.
You can crawl menu tree your self and write out menu HTML as you like. Used that and should be something like:
$tree = menu_tree_all_data('menu_machine_name');
Also, if I remember well, if you do only that your active (current) menu item won't be marked any way, and for marking it you have to also call (after getting $tree variable) :
menu_tree_add_active_path($tree);
But again, if I remember well, that function is only available if you install "Menu block" module...
Print out $tree variable after that and organize your code to crawl recursively menu tree you collected.

Catch the URL and redirect somewhere else

i ve done this below menu in php which is autogenerated with a function :
As you know, if i click on "Red Chicken", it will try to open a ../Red%20Chicken URL, which doesnt exist till it comes from a big table which change everytime.
What i want to do is : to know where we clicked (example : by generating the url and cut it ) and then redirect to a page like result.php (+ get something like the variable to know where do we come from). And of course, i don't want to create a .php page for each element of my table.
Is this thing possible ?
EDIT : i found a way, it's to change my function and how it generates the menu.
Not really what i wanted but it's okay.
<ul class=\"niveau1\">
<li class=\"sousmenu\"><a href=\"Food\">Food</li>
<ul class=\"niveau2\">
<li class=\"sousmenu\">Meat</li>
<ul class=\"niveau3\">
<li class=\"sousmenu\">Poultry</li>
<ul class=\"niveau4\">
<li class=\"sousmenu\">Red Chicken</li>
</ul>
</ul>
<ul class=\"niveau3\">
<li class=\"sousmenu\">Beef</li>
<ul class=\"niveau4\">
<li class=\"sousmenu\">Hamburgers</li>
</ul>
<ul class=\"niveau4\">
<li class=\"sousmenu\">Steak</li>
</ul>
</ul>
</ul>
<ul class=\"niveau2\">
<li class=\"sousmenu\">Dairy</li>
<ul class=\"niveau3\">
<li class=\"sousmenu\">Cow</li>
</ul>
<ul class=\"niveau3\">
<li class=\"sousmenu\">Sheep</li>
</ul>
</ul>
</ul>
<ul class=\"niveau1\">
<li class=\"sousmenu\">name</li>
</ul>
http://jsfiddle.net/w10j0a38/1/
The PHP-Way would probably be to use URLs like <a href='menuhandler.php?sel=cow'>Cow</a>, and if you want to be lazy, you could also JS/jquery to manupulate the URLs and replace <a href="something">with a call in the style shown before - but then this would not work w/o JS, so it is not a real option IMHO.
changed my function to generate it in another way
<a href=\"Recette.php?var=food\">
Not really what i wanted but it's okay.

Fatal error: Class 'Zend_Locale' not found

I'm developing a web app with Zend Framework 2.
I want to achieve urls with current locale automatically built-in, i.e. /locale/controller/action/etc. I wrote this:
<?php
$locale = new Zend_Locale();
?>
<ul class="nav">
<li>
Devices
<ul>
<li>
<img src="img/navbar/add.png" alt="+"> Add
</li>
</ul>
</li>
<li>
Favorites
<ul>
<li>
<img src="img/navbar/add.png" alt="+"> Add
</li>
</ul>
</li>
</ul>
and put it in a navbar.phtml file that i include in this way
include("navbar.phtml");
in my Application/view/layout/layout.phtml.
But, i only get this
Fatal error: Class 'Zend_Locale' not found in blabla\module\Application\view\layout\navbar.phtml on line 3
What's wrong? I forget some "use"? Sorry but i'm a newbie in php.
Installation of PHP intl extension is must.
Ok, i just resolved.
The code above is relative to the older version of Zend Framework.
In Zend Framework 2 the right code is this:
<?php
$translator = new Zend\I18n\Translator\Translator();
$locale = substr($translator->getLocale(), 0, 2);
?>
<ul class="nav">
<li>
Devices
<ul>
<li>
<img src="img/navbar/add.png" alt="+"> Add
</li>
</ul>
</li>
<li>
Favorites
<ul>
<li>
<img src="img/navbar/add.png" alt="+"> Add
</li>
</ul>
</li>
</ul>
And don't forget to enable intl PHP extension!

keeping active page using include_once to include site navigation

Another, what could be a silly, question. I have a very in-depth navigation menu on my clients site. I don't mind doing the hard slog now changing all the pages and links to .php - will save mucho time in the future. I want to use <?php include_once("nav.php"); ?> to pull this into every page. At the moment the parent item that is active will be highlighted depending on which child page is being viewed. The menu structure is currently just part of each of the .html page.
HTML markup:
<div id="navigation-wrapper">
<nav id="main-navigation">
<ul class="main-menu">
<li><span aria-hidden="true" class="li_display nav_icon"></span>About
<ul>
<li>Corporate Profile</li>
<li>Board of Directors</li>
<li>Operating Divisions</li>
<li>Organisational Chart</li>
<li>Corporate Documentation</li>
</ul>
</li>
<li><span aria-hidden="true" class="li_news nav_icon"></span>Investor
<ul>
<li>Overview</li>
<li>Financial</li>
<li>News</li>
<li>Events</li>
<li>General</li>
<li>Register for Alerts</li>
</ul>
</li>
<li><span aria-hidden="true" class="li_bulb nav_icon"></span>Products
<ul>
<li>Mecer</li>
<li>Hardware
<ul>
<li>APC</li>
<li>Acer</li>
<li>ASUS</li>
<li>E-Beam</li>
<li>Fujitsu</li>
<li>Huawei</li>
<li>Lenovo</li>
<li>Microsoft</li>
<li>NEC</li>
<li>Samsung</li>
<li>Toshiba</li>
</ul>
</li>`enter code here`
<li>Mustek Energy
<ul>
<li>Solar Panels</li>
<li>LED Lighting Solutions</li>
</ul>
</li>
<li>Mustek Solutions
<ul>
<li>Mustek Cloud Computing</li>
<li>Mustek Digital Signage</li>
<li>Mustek POS Solutions</li>
<li>Mustek Security Technology</li>
</ul>
</li>
<li>Networking Solutions
<ul>
<li>D-Link</li>
<li>Huawei</li>
<li>Miniflex</li>
<li>NEC</li>
<li>NComputing</li>
</ul>
</li>
<li>Printing Solutions
<ul>
<li>Brother</li>
<li>Epson</li>
</ul>
</li>
<li>Complete Product Catalogue</li>
</ul>
</li>
<li><span aria-hidden="true" class="li_settings nav_icon"></span>Support
<ul>
<li>DealerNet</li>
<li>Dealer Application Form</li>
<li>Dealer Locator</li>
<li><a href="http://downloadcenter.mustek.co.za/list.php?dir=Repository" target=_blank>Download Latest Drivers</a></li>
<li>Mecer EyeSPY</li>
</ul>
</li>
<li><span aria-hidden="true" class="li_phone nav_icon"></span>Contact
<ul>
<li>Branches</li>
<li>Customer Liaison</li>
<li>Investors</li>
<li>Sales Queries</li>
<li>Technical Queries</li>
<li>Careers</li>
</ul>
</li>
</ul>
</nav>
</div>
As you can see the class="active-page" dictates which parent icon to show. I read somewhere that by adding <?php $page = "page-name"; ?> it will say which page this is and will act like the class="active-page". Do I need to create an id for the page in the nav.php file that it will reference?
Sorry guys, but my knowledge of PHP is very limited, but I am trying to learn the basics on the fly. Any help is greatly appreciated!
Just use an if-statement to add "active-page" as class to the current active page:
<li><span aria-hidden="true" class="li_display nav_icon"></span>About
You then need to define a constant ACTIVE_PAGE before including your navigation.
<?php
define ('ACTIVE_PAGE', "About");
include ('yournav.php');
?>
This should work and is okay if you do not have too many pages.
An alternative could be in getting the currently visited page via
$_SERVER['PHP_SELF']
and then add to navigation.php which html-file shall be called for which entry in php_self. The advantage would be that you have all your navigation-based code in one place. Personally, I would prefer this last solution.

Categories