PDA

View Full Version : Hedgen's Small Tutorials


Hedgen
03-10-2013, 01:58 AM
Hey everyone! I am posting this thread for small things I figure out that some of you might have issues with, such as moving things from the :SIDEFEED: to the :LINKSBAR:, so as I make modifications to my adoptables site, I'll be adding things here (Or when helping people, if I answer someone with something to do with code I'll add it here in case anyone else has trouble with the same thing.

I will reply to this with the tutorials, and link to them on this post, that way this post isn't to long, and you won't have to look through this thread for them.

Editing :SIDEFEED: and :LINKSBAR: (http://mysidiaadoptables.com/forum/showpost.php?p=26237&postcount=2)
Redirect People after X Seconds (http://mysidiaadoptables.com/forum/showpost.php?p=26238&postcount=3)

Hedgen
03-10-2013, 04:15 AM
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:
private function getsidebar()
Once there, copy:
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:
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:

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:

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 $links = "<div class='ddmenu'>\n<ul>";

After that, change
$links = "<div class='ddmenu'>\n<ul>";
to
$links .= "\n<ul>";
so the menu displays properly.

You should now have something similar to:

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:
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:

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
private function getlinks() in the same file
and place this modified if statement under

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
return $links;
You should have something like this:
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.

Hedgen
03-10-2013, 04:32 AM
Note: 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. Since it is just a little bit of HTML, you should be able to add it to any page, but again I haven't tested it yet.

Someone asked about redirecting people to the home page after logging in after 5 seconds, so I found this little bit of html code you place in your header of any page, and it will redirect people to wherever you specify.

Place this in whatever page you want:
<head>
<meta http-equiv='refresh' content='timeinseconds; URL=yoursite.com'>
</head>
Replace "timeinseconds" with the amount of time in seconds you want to wait until the redirect. So if you wanted them to wait 5 seconds, set "content=" to 5.
Replace "yoursite.com" with the page you want them to be redirected to.

How to redirect someone from the login page after 5 seconds:
Go to login.php and find:
// Validation succeeded, now begins the actual login procedure

a couple lines below that, there should be "$mysidia->page->addcontent"
Place the html code right inside the quotes for that.
It should now be something like this:
// Validation succeeded, now begins the actual login procedure

$mysidia->page->settitle($lang->success_title);
$mysidia->page->addcontent("<head>
<meta http-equiv='refresh' content='5;
URL=redirectedpage.com'>
</head>
Welcome back {$mysidia->input->post("username")}. {$lang->success}");
content='5; being 5 second wait, and URL=redirectedpage.com' being the page you want people to be redirected to.

How to redirect someone from the logout page after 5 seconds:

Go to logout.php, once there edit:
$mysidia->page->addcontent($lang->default);
to
$mysidia->page->addcontent("<head>
<meta http-equiv='refresh' content='5; URL=redirectedpage.com'>
</head>". $lang->default);
Again, content='5; being 5 second wait, and URL=redirectedpage.com being the page you want people to be redirected to.