Liquid Fire Posted February 27, 2007 Share Posted February 27, 2007 I have been told that i should using php to create "widgets" instead of using string html/css and was thinking maybe it a good idea. I was think that i could create a class called CMenu and then when i wanted to add a menu to the site i would just do something like this: $new_menu = new CMenu(); $new_menu->AddLink("www.phpfreaks.com", "PHP Freaks Website"); $new_menu->AddLink("www.phpfreaks.com", "PHP Freaks Website"); $new_menu->AddLink("www.phpfreaks.com", "PHP Freaks Website"); $new_menu->AddLink("www.phpfreaks.com", "PHP Freaks Website"); $new_menu2 = new CMenu(); $new_menu->AddText("PHP Freaks Website is cool"); now does nayone know of any tutorials or examples of doing this type of things? Link to comment https://forums.phpfreaks.com/topic/40359-using-php-to-create-html-widgets/ Share on other sites More sharing options...
ShogunWarrior Posted February 27, 2007 Share Posted February 27, 2007 Just look up classes, here's an example of how you would implement your first menu class: <?php class Cmenu { var $links = array(); function Cmenu() {} function AddLink($url,$title) { $this->links[] = array($url,$title); } function display() { echo '<ul>'; foreach( $this->links as $link ) { echo '<li> <a href="'.$link[0].'" title="'.$title[1].'">'.$link[1].'</a> </li>' . "\n"; } echo '</ul>'; } } $new_menu->display(); would show the menu. Link to comment https://forums.phpfreaks.com/topic/40359-using-php-to-create-html-widgets/#findComment-195310 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.