Click here to Skip to main content
15,914,074 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
QuestionMYSQL to XML using PHP Pin
wolf7777726-Aug-13 22:27
wolf7777726-Aug-13 22:27 
QuestionUsing .net webservice data in php Pin
Andile.M20-Aug-13 0:35
Andile.M20-Aug-13 0:35 
QuestionIntitialize a session variable after onclick event is fired Pin
pandu web dev11-Aug-13 23:16
pandu web dev11-Aug-13 23:16 
AnswerRe: Intitialize a session variable after onclick event is fired Pin
Kaivan Alimohammadi23-Aug-13 10:25
Kaivan Alimohammadi23-Aug-13 10:25 
GeneralRe: Intitialize a session variable after onclick event is fired Pin
pandu web dev26-Aug-13 3:28
pandu web dev26-Aug-13 3:28 
QuestionContact form - Bootstrap Error Validation Pin
bigcdh4-Aug-13 8:13
bigcdh4-Aug-13 8:13 
AnswerRe: Contact form - Bootstrap Error Validation Pin
Peter_in_27808-Aug-13 15:42
professionalPeter_in_27808-Aug-13 15:42 
AnswerRe: Contact form - Bootstrap Error Validation Pin
vbmike23-Aug-13 9:12
vbmike23-Aug-13 9:12 
GeneralRe: Contact form - Bootstrap Error Validation Pin
bigcdh23-Aug-13 9:22
bigcdh23-Aug-13 9:22 
QuestionPHP find all occurrences of string in file Pin
MicahC5-Jul-13 6:44
MicahC5-Jul-13 6:44 
AnswerRe: PHP find all occurrences of string in file Pin
Graham Breach5-Jul-13 21:20
Graham Breach5-Jul-13 21:20 
GeneralRe: PHP find all occurrences of string in file Pin
MicahC7-Jul-13 19:52
MicahC7-Jul-13 19:52 
GeneralRe: PHP find all occurrences of string in file Pin
MicahC10-Jul-13 5:56
MicahC10-Jul-13 5:56 
QuestionNot much traffic here is there..... Pin
Erudite_Eric16-Jun-13 23:40
Erudite_Eric16-Jun-13 23:40 
AnswerRe: Not much traffic here is there..... Pin
Ali Al Omairi(Abu AlHassan)7-Jul-13 22:18
professionalAli Al Omairi(Abu AlHassan)7-Jul-13 22:18 
QuestionCounting Menu Items & Determining If First/Last Pin
NickBogi7-Jun-13 13:20
NickBogi7-Jun-13 13:20 
AnswerGot It Working Pin
NickBogi10-Jun-13 8:29
NickBogi10-Jun-13 8:29 
I couldn't figure it out except I knew that there must be some native wordpress functionality I could use with wp_nav_menu so I created this code and it works well to have wordpress count and mark first/last (excluding child items for last) with an added function and filter.

Seems to work well. Here it is for anyone else with a similar problem:

PHP
// set first/last class 
function nb_first_last_menu_class( $objects, $args ) { 
     // set first/last class for submenu 
    $ids        = array(); 
    $parent_ids = array(); 
    $top_ids    = array(); 
    foreach ( $objects as $i => $object ) { 
        // If no parent, store the ID, skip object 
        if ( 0 == $object->menu_item_parent ) { 
            $top_ids[$i] = $object; 
            continue; 
        } 
        // don't set first class for submenu 
        if ( ! in_array( $object->menu_item_parent, $ids ) ) { 
            $objects[$i]->classes[] = ''; 
            $ids[]          = $object->menu_item_parent; 
        } 
         // If we didn't set first class for submenu, skip adding the ID 
        if ( in_array( '', $object->classes ) ) 
            continue; 
         // Store the menu parent IDs in an array 
        $parent_ids[$i] = $object->menu_item_parent; 
    } 
    // Remove dup values and pull out last menu item 
    $sanitized_parent_ids = array_unique( array_reverse( $parent_ids, true ) ); 
    // Loop IDs, set last class to the appropriate objects 
    foreach ( $sanitized_parent_ids as $i => $id ) 
        $objects[$i]->classes[] = 'last'; 
    // set classes for top level menu items 
    $objects[1]->classes[] = 'first';  
    $objects[end( array_keys( $top_ids ) )]->classes[] = 'last'; 
    return $objects; 
} 
add_filter( 'wp_nav_menu_objects', 'nb_first_last_menu_class', 10, 2 );

QuestionUrgent !!! Looking for the best solution Pin
MacAriel15-May-13 8:43
MacAriel15-May-13 8:43 
AnswerRe: Urgent !!! Looking for the best solution Pin
herlon21423-Jul-13 9:59
herlon21423-Jul-13 9:59 
QuestionVideo Gallery for wordpress site. Pin
Neha Pandal12-May-13 10:03
professionalNeha Pandal12-May-13 10:03 
AnswerRe: Video Gallery for wordpress site. Pin
Archie22is30-Jun-13 21:07
Archie22is30-Jun-13 21:07 
Questionhow to store QR Code image in mysql with php Pin
blertaaa2-May-13 22:43
blertaaa2-May-13 22:43 
AnswerRe: how to store QR Code image in mysql with php Pin
Prasad Khandekar21-May-13 4:56
professionalPrasad Khandekar21-May-13 4:56 
AnswerRe: how to store QR Code image in mysql with php Pin
Resalat Haque Prodhan27-Jun-13 2:02
Resalat Haque Prodhan27-Jun-13 2:02 
AnswerRe: how to store QR Code image in mysql with php Pin
Rony Sur2-Jul-13 0:04
professionalRony Sur2-Jul-13 0:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.