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!
Related
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>
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.
It is possible to create an IF query for the tag in SPIP?
When i have only one article linked to the tag than he take me directly to the article. But if i have more than 1 article, than he does taken me to the tag page of spip, where are the listing of the linked article.
Here the code to go directly to the article
<div id="tagsphere-#ENV{id_article}">
<ul>
<BOUCLE_mot(MOTS){id_groupe ?}>
<B_article>
<li>
<a<BOUCLE_article(ARTICLES){id_mot = #ID_MOT}{0, 1}> href="#URL_ARTICLE"</BOUCLE_article>>
#TITRE
</a>
</li>
</B_article>
</BOUCLE_mot>
</ul>
</div>
and here the code to go to the tag menu
<div id="tagsphere-#ENV{id_article}">
<ul>
<BOUCLE_mot(MOTS){id_groupe ?}>
<li>[(#TITRE)]</li>
</BOUCLE_mot>
</ul>
</div>
Thanks in advance
Try this, will work with any SPIP version.
<BOUCLE_mot(MOTS){id_groupe ?}>
[(#REM) Link to mot]
<BOUCLE_check(ARTICLES) {id_mot} {1,1}>
<li>#_mot:TITRE</li>
[(#ID_ARTICLE|oui)]
</BOUCLE_check>
[(#REM) Link to one article]
<BOUCLE_one(ARTICLES) {id_mot} {0,1}>
<li>#_mot:TITRE</li>
</BOUCLE_one>
<//BOUCLE_check>
</BOUCLE_mot>
Conditional display is a real lack in SPIP. This is what I would do (don't have any SPIP environment with me to check).
<div id="tagsphere-#ENV{id_article}">
<ul>
<BOUCLE_mot(MOTS){id_groupe ?}>
<BOUCLE_articles(ARTICLES){id_mot = #ID_MOT}>
<B_article_unique>
<li>
<a<BOUCLE_article_unique(ARTICLES){id_article}{si #TOTAL_BOUCLE|==1}> href="#URL_ARTICLE"</BOUCLE_article_multiple>>
#TITRE
</a>
</li>
</B_article_unique>
<BOUCLE_article_multiple(ARTICLES){id_article}{si #TOTAL_BOUCLE|!=1} />
<li>
<a href="#URL_MOT">
#TITRE
</a>
</li>
</B_article_muliple>
</BOUCLE_articles>
</BOUCLE_mot>
</ul>
</div>
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.
I'm trying to build a kiosk on a local machine, so no online requirement. I am going to build a big menu which will show exhibition stores and products. Due to the stores and products will always change, the client has requested to use a simple text file - .txt to populate the menu.
I used jQuery last week but unfortunately it didn't work. So after searching I've decided to use php instead. I'm new to php, but I have given it a try today, I have only managed to populate one list with the external file kate.txt
Here is my code for the page
<body>
<ul class="sf-menu">
<li class="current">
Area1
<ul>
<li class="current">
Kate
<ul>
<?php
//variables
$dir = "C:\wamp\www\Menu";
$txtfile="Textfiles\kate.txt";
foreach (glob("$txtfile") as $filename) {
$file = $filename;
$contents = file($file);
$string = implode("<li>", $contents);
}
?>
<li><?php echo $string ?></li>
</ul>
</li>
<li>
Cathy
<ul>
<li>Banana</li>
<li>Apple</li>
</ul>
</li>
</ul>
</li>
<li>
Area2
<ul>
<li>
lily
<ul>
<li>Watermelon</li>
<li>Grapefruit</li>
</ul>
</li>
<li>
John
<ul>
<li>Orange</li>
<li>Pineapple</li>
</ul>
</li>
</ul>
</li> <!--current-->
</ul> <!--sf-menu-->
</body>
Can someone please give me some direction on the php code? I don't mind how the text files are structured in a folder, as long as I can populate all the menu list items and links with a text file or multiple text files not in the html code.
Assuming that your text file holds all your list items
kate.txt:
<li>stuff</li>
<li>stuff</li>
...
the php file
<?php
$txtfile="Textfiles\kate.txt";
$content = file_get_contents($txtfile);
<li class="current">
Kate
<ul>
<?php echo $content ?>
</ul>
</li>