News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
How to Tidy Your WordPress Menu HTML
January 26, 2011 @ 09:37:59

On the SitePoint PHP blog today there's a new post from Craig Buckler for the WordPress users out there. The HTML that this popular blog/CMS tools spits out can sometimes be not-so-semantic. Craig shares a tip on cleaning up one aspect of it - the methods returning lists for menus or sitemaps.

love WordPress. I also love clean semantic HTML. Unfortunately, several of the standard WordPress theme functions return code that is a little untidy. For me, the primary culprits are wp_list_pages() and the newer wp_nav_menu(); both return an unordered list of page links.

He gives an example of a sample list generated by wp_nav_menu() that's full of badly formatted and unnecessary elements. To help fix the issue, he shares his regular expression-based call to strip out things like extra tabs, empty classes and all title attributes. Obviously you can customize this as you need, but it's a good start towards something that's a bit cleaner and up to code.

0 comments voice your opinion now!
wordpress tidy html output pregreplace regularexpression menu


PHPro.org:
Dynamically Create Menu With PHP DOM
July 20, 2009 @ 10:50:52

New from Kevin Waterson on the PHPro.org site is this tutorial looking at dynamically making a website menu with PHP's DOM functionality.

Most PHP coders will have their own menu generation class that will take an array or an item and add it to a HTML un-ordered list or other tag and the styling is handled with CSS. This has proven to be a worthy solution to menu creation, however, PHP already has all the tools and classes built in to create a menu using DOM. It is both powerful and extensible and further eliminates for yet another class in your tree.

The tutorial shows you how to create a simple XML document to define the menu using the DOM functionality in PHP and finally output it as a series of unordered lists that can be styled in whatever way you want.

0 comments voice your opinion now!
xml dom menu dynamic


Tiffany Brown's Blog:
Turn text files into pull down menus
February 27, 2008 @ 09:35:00

Tiffany Brown shares a quick function she whipped up to create dropdown menus from the contents of a newline separated text file (or files).

I developed this PHP function for a project I'm working on. I'm posting it here in case I need it again, or in case you find it handy.

The function turns each line into an option tag making defining custom menus based on the contents of dynamically-given text files easy.

This could also be easily adapted to create navigations menus at the top of your pages with a few modifications to the HTML tags being used and some CSS to change the look of the list.

0 comments voice your opinion now!
text file dropdown menu form element navigation css


Arnold Daniels' Blog:
How I PHP The Output Handler - Continued
December 07, 2007 @ 09:32:00

Continuing on from his previous post on output handling, Arnold Daniels shows how to build on the previous setup and add the ability to include dynamic data into the template.

For instance, it would be nice if the data in the left column, 'Beauty Tips', could be different for each page. There are several ways to solve this, but for know I will choose the simplest.

He takes a few steps to make adding the content simple:

  • Adding markers for the title and left menu to the template
  • Change the OutputHandler class to make it less static
  • use setData() to title the page
  • user setData() to add left column content
  • Use mark() and endmark() to section off a part of the template.

He's provided a demo and made the source code available for download.

1 comment voice your opinion now!
output handler dynamic content title menu output handler dynamic content title menu


Felix Geisendorfer's Blog:
MacGyver menu for CakePHP - What's the active menu item?
July 09, 2007 @ 09:34:00

In a new post to his blog today, Felix Geisendorfer talks about view coding - specifically working with a menu and determining which element is active.

One of the challenges many of us have faced before and will face in future is building a menu. Now this of course is very simple assuming that we're just shooting for a static <ul> with some <li>'s containing the links. However the tricky part is to figure out what is the active menu item. I had some code doing this in the past but tried out a new flavor of it today which I call the MacGyver menu for CakePHP as it's a little dirty yet powerful and easy to maintain.

In his included code, he creates a simple navigation from an array of titles/links and, with some sorting, a regular expression and a CSS class, the selected item can be highlighted simply.

0 comments voice your opinion now!
cakephp framework navigation highlight active menu cakephp framework navigation highlight active menu


PHP-GTK Community Site:
Extending GtkMenu class for Popup menu dialog
March 23, 2007 @ 11:38:00

On the PHP-GTK Community site today, there's a "quick hit" post for extending a GtkMenu object in a PHP-GTK application to create a popup menu dialog.

Here is a quick way to build a popup menu supporting event registration from a GtkWidget. Menu items are passed to the class constructor as a list of labels. This class emits activate signals with full context (x,y coordinates, button ...).

There's the list of the steps that the code will follow and the two code chunks that will make it happen - the sample PHP-GTK app and the class file that handles the menu creation.

1 comment voice your opinion now!
phpgtk tutorial gtkmenu popup menu dialog phpgtk tutorial gtkmenu popup menu dialog


Richard Heyes' Blog:
PHP Console Class
January 09, 2006 @ 06:51:35

On his blog today, Richard Heyes notes that he's created a new class that combines some of the most common console-script functionality into once place - Console.

Just added a new class called Console, which wraps up some common Console script related functionality. All the methods are static, and it's PHP5 only. Methods include:

  • Console::Pause()
  • Console::BooleanQuestion()
  • Console::ClearScreen()
  • Console::GetLine()
  • Console::ShowMenu()

You can grab a copy of the class here as well as an example of its usage, showing how to build a menu and have the user input their information...

0 comments voice your opinion now!
console class build menu booleanQuestion getLine clearScreen console class build menu booleanQuestion getLine clearScreen



Community Events





Don't see your event here?
Let us know!


list zendserver opinion series laravel install framework release package library community introduction deployment language podcast api interview update tips symfony

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework