Mys 1.3.6 Menu & Sidebar Icons (with AdminCP support)

Forum
Last Post
Threads / Messages

KittHaven

Member
Member
Joined
May 21, 2013
Messages
478
Points
28
Age
25
Location
Devon, UK
Mysidian Dollar
8,292
Hey, here's a tutorial on how to add icons to the default menu with adminCP support for both the image and icon width.

0. First we want to setup the database, so open your PHPMyAdmin and go to adopts_links. We want to add 2 new columns to the table. Go to 'Structure' and at the bottom choose to add 2 new columns after 'linktext'

2024-03-24 04_39_47-localhost _ MySQL _ mysidia1.3.6 _ adopts_links _ phpMyAdmin 5.2.1 - Opera.png
Fill in the information like this:
2024-03-24 04_40_12-localhost _ MySQL _ mysidia1.3.6 _ adopts_links _ phpMyAdmin 5.2.1 - Opera.png

This will allow you to put the image url and decide the width for each icon. By default I have the icon width as 64px but that might be too big for you so feel free to change it. I found that something like 25px is a decent size.

Make sure to press Save when you're done to submit the new columns.

1. Next we'll set up the AdminCP part so you can change and add new link icons easily. Find and open model/domainmodel/link.php.

At the top, add:

PHP:
    protected $linkicon;
    protected $iconwidth;

I put it underneath protected $linktext.

2. Now scroll down to public function getText() and underneath it put this:

PHP:
    public function hasIcon(){
        return ($this->linkicon && $this->linkicon != NULL);
    }

    public function getIcon(){ // Added
        if($this->linkicon == NULL) $this->linkicon = "None";
        return $this->linkicon;
    }

    public function getIconWidth(){ // Added
        return $this->iconwidth;
    }

3. Now open view/admincp/linksview.php and replace the entire file with this:

PHP:
<?php

namespace View\AdminCP;
use Resource\Collection\LinkedHashMap;
use Resource\Collection\LinkedList;
use Resource\Core\Registry;
use Resource\Core\View;
use Resource\GUI\Component\Button;
use Resource\GUI\Component\TextField;
use Resource\GUI\Container\TCell;
use Resource\GUI\Document\Comment;
use Resource\GUI\Element\Align;
use Resource\Native\MysString;
use Service\Builder\FormBuilder;
use Service\Builder\TableBuilder;
use Service\Helper\TableHelper;

class LinksView extends View{
    
    public function index(){
        parent::index();
        $document = $this->document;
        $helper = new TableHelper;
        $linksTable = new TableBuilder("links");
        $linksTable->setAlign(new Align("center", "middle"));
        $linksTable->buildHeaders("ID", "Link Type", "Link Text", "Link Icon", "Icon Width", "Link Url", "Link Parent", "Link Order", "Edit", "Delete");
        $linksTable->setHelper($helper);
        
        $links = $this->getField("links");
        $iterator = $links->iterator();
        while($iterator->hasNext()){
            $link = $iterator->next();
            $cells = new LinkedList;
            $cells->add(new TCell($link->getID()));
            $cells->add(new TCell($link->getType()));
            $cells->add(new TCell($link->getText()));
            $cells->add(new TCell($link->hasIcon() ? "<img src='{$link->getIcon()}' alt='{$link->getText()} icon' width='{$link->getIconWidth()}px'>" : "None")); // Added
            $cells->add(new TCell($link->getIconWidth()));
            $cells->add(new TCell($link->getURL()));
            $cells->add(new TCell($link->hasParent() ? $link->getParentText() : "N/A"));
            $cells->add(new TCell($link->getOrder()));
            $cells->add(new TCell($helper->getEditLink($link->getID())));
            $cells->add(new TCell($helper->getDeleteLink($link->getID())));
            $linksTable->buildRow($cells);
        }
        $document->add($linksTable);

        $pagination = $this->getField("pagination");
        $document->addLangvar($pagination->showPage());
    }
    
    public function add(){
        $mysidia = Registry::get("mysidia");
        $document = $this->document;       
        if($mysidia->input->post("submit")){
            $document->setTitle($this->lang->added_title);
            $document->addLangvar($this->lang->added);
            return;         
        }
        
        $document->setTitle($this->lang->add_title);
        $document->addLangvar($this->lang->add);
        $linkTypes = new LinkedHashMap;
        $linkTypes->put(new MysString("Navlink"), new MysString("navlink"));
        $linkTypes->put(new MysString("Sidelink"), new MysString("sidelink"));

        $linksForm = new FormBuilder("addform", "add", "post");
        $linksForm->add(new Comment("Link Type: ", FALSE));
        $linksForm->buildRadioList("linktype", $linkTypes, "navlink");
        $linksForm->add(new Comment("Link Text: ", FALSE));
        $linksForm->add(new TextField("linktext"));
        $linksForm->add(new Comment($this->lang->text));
        $linksForm->add(new Comment("Link Icon: ", FALSE)); // Added
        $linksForm->add(new TextField("linkicon"));
        $linksForm->add(new Comment($this->lang->icon));
        $linksForm->add(new Comment("Icon Width: ", FALSE)); // Added
        $linksForm->add(new TextField("iconwidth", "64"));
        $linksForm->add(new Comment($this->lang->iconwidth));
        $linksForm->add(new Comment("Link URL: ", FALSE));
        $linksForm->add(new TextField("linkurl"));
        $linksForm->add(new Comment($this->lang->url));
        $linksForm->add(new Comment("Link parent:", FALSE));
        $linksForm->buildDropdownList("linkparent", "ParentLinkList");
        $linksForm->add(new Comment("Link Order: ", FALSE));
        $linksForm->add(new TextField("linkorder", 0));
        $linksForm->add(new Button("Add Link", "submit", "submit"));
        $document->add($linksForm);
    }
    
    public function edit(){
           $mysidia = Registry::get("mysidia");
        $document = $this->document;
        $link = $this->getField("link");
          if(!$link) $this->index();
        elseif($mysidia->input->post("submit")){
            $document->setTitle($this->lang->edited_title);
            $document->addLangvar($this->lang->edited);
        }
        else{
            $document->setTitle($this->lang->edit_title);
            $document->addLangvar($this->lang->edit);
            $linkTypes = new LinkedHashMap;
            $linkTypes->put(new MysString("Navlink"), new MysString("navlink"));
            $linkTypes->put(new MysString("Sidelink"), new MysString("sidelink"));
            
            $linksForm = new FormBuilder("editform", $link->getID(), "post");
            $linksForm->add(new Comment("Link Type: ", FALSE));
            $linksForm->buildRadioList("linktype", $linkTypes, $link->getType());
            $linksForm->add(new Comment("Link Text: ", FALSE));
            $linksForm->add(new TextField("linktext", $link->getText()));
            $linksForm->add(new Comment($this->lang->text));
            $linksForm->add(new Comment("Link Icon: ", FALSE)); // Added
            $linksForm->add(new Comment($link->hasIcon() ? "<img src='{$link->getIcon()}' alt='{$link->getText()} icon' width='{$link->getIconWidth()}px'>" : "", FALSE));
            $linksForm->add(new TextField("linkicon", $link->hasIcon() ? $link->getIcon() : NULL));
            $linksForm->add(new Comment($this->lang->icon));
            $linksForm->add(new Comment("Icon Width: ", FALSE));
            $linksForm->add(new TextField("iconwidth", $link->getIconWidth()));
            $linksForm->add(new Comment($this->lang->iconwidth));
            $linksForm->add(new Comment("Link URL: ", FALSE));
            $linksForm->add(new TextField("linkurl", $link->getURL()));
            $linksForm->add(new Comment($this->lang->url));
            $linksForm->add(new Comment("Link parent:", FALSE));
              $linksForm->buildDropdownList("linkparent", "ParentLinkList", $link->getParent());
            $linksForm->add(new Comment("Link Order: ", FALSE));
            $linksForm->add(new TextField("linkorder", $link->getOrder()));
            $linksForm->add(new Button("Edit Link", "submit", "submit"));
            $document->add($linksForm);             
        }
    }
    
    public function delete(){
        $document = $this->document;
        $link = $this->getField("link");
        if(!$link) $this->index();
        else{
            $document->setTitle($this->lang->delete_title);
            $document->addLangvar($this->lang->delete);
        }
    }
}

If you had already made changes to this file you can use that as a way to see what you need to add, but basically I added sections for the link icon and icon width in the index, add, and edit sections.

4. Next open controller/admincp/linkscontroller.php and replace it with this:

PHP:
<?php

namespace Controller\AdminCP;
use Exception;
use Model\DomainModel\Link;
use Resource\Collection\ArrayList;
use Resource\Core\AppController;
use Resource\Core\Pagination;
use Resource\Core\Registry;
use Resource\Exception\BlankFieldException;
use Resource\Exception\InvalidIDException;
use Resource\Exception\NoPermissionException;

class LinksController extends AppController{

    public function __construct(){
        parent::__construct();
        $mysidia = Registry::get("mysidia");
        if($mysidia->usergroup->getpermission("canmanagesettings") != "yes"){
            throw new NoPermissionException("You do not have permission to manage links.");
        }   
    }
    
    public function index(){
        parent::index();
        $mysidia = Registry::get("mysidia");
        $total = $mysidia->db->select("links")->rowCount();
        $pagination = new Pagination($total, $mysidia->settings->pagination, "admincp/links", $mysidia->input->get("page"));   
        $prefix = constant("PREFIX");
        $stmt = $mysidia->db->query("SELECT subcat.*,parentcat.linktext as parentname FROM {$prefix}links as subcat LEFT JOIN {$prefix}links as parentcat ON parentcat.id=subcat.linkparent ORDER BY subcat.id ASC LIMIT {$pagination->getLimit()},{$pagination->getRowsperPage()}");
        $links = new ArrayList;
        while($dto = $stmt->fetchObject()){
            $links->add(new Link($dto->id, $dto));
        }
        $this->setField("pagination", $pagination);
        $this->setField("links", $links);       
    }
    
    public function add(){
        $mysidia = Registry::get("mysidia");       
        if($mysidia->input->post("submit")){
            if(!$mysidia->input->post("linktext") || !$mysidia->input->post("linkurl")) throw new BlankFieldException("global_blank");
            $mysidia->db->insert("links", ["id" => NULL, "linktype" => $mysidia->input->post("linktype"), "linktext" => $mysidia->input->post("linktext"), "linkicon" => $mysidia->input->post("linkicon"), "iconwidth" => $mysidia->input->post("iconwidth"), "linkurl" => $mysidia->input->post("linkurl"), "linkparent" => (int)$mysidia->input->post("linkparent"), "linkorder" => (int)$mysidia->input->post("linkorder")]);           
        }
    }
    
    public function edit($lid = NULL){
           $mysidia = Registry::get("mysidia");
          if(!$lid) return $this->index();
        try{
            $link = new Link($lid);
            if($mysidia->input->post("submit")){
                $mysidia->db->update("links", ["linktype" => $mysidia->input->post("linktype"), "linktext" => $mysidia->input->post("linktext"), "linkicon" => $mysidia->input->post("linkicon"), "iconwidth" => $mysidia->input->post("iconwidth"), "linkurl" => $mysidia->input->post("linkurl"),
                                               "linkparent" => (int)$mysidia->input->post("linkparent"), "linkorder" => (int)$mysidia->input->post("linkorder")], "id = '{$link->getID()}'");
            }
            $this->setField("link", $link);
        }
        catch(Exception $e){
            throw new InvalidIDException("global_id");
        }
    }
    
    public function delete($lid = NULL){
        $mysidia = Registry::get("mysidia");
        if(!$lid)$this->index();
        else{
            $link = new Link($lid);
            $mysidia->db->delete("links", "id = '{$link->getID()}'");
        }
        $this->setField("link", $lid ? $link : NULL);
    }
}

Like before I just added parts for the link icon and icon width. Without the controller, submitting the new icon and icon width wouldn't actually do anything so make sure you do both the view file and controller before testing if it works.

5. Now we need to set up the lang file. So open lang/admincp/lang_links.php and add this to it:

PHP:
$lang['icon'] = "Type the icon url that will appear for the new link. Leave blank for no icon.";   
$lang['iconwidth'] = "Size of the icon in px.";

Now you should be able to set icons for your links, but they won't appear on the site just yet. That's the next part! Screenshots of what the AdminCP should look like in the spoiler.

  Spoiler: images 


6. To make the icons actually appear on the site, find and open model/viewmodel/menu.php. Replace it with this:

PHP:
<?php

namespace Model\ViewModel;
use ArrayObject, Exception;
use Resource\Core\Initializable;
use Resource\Core\Registry;
use Resource\GUI\Component;
use Resource\GUI\Container\LinksList;
use Resource\GUI\Document\Division;
use Resource\Utility\URL;

/**
 * The Menu Class, defines a standard HTML Dropdown Menu component.
 * It extends from the WidgetViewModel class, while adding its own implementation.
 * @category Model
 * @package ViewModel
 * @author Hall of Famer
 * @copyright Mysidia Adoptables Script
 * @link http://www.mysidiaadoptables.com
 * @since 1.3.3
 * @todo Not much at this point.
 *
 */

class Menu extends WidgetViewModel implements Initializable{

    /**
     * The categories property, stores a list of link categories.
     * @access protected
     * @var ArrayObject
     */
    protected $categories;
    
    /**
     * The links property, defines all links inside the dropdown menu.
     * @access protected
     * @var ArrayObject
     */
    protected $links;

    /**
     * Constructor of Menu Class, it initializes basic dropdown menu properties     
     * @access public
     * @return void
     */
    public function __construct(){
        $this->categories = new ArrayObject;
        $this->links = new ArrayObject;
        $this->initialize();
    }

    /**
     * The initialize method, which handles advanced properties that cannot be initialized without a menu object.
     * It should only be called upon object instantiation, otherwise an exception will be thrown.     
     * @access public
     * @return void
     */   
    public function initialize(){
        $mysidia = Registry::get("mysidia");
        if($this->categories->count() != 0) throw new Exception("Initialization process already completed.");
        $menuList = new LinksList("ul");
        
        $stmt = $mysidia->db->select("links", [], "linktype = 'navlink' AND linkparent < 1 ORDER BY linkorder ASC");         
        while($category = $stmt->fetchObject()){
            $menu = new LinksList;
            $this->setCategories($menu, $category);   
                    
            $stmt2 = $mysidia->db->select("links", [], "linktype = 'navlink' AND linkparent='{$category->id}' ORDER BY linkorder ASC");
            if($stmt2->rowCount() > 0){
                  $linksList = new LinksList("ul");
                while($item = $stmt2->fetchObject()) $this->setLinks($linksList, $item);
                $menu->add($linksList);
            }
            $menuList->add($menu);
        }
        $this->setDivision($menuList);
    }
    
    /**
     * The setDivision method, setter method for property $division.
     * It is set internally upon object instantiation, cannot be accessed in client code.
     * @param Component  $menuList
     * @access protected
     * @return void
     */
    protected function setDivision(Component $menuList){
        $this->division = new Division;
        $this->division->setClass("ddmenu");
        $this->division->add($menuList);
    }

    /**
     * The getCategories method, getter method for property $categories.
     * @access public
     * @return ArrayObject
     */
    public function getCategories(){
        return $this->categories;
    }
    
    /**
     * The setCategories method, setter method for property $categories.
     * It is set internally upon object instantiation, cannot be accessed in client code.
     * @param LinksList  $menu
     * @param Object  $category
     * @access protected
     * @return void
     */
    protected function setCategories(LinksList $menu, $category){
        $parentLink = new Component\Link($category->linkurl);
        $parentLink->setClass("hides");
        if($category->linkicon == NULL){
            $parentLink->setText($category->linktext);
        }
        else{
            $parentLink->setText("<img src='{$category->linkicon}' alt=''{$category->linktext} icon' width='{$category->iconwidth}px'> {$category->linktext}");
        }
        
        $menu->add($parentLink);
        $this->categories->offsetSet($category->linktext, $parentLink);
    }
    
    /**
     * The getLinks method, getter method for property $links.
     * @access public
     * @return ArrayObject
     */
    public function getLinks(){
        return $this->links;
    }   
    
    /**
     * The setLinks method, setter method for property $links.
     * It is set internally upon object instantiation, cannot be accessed in client code.
     * @param LinksList  $linksList
     * @param Object  $item
     * @access protected
     * @return void
     */
    protected function setLinks(LinksList $linksList, $item){
        $url = new URL($item->linkurl, FALSE, FALSE);
        $childLink = new Component\Link($url);
        if($item->linkicon == NULL){
            $childLink->setText($item->linktext);
        }
        else{
            $childLink->setText("<img src='{$item->linkicon}' alt=''{$item->linktext} icon' width='{$item->iconwidth}px'> {$item->linktext}");
        }
        $childLink->setListed(TRUE);
        
        $linksList->add($childLink);
        $this->links->offsetSet($item->linktext, $childLink);
    }
}

7. Next open css/menu.css as we need to tweak it so the menu fits the icons. Replace it with this:

CSS:
/* ================================================================
This copyright notice must be untouched at all times.

The original version of this stylesheet and the associated (x)html
is available at http://www.cssplay.co.uk/menus/dd_valid.html
Copyright (c) 2005-2007 Stu Nicholls. All rights reserved.
This stylesheet and the assocaited (x)html may be modified in any
way to fit your requirements.
=================================================================== */

/* common styling */
.ddmenu {width:100%; position:relative; z-index:100;}
.ddmenu ul li a, .ddmenu ul li a:visited {display:block; text-decoration:none; font-size:12px; color:#000;width:182px; text-align:center; color:#fff; border:1px solid #fff; background:#222; line-height:20px; overflow:hidden;}
.ddmenu ul {padding:0; margin:0; list-style: none;}
.ddmenu ul li {float:left; position:relative;}
.ddmenu ul li ul {display: none;}

/* specific to non IE browsers */
.ddmenu ul li:hover a {color:#fff; background:#acacac;}
.ddmenu ul li:hover ul {display:block; position:absolute; left:0; width:182px;}
.ddmenu ul li:hover ul li a.hides {background:#222; color:#fff;}
.ddmenu ul li:hover ul li:hover a.hides {background:#222; color:#000;}
.ddmenu ul li:hover ul li ul {display: none;}
.ddmenu ul li:hover ul li a {display:block; background:#ddd; color:#000;}
.ddmenu ul li:hover ul li a:hover {background:#ededed; color:#000;}
.ddmenu ul li:hover ul li:hover ul {display:block; position:absolute; left:182px; top:0;}
.ddmenu ul li:hover ul li:hover ul.left {left:-182px;}
 

Attachments

  • files.zip
    8.7 KB · Views: 1
8. Finally, so the icons work on the sidebar, find and open model/viewmodel/sidebar.php and replace it with this:

PHP:
<?php

namespace Model\ViewModel;
use Model\DomainModel\Widget;
use Resource\Core\Registry;
use Resource\GUI\Component;
use Resource\GUI\Component\Link;
use Resource\GUI\Container\LinksList;
use Resource\GUI\Document\Comment;
use Resource\GUI\Document\Division;
use Resource\GUI\Document\Paragraph;
use Service\Builder\FormBuilder;

/**
 * The Sidebar Class, defines a standard HTML Sidebar component.
 * It extends from the WidgetViewModel class, while adding its own implementation.
 * @category Model
 * @package ViewModel
 * @author Hall of Famer
 * @copyright Mysidia Adoptables Script
 * @link http://www.mysidiaadoptables.com
 * @since 1.3.3
 * @todo Not much at this point.
 *
 */

class Sidebar extends WidgetViewModel{

    /**
     * The moneyBar property, specifies the money/donation bar for members.
     * @access protected
     * @var Paragraph
     */
    protected $moneyBar;
    
    /**
     * The linksBar property, stores all useful links for members.
     * @access protected
     * @var Paragraph
     */
    protected $linksBar;
    
    /**
     * The wolBar property, determines the who's online url in the sidebar.
     * @access protected
     * @var Link
     */
    protected $wolBar;
    
    /**
     * The loginBar property, specifies the loginBar for guests.
     * @access protected
     * @var FormBuilder
     */
    protected $loginBar;

    
    /**
     * Constructor of Sidebar Class, it initializes basic sidebar properties     
     * @access public
     * @return void
     */
    public function __construct(){
        parent::__construct(new Widget("sidebar"));
    }
    
    /**
     * The setDivision method, setter method for property $division.
     * It is set internally upon object instantiation, cannot be accessed in client code.
     * @param Component  $module
     * @access protected
     * @return Void
     */
    protected function setDivision(Component $module){
        if(!$this->division){
            $this->division = new Division;
            $this->division->setClass("sidebar");
        }   
        $this->division->add($module);
    }
    
    /**
     * The getMoneyBar method, getter method for property $moneyBar.
     * @access public
     * @return Paragraph
     */
    public function getMoneyBar(){
        return $this->moneyBar;
    }
    
    /**
     * The setMoneyBar method, setter method for property $moneyBar.
     * It is set internally upon object instantiation, cannot be accessed in client code.
     * @access protected
     * @return Void
     */
    protected function setMoneyBar(){
        $mysidia = Registry::get("mysidia");
        $this->moneyBar = new Paragraph;
        $this->moneyBar->add(new Comment("You have {$mysidia->user->getMoney()} {$mysidia->settings->cost}."));
        
        $donate = new Link("donate");
        $donate->setText("Donate Money to Friends");
        $this->moneyBar->add($donate);
        $this->setDivision($this->moneyBar);       
    }

    /**
     * The getLinksBar method, getter method for property $linksBar.
     * @access public
     * @return Paragraph
     */
    public function getLinksBar(){
        return $this->linksBar;
    }
    
    /**
     * The setLinksBar method, setter method for property $linksBar.
     * It is set internally upon object instantiation, cannot be accessed in client code.
     * @access protected
     * @return Void
     */
    protected function setLinksBar(){
        $mysidia = Registry::get("mysidia");
        $this->linksBar = new Paragraph;
        $linkTitle = new Comment("{$mysidia->user->getUsername()}'s Links:");
        $linkTitle->setBold();
        $this->linksBar->add($linkTitle);
        
        $linksList = new LinksList("ul");
        $this->setLinks($linksList);
        
        $this->linksBar->add($linksList);
        $this->setDivision($this->linksBar);   
    }

    /**
     * The setLinks method, append all links to the LinksBar.
     * It is set internally upon object instantiation, cannot be accessed in client code.
     * @access protected
     * @return Void
     */
    protected function setLinks(LinksList $linksList){
        $mysidia = Registry::get("mysidia");
        $stmt = $mysidia->db->select("links", ["id", "linktext", "linkicon", "iconwidth", "linkurl"], "linktype = 'sidelink' ORDER BY linkorder");
        if($stmt->rowCount() == 0) Throw new Exception("There is an error with sidebar links, please contact the admin immediately for help.");
        
        while($sideLink = $stmt->fetchObject()){
            $link = new Link($sideLink->linkurl);
            if($sideLink->linkicon == NULL){
                $link->setText($sideLink->linktext);
            }
            else{
                $link->setText("<img src='{$sideLink->linkicon}' alt='{$sideLink->linktext} icon' width='{$sideLink->iconwidth}px'> {$sideLink->linktext}");
            }
            if($sideLink->linkurl == "messages"){
                $num = $mysidia->db->select("messages", ["touser"], "touser = '{$mysidia->user->getID()}' AND status = 'unread'")->rowCount();
                if($num > 0) $link->setText("<b>{$link->getText()} ({$num})</b>");
            }
            $link->setListed(TRUE);
            $linksList->add($link);   
        }
        
        if($mysidia->user->isAdmin()){
            $adminCP = new Link("admincp/", FALSE, FALSE);
            $adminCP->setText("Admin Control Panel");
            $adminCP->setListed(TRUE); 
            $linksList->add($adminCP);           
        }
    }
    
    /**
     * The getWolBar method, getter method for property $wolBar.
     * @access public
     * @return LinksList
     */
    public function getWolBar(){
        return $this->wolBar;
    }
    
    /**
     * The setWolBar method, setter method for property $wolBar.
     * It is set internally upon object instantiation, cannot be accessed in client code.
     * @access protected
     * @return void
     */
    protected function setWolBar(){
        $mysidia = Registry::get("mysidia");
        $this->wolBar = new Link("online");
        $totalMembers = $mysidia->db->select("online", [], "username != 'Guest'")->rowCount();
        $totalGuests = $mysidia->db->select("online", [], "username = 'Guest'")->rowCount();
        $this->wolBar->setText("This site has {$totalMembers} members and {$totalGuests} guests online.");
        $this->setDivision($this->wolBar);         
    }
    
    /**
     * The getLoginBar method, getter method for property $loginBar.
     * @access public
     * @return FormBuilder
     */
    public function getLoginBar(){
        return $this->loginBar;
    }
    
    /**
     * The setLoginBar method, setter method for property $loginBar.
     * It is set internally upon object instantiation, cannot be accessed in client code.
     * @access protected
     * @return Void
     */
    protected function setLoginBar(){
        $this->loginBar = new FormBuilder("login", "login", "post");
        $loginTitle = new Comment("Member Login:");
        $loginTitle->setBold();
        $loginTitle->setUnderlined();
        $this->loginBar->add($loginTitle);

        $this->loginBar->buildComment("username: ", FALSE)
                       ->buildTextField("username")
                       ->buildComment("password: ", FALSE)
                       ->buildPasswordField("password", "password", "", TRUE)   
                       ->buildButton("Log In", "submit", "submit")
                       ->buildComment("Don't have an account?");
                      
        $register = new Link("register");
        $register->setText("Register New Account");
        $register->setLineBreak(TRUE);
        $forgot = new Link("forgotpass");
        $forgot->setText("Forgot Password?");
        
        $this->loginBar->add($register);
        $this->loginBar->add($forgot);
        $this->setDivision($this->loginBar);     
    }
}

That should be it! Image below!

  Spoiler: image 


If you've not edited any of these files I have provided them as downloads on the main post. Just drop and overwrite into the correct location. Any questions feel free to ask and I can try to help!
 
So cool! Thank you I can't wait to try this later
answer.png
I did it! This was so cool thank you I had no idea where to even begin with this. Your tutorial was so great and easy to follow. I can't wait to make some icons and update my header
 

Attachments

  • question.png
    question.png
    36.1 KB · Views: 3
Last edited:

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,118
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Top