PDA

View Full Version : Four Questions - Forum/Pagination/Levelup


AlexC
04-20-2012, 08:24 AM
Okay, so I've got four questions, and I'd appreciate the help. :3 I didn't want to spam, so here is them all at once.

FIRST ONE: My pagination is turning my ratties.x10.mx url to www.ratties.x10.mx, so when I'm flipping through, for example, my adopts, going to the next page logs me out. :/ Same with the members page... I suspect once I start using the message system I'll get the same problem with the pagination there.

SECOND ONE: I prefer the forum's profile and message look (no offense) and was wondering if it is possible to shift my users over there more - so, for example, when someone clicks to go to the profile of someone on the main site, they get directed to the forum profile. I can probably do that easily enough, what I'm wondering about the adopts - obviously I can't shift those over, so what I'm asking is a) can someone either help me find a way to post someone's adoptables on their forum profile, or to slim down the profile on the main site with a link to their forum profile, so they can go both places.

THIRD ONE: Is it possible to "embed" the forum into my site? So to use the theme I have there and just insert the forum's information into the fields there, so it looks like you haven't left the site? Or would that be too hard?

FOURTH: Can I add a bit more information to the levelup page? So when someone clicks on an adoptable, it says stuff like name, clicks, level, gender, trade-ability, and just tells you clicked on it - but to also have this when you've already clicked it, so the information is still displayed. If someone could help me with this, that would be great. :D

Okay, that's it, for now. xD

Hall of Famer
04-20-2012, 08:49 AM
Well...

First of all, you may go to each script file that uses pagination and find a line like this(the example below is for messages.php):


$pagination = new Pagination($adopts, $query, $rowsperpage, "http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/messages.php");
You can edit out www. and the code should work for site url not using www. I, however, strongly recommend including www. though, since this is the convention we use for this script.


And yes, it is doable to direct user profile and message page to the forum, but that will require a lot more coding. You have to be familiar with the way your forum engine works. If it is MyBB, the user profile page looks like this:


http://www.yourdomain.com/mybb/member.php?action=profile&uid=5
The cheapest way to do this is to edit the navlink 'memberlist' and change its url to http://mysidiarpg.com/site/mybb/memberlist.php. If you still want to use the member list for Mysidia Adoptables but not the profile, you may go to profile.php and find this line:



$article_content .= "<strong><a href='profile.php?user={$row->username}'>{$star}{$row->username}</a></strong><br />";
And change it to:


$article_content .= "<strong><a href='http://www.yourdomain.com/mybb/member.php?action=profile&uid=".usernametouid($row->username).">{$star}{$row->username}</a></strong><br />";
And it should do the trick, but keep in mind that it requires the ids from adoptables and forum's user tables to be consistent. If your user id is 1 in adoptables table, but 2 in forum table, the above code will fail and you have to do a lot more coding to make it work.


The third one is, well, doable but definitely difficult. This requires a significant modification over the core script of your adoptables site, and will take me at least 3 days to complete, and not sure how long it will take you.


The last request is quite easy to achieve, you just have to re-write these lines from levelup.php to whatever you want them to be:


$article_title = $lang_gave."{$owned_adoptable->name} one ".$lang_unit;
$article_content = "<img src='{$image}'><br>{$lang_gave}{$owned_adoptable->name} one {$lang_unit}.<br>".$lang_levelup_encourage;
Note the $owned_adoptables is an object with various properties such as level, click, gender and tradestatus, you can access them by $owned_adoptables->property. A concrete example is already available above, note how the adoptables name is accessed as {$owned_adoptable->name}. If you do not know what properties are available in $owned_adoptables object, simply go to your prefix.owned_adoptables table and the column names are the property names.

SilverDragonTears
04-20-2012, 12:57 PM
Have you seen my levelup pages? I can definitely help you there!

Hall of Famer
04-20-2012, 01:53 PM
I think she will mostly be stuck with question three, since thats a question even I do not know how complicated it can get. To me it seems that Gloometh wants somewhat of a full forum integration. An interesting thought, but may take time to accomplish.

SilverDragonTears
04-20-2012, 01:55 PM
You could just make your forum theme match your site theme. Or use iframe. But meh... I wouldn't go that route.

AlexC
04-20-2012, 03:51 PM
Well...

First of all, you may go to each script file that uses pagination and find a line like this(the example below is for messages.php):


$pagination = new Pagination($adopts, $query, $rowsperpage, "http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/messages.php");
You can edit out www. and the code should work for site url not using www. I, however, strongly recommend including www. though, since this is the convention we use for this script.

So it is recommended to use www. then? Well, I guess i could switch, because otherwise I'll have to keep changing it over every upgrade.

And yes, it is doable to direct user profile and message page to the forum, but that will require a lot more coding. You have to be familiar with the way your forum engine works. If it is MyBB, the user profile page looks like this:


http://www.yourdomain.com/mybb/member.php?action=profile&uid=5
The cheapest way to do this is to edit the navlink 'memberlist' and change its url to http://mysidiarpg.com/site/mybb/memberlist.php. If you still want to use the member list for Mysidia Adoptables but not the profile, you may go to profile.php and find this line:



$article_content .= "<strong><a href='profile.php?user={$row->username}'>{$star}{$row->username}</a></strong><br />";
And change it to:


$article_content .= "<strong><a href='http://www.yourdomain.com/mybb/member.php?action=profile&uid=".usernametouid($row->username).">{$star}{$row->username}</a></strong><br />";
And it should do the trick, but keep in mind that it requires the ids from adoptables and forum's user tables to be consistent. If your user id is 1 in adoptables table, but 2 in forum table, the above code will fail and you have to do a lot more coding to make it work.

Can I change the ids in the forum to match the ones on the site and then just do that thing you showed me of telling it where to start counting from?

The third one is, well, doable but definitely difficult. This requires a significant modification over the core script of your adoptables site, and will take me at least 3 days to complete, and not sure how long it will take you.

You could just make your forum theme match your site theme. Or use iframe. But meh... I wouldn't go that route.


@Silver, this is actually what I wanted - I just want my forum to look the same as my site. I just wasn't sure how to transfer over the nav bar and stuff. I don't want to do some advanced mod or anything.

The last request is quite easy to achieve, you just have to re-write these lines from levelup.php to whatever you want them to be:


$article_title = $lang_gave."{$owned_adoptable->name} one ".$lang_unit;
$article_content = "<img src='{$image}'><br>{$lang_gave}{$owned_adoptable->name} one {$lang_unit}.<br>".$lang_levelup_encourage;
Note the $owned_adoptables is an object with various properties such as level, click, gender and tradestatus, you can access them by $owned_adoptables->property. A concrete example is already available above, note how the adoptables name is accessed as {$owned_adoptable->name}. If you do not know what properties are available in $owned_adoptables object, simply go to your prefix.owned_adoptables table and the column names are the property names.

I'm slightly confused with how to add stuff like that - basically all I want to display is clicks, level, trade status, image, name, gender and that's about it. I do like how Silver has done her's, I just want it to be displayed even when you've already clicked it.

Silver, would you mind showing me how you pulled the information from the database? After that I think I can handle it, I just don't get that part too easily.

AlexC
04-20-2012, 09:29 PM
I tried doing the memberlist thing, since that was the first thing on my list, but for some reason it isn't calling the id number right?

I am getting this:

http://www.ratties.x10.mx/forum/member.php?action=profile&uid=

and my code looks like this:

<a href='http://www.ratties.x10.mx/forum/member.php?action=profile&uid='.usernametouid($row->username).'>{$star}{$row->username}</a>

SilverDragonTears
04-20-2012, 09:32 PM
Are you calling the database to get the member id's?

Try:

<a href='http://www.ratties.x10.mx/forum/member.php?action=profile&uid='{$row->uid}'>{$star}{$row->username}</a>

AlexC
04-20-2012, 09:44 PM
I'm still not getting a profile on the forum. D:

SilverDragonTears
04-20-2012, 09:45 PM
Yea that didn't work. I found how to get the uid value but the uid on the adopts site and the forums isn't the same which I thought it would be which is weird. It's a bit complex... I don't know how to do it without giving myself a headache.

AlexC
04-20-2012, 09:47 PM
the forum and main site's members should share the same IDs - I had to do some edits, but everything should be lining up now.

SilverDragonTears
04-20-2012, 10:11 PM
I thought so too, but then I put it on my site and a member from the site doesn't match the ones on the forum. Mine does.... hmmm

SilverDragonTears
04-20-2012, 10:16 PM
I guess mine is messed up somehow but you can try it on yours. Add this to the query:
, ".constant("PREFIX")."users.uid

and this where you want the link to show up:
<a href='http://www.ratties.x10.mx/forum/member.php?action=profile&uid={$row->uid}'>{$row->username}</a>

AlexC
04-20-2012, 10:36 PM
Okay, it's like 12:30 here and I think I found the query but I have no idea if I did - where do I put this? :c

// We did not specify a user, so show the memberlist
$article_title = "Memberlist";
$article_content = "Here are all of the members of this site, sorted by registration date.<br /><br />";
include("css/pagination.css");
$query = "SELECT * FROM ".constant("PREFIX")."users ORDER BY uid ASC";
$stmt = $adopts->query($query);
$rowsperpage = 15;
$pagination = new Pagination($adopts, $query, $rowsperpage, "http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/profile.php");
$pagination->setPage($_GET[page]);

$stmt = $adopts->select("users", array(), "1 ORDER BY uid ASC LIMIT {$pagination->getLimit()},{$rowsperpage}");
while ($row = $stmt->fetchObject()){
$status = cancp($row->usergroup);
$star = ($status == "yes")?"<img src='templates/icons/star.gif' border=0' /> ":"";
$article_content .= "<strong><a href='http://www.ratties.x10.mx/forum/member.php?action=profile&uid='{$row->uid}'>{$star}{$row->username}</a></strong><br />";
}

$article_content .= "<br />{$pagination->showPage()}</div>";

}


here is the member list part of the code.

SilverDragonTears
04-20-2012, 10:39 PM
I was looking at the wrong page. What you have now should work. Try this

// We did not specify a user, so show the memberlist
$article_title = "Memberlist";
$article_content = "Here are all of the members of this site, sorted by registration date.<br /><br />";
include("css/pagination.css");
$query = "SELECT * FROM ".constant("PREFIX")."users ORDER BY uid ASC";
$stmt = $adopts->query($query);
$rowsperpage = 15;
$pagination = new Pagination($adopts, $query, $rowsperpage, "http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/profile.php");
$pagination->setPage($_GET[page]);

$stmt = $adopts->select("users", array(), "1 ORDER BY uid ASC LIMIT {$pagination->getLimit()},{$rowsperpage}");
while ($row = $stmt->fetchObject()){
$status = cancp($row->usergroup);
$star = ($status == "yes")?"<img src='templates/icons/star.gif' border=0' /> ":"";
$article_content .= "<strong><a href='http://www.ratties.x10.mx/forum/member.php?action=profile&uid={$row->uid}'>{$star}{$row->username}</a></strong><br />";
}

$article_content .= "<br />{$pagination->showPage()}</div>";

}

AlexC
04-20-2012, 10:41 PM
Still not working. :/ I don't know how hard it is fetch the id.

SilverDragonTears
04-20-2012, 10:43 PM
It should already be fetching it.

AlexC
04-20-2012, 10:48 PM
It's probably fetching, it just isn't inserting it into the URL.

http://www.ratties.x10.mx/forum/member.php?action=profile&uid= <-- this is what I've been getting every time.

I removed the quotes around the id thing, and for some reason it was kinda working then - the ids were showing up, but everything went wonky.

SilverDragonTears
04-20-2012, 10:49 PM
Show me it again... what you have now?

I have this and it works
$stmt = $adopts->select("users", array(), "1 ORDER BY uid ASC LIMIT {$pagination->getLimit()},{$rowsperpage}");
while ($row = $stmt->fetchObject()){
$status = cancp($row->usergroup);
$star = ($status == "yes")?"<img src='templates/icons/star.gif' border=0' /> ":"";
$article_content .= "<strong><a href='http://taleofdragons.net/forum/member.php?action=profile&uid={$row->uid}'>{$star}{$row->username}</a></strong><br />";
}

AlexC
04-20-2012, 10:51 PM
}
else{

// We did not specify a user, so show the memberlist
$article_title = "Memberlist";
$article_content = "Here are all of the members of this site, sorted by registration date.<br /><br />";
include("css/pagination.css");
$query = "SELECT * FROM ".constant("PREFIX")."users ORDER BY uid ASC";
$stmt = $adopts->query($query);
$rowsperpage = 15;
$pagination = new Pagination($adopts, $query, $rowsperpage, "http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/profile.php");
$pagination->setPage($_GET[page]);

$stmt = $adopts->select("users", array(), "1 ORDER BY uid ASC LIMIT {$pagination->getLimit()},{$rowsperpage}");
while ($row = $stmt->fetchObject()){
$status = cancp($row->usergroup);
$star = ($status == "yes")?"<img src='templates/icons/star.gif' border=0' /> ":"";
$article_content .= "<strong><a href='http://www.ratties.x10.mx/forum/member.php?action=profile&uid='{$row->uid}'>{$star}{$row->username}</a></strong><br />";
}

$article_content .= "<br />{$pagination->showPage()}</div>";

}
What I have right now.

http://www.ratties.x10.mx/profile.php member list

I can remove the quotes again and show you how it went.

SilverDragonTears
04-20-2012, 10:54 PM
Just remove the ' right before {$row->uid}

AlexC
04-20-2012, 10:57 PM
It... works perfectly. o.o Coding will never cease to amaze me with it's brillant way of screwing up completely because of a dash or a quote mark.

Thank you so much - you catch all these things. D:

SilverDragonTears
04-20-2012, 10:58 PM
;) Just be sure that the links keep matching the profiles. Sucks that mine doesn't work. That'd be neato.

AlexC
04-20-2012, 11:00 PM
I had two extra users in my forum - test accounts - and once I deleted those, I just had to realign the ids through phpmyadmin. Took ages though - I had to go through all of the forum threads and posts and change the IDs there as well. Thank god there wasn't as many as I imagine there was on yours.

Maybe you can still do it on your dragon site?

SilverDragonTears
04-20-2012, 11:04 PM
269 members.... nah. lol, It shall stay as it is :)

AlexC
04-20-2012, 11:06 PM
How did you manage to get 269 members so quickly? Didn't you only release it a while ago?

SilverDragonTears
04-20-2012, 11:10 PM
I had more members but when 1.3.1 was released I had an oopsie and ended up restarting :/ SA has 5451!

AlexC
04-20-2012, 11:17 PM
*shakes head* That is amazing. There is just something really popular about adoptable sites for some reason.

SilverDragonTears
04-20-2012, 11:18 PM
It's fun :) I'd be a member to a lot more if I wasn't so busy running my own ;)

AlexC
04-21-2012, 08:26 AM
true. xD I used to be all over the place with different adoptable sites and then I started making my own and I just didn't do that as often.

AlexC
04-22-2012, 10:09 AM
So does anyone know how I could get my adoptables to be displayed on the forum profile or have a different type of profile on the main site?

And can someone show me how to rewrite the levelup page there?

Hall of Famer
04-22-2012, 11:08 AM
Well... This is gonna be quite difficult since you have to be familiar and comfortable with MyBB's coding style. You will need to modify the core script of Mybb user profile, which will require at least intermediate programming skills to complete since they use OOP(so yeah you have to not only understand OOP, but also code in OOP). I can help you with this in summer if I am not too busy working on the new version.

Another risk you have to consider is that you will not be able to upgrade the forum with their upgraders. Id say be extraordinarily careful if you take this path, since manually upgrading forum is beyond what I can help with.

Rewriting the levelup.php is gonna be a much easier task though. What do you want the page to look like?

AlexC
04-22-2012, 11:16 AM
I can leave that for now perhaps... I guess I can fiddle with stuff and see how I can do it otherwise.

I'd like it to add something like this to both the levelup and already clicked display;

Information:
Owned by: [owner]
This rat has [x] clicks and is [x] stage (level).
This rat is also [trade status].

That's about it, I believe.