View Single Post
  #2  
Old 03-10-2013, 04:15 AM
Hedgen's Avatar
Hedgen Hedgen is offline
Member
 
Join Date: Oct 2012
Posts: 36
Gender: Male
Credits: 4,927
Hedgen is on a distinguished road
Default :SIDEFEED: to :LINKSBAR:

Note1: This is for Mysidia Version 1.3.2, It may or may not work for Version 1.3.3, I haven't tested it for 1.3.3 yet.
Note2: This tutorial might seem a little long, I might have been able to explain things more clearly, and I probably could have made it shorter, but bare with me, I'm not use to writing tutorials.

So I wanted to move my login form from the :SIDEFEED: to the :LINKSBAR: part of the site (SIDEFEED has the login form, and other single links, while LINKSBAR has drop down menus) so I messed with the code until I figured out how to do it.

This tutorial is mostly showing how to move the location of the login form, you can do this with other parts of the sidefeed but I'm only showing the login form. I am using the main theme, so my :LINKSBAR: is a horizontal dropdown menu on top of the site.

So to start, open up class_page.php (classes/class_page.php) and find:
PHP Code:
private function getsidebar() 
Once there, copy:
PHP Code:
if($mysidia->user->isloggedin == TRUE) {
        
$msgctr "<a href='messages.php'>Messages</a>";        
        
$data $mysidia->db->select("messages", array("touser"), "touser='{$mysidia->user->username}' and status='unread'")->fetchAll();

        if(
count($data) > 0$msgctr "<a href='messages.php'>Messages <b>(".count($data).")</b></a>";
        
$sidebar "You have {$mysidia->user->money} {$mysidia->settings->cost}.<br />
                   <a href='donate.php'>Donate money to friends</a><br />
                   <br /><strong>Your links:</strong><br />
                   <ul><li><a href='adopt.php'>Adopt New Pets</a></li>
                   <li><a href='pound.php'>Acquire Pounded Pets</a></li>
                   <li><a href='myadopts.php'>Manage Adoptables</a></li>
                   <li><a href='account.php'>Go to My Account</a></li>
                   <li>
{$msgctr}<li><a href='changestyle.php'>Change Theme</a></li>
                   <li><a href='logout.php'>Log Out</a></li>"
;

        
$row $mysidia->db->select("users", array("uid""username"), "username='{$mysidia->user->username}' and usergroup='1'")->fetchObject();        
        if(
is_object($row)) $sidebar .= "<li><a href='admincp/'>Admin Center</a></li><br />";
     }
     else {
        
$sidebar "<b><u>Member Login:</u></b><br />
        <form name='form1' method='post' action='login.php'>
          <p>Username: <input name='username' type='text' id='username'></p>
          <p>Password: <p><input name='password' type='password' id='password'></p>
          <p><input type='submit' name='Submit' value='Log In'></p>
        </form>Don't have an account?<br /><a href='register.php'>Register Free</a><br /><a href='forgotpass.php'>Forgot Password?</a><br />"
;
     } 
to your favorite text editor. (You don't have to copy it to a text editor, but I find it easier if I am modifying code that I am going to place somewhere else to do it in a blank file.)

Once you did or did not do that, you really only need to keep these parts of the code:
PHP Code:
if($mysidia->user->isloggedin == TRUE) {
        
$sidebar "";
     }
     else {
        
$sidebar "<b><u>Member Login:</u></b><br />
        <form name='form1' method='post' action='login.php'>
          <p>Username: <input name='username' type='text' id='username'></p>
          <p>Password: <p><input name='password' type='password' id='password'></p>
          <p><input type='submit' name='Submit' value='Log In'></p>
        </form>Don't have an account?<br /><a href='register.php'>Register Free</a><br /><a href='forgotpass.php'>Forgot Password?</a><br />"
;
     } 
Once you have that, decide whether you want the login form above or below your :LINKSBAR:.

If you wish to have the login form above the linksbar:
  Spoiler: Above Linksbar 

Change both of the "$sidebar =" to "$links ="
Once you have done that, place your html div tags, or whatever you are using to style your site, right inside of the quotes.
You should now have something like this:

PHP Code:
if($mysidia->user->isloggedin == TRUE) {
        
$links "<div class='ddmenu' style='top:-25px;'>";
     }
     else {
        
$links "<div class='ddmenu' style='top:0px;'>
            <b><u>Member Login:</u></b><br />
            <form name='form1' method='post' action='login.php'>
                  <p>Username: <input name='username' type='text' id='username'></p>
                  <p>Password: <p><input name='password' type='password' id='password'></p>
                  <p><input type='submit' name='Submit' value='Log In'></p>
            </form>Don't have an account?<br /><a href='register.php'>Register Free</a><br /><a href='forgotpass.php'>Forgot Password?</a><br />"
;
     } 
Note: your <div> tag will probably be different than mine. I have a menu that floats above my website so I have to style mine a little differently.

Okay, so now you have gotten that set up, let's place it in the LINKSBAR.

Find "private function getlinks()" in the same file.
Once there, you want add our login form above
PHP Code:
$links "<div class='ddmenu'>\n<ul>"
After that, change
PHP Code:
$links "<div class='ddmenu'>\n<ul>"
to
PHP Code:
$links .= "\n<ul>"
so the menu displays properly.

You should now have something similar to:

  Spoiler:  
PHP Code:
private function getlinks(){
     
// This method gets the links for the top bar from the database
     
     
global $mysidia;     
     if(
$mysidia->user->isloggedin == TRUE) {
        
$links "<div class='ddmenu' style='top:-25px;'>";
     }
     else {
        
$links "<div class='ddmenu' style='top:0px;'>
            <b><u>Member Login:</u></b><br />
            <form name='form1' method='post' action='login.php'>
                  <p>Username: <input name='username' type='text' id='username'></p>
                  <p>Password: <p><input name='password' type='password' id='password'></p>
                  <p><input type='submit' name='Submit' value='Log In'></p>
            </form>Don't have an account?<br /><a href='register.php'>Register Free</a><br /><a href='forgotpass.php'>Forgot Password?</a><br />"
;
     }
     
$links .= "\n<ul>";     
     
$stmt $mysidia->db->select("links", array(), "linkparent < 1 ORDER BY id ASC");       
     while (
$category $stmt->fetchObject()) {
        
$links .= "\n<li><a class='hide' href='{$category->linkurl}'>{$category->linktext}</a>
               \n<ul>"
;
        
$stmt2 $mysidia->db->select("links", array(), "linkparent='{$category->id}' ORDER BY id ASC");
        while(
$item $stmt2->fetchObject()){
            
$links .= "<li><a href='{$item->linkurl}' title='{$item->linktext}'>{$item->linktext}</a></li>";      
        }
        
$links .= "</ul>
              \n</li>"
;
     }    
     
$links .= "\n</ul>";
     return 
$links;
  } 


After you got that, you can edit the login form layout to get it to how you want it, and then you are done with getting it above the menu!


If you wish to have the login form below the linksbar:
  Spoiler: Below Linksbar 
Change both of the "$sidebar =" to "$links .=" so when you place it below the linksbar it adds it to the menu. You should have something like this:

PHP Code:
if($mysidia->user->isloggedin == TRUE) {
        
$links .= "";
     }
     else {
        
$links .= "
            <b><u>Member Login:</u></b><br />
            <form name='form1' method='post' action='login.php'>
                  <p>Username: <input name='username' type='text' id='username'></p>
                  <p>Password: <p><input name='password' type='password' id='password'></p>
                  <p><input type='submit' name='Submit' value='Log In'></p>
            </form>Don't have an account?<br /><a href='register.php'>Register Free</a><br /><a href='forgotpass.php'>Forgot Password?</a><br />"
;
     } 
Find
PHP Code:
private function getlinks() 
in the same file
and place this modified if statement under

PHP Code:
while ($category $stmt->fetchObject()) {
        
$links .= "\n<li><a class='hide' href='{$category->linkurl}'>{$category->linktext}</a>
               \n<ul>"
;
        
$stmt2 $mysidia->db->select("links", array(), "linkparent='{$category->id}' ORDER BY id ASC");
        while(
$item $stmt2->fetchObject()){
            
$links .= "<li><a href='{$item->linkurl}' title='{$item->linktext}'>{$item->linktext}</a></li>";      
        }
        
$links .= "</ul>
              \n</li>"
;
     }    
     
$links .= "\n</ul>"
but above
PHP Code:
return $links
You should have something like this:
  Spoiler:  
PHP Code:
private function getlinks(){
     
// This method gets the links for the top bar from the database
     
     
global $mysidia;     
     
     
$links "<div class='ddmenu' style='top:0px;'><ul>";     
     
$stmt $mysidia->db->select("links", array(), "linkparent < 1 ORDER BY id ASC");       
     while (
$category $stmt->fetchObject()) {
        
$links .= "\n<li><a class='hide' href='{$category->linkurl}'>{$category->linktext}</a>
               \n<ul>"
;
        
$stmt2 $mysidia->db->select("links", array(), "linkparent='{$category->id}' ORDER BY id ASC");
        while(
$item $stmt2->fetchObject()){
            
$links .= "<li><a href='{$item->linkurl}' title='{$item->linktext}'>{$item->linktext}</a></li>";      
        }
        
$links .= "</ul>
              \n</li>"
;
     }    
     
$links .= "\n</ul>";
     if(
$mysidia->user->isloggedin == TRUE) {
        
$links .= "";
     }
     else {
        
$links .= "
            <b><u>Member Login:</u></b><br />
            <form name='form1' method='post' action='login.php'>
                  <p>Username: <input name='username' type='text' id='username'></p>
                  <p>Password: <p><input name='password' type='password' id='password'></p>
                  <p><input type='submit' name='Submit' value='Log In'></p>
            </form>Don't have an account?<br /><a href='register.php'>Register Free</a><br /><a href='forgotpass.php'>Forgot Password?</a><br />"
;
     }
     return 
$links;
  } 

And then you can edit the login form to however you want it, and then you are done!



If you have any questions about this tutorial, or any others I post, please say so here. I know that I sometimes don't explain things very well so I try to explain the best I can.

Last edited by Hedgen; 03-26-2013 at 01:52 PM.
Reply With Quote