#1
|
||||
|
||||
Explore Help?
Kyttias helped me get this working, I give her my deepest gratitude. I don't need help anymore.
Last edited by cailynmae; 04-11-2015 at 02:53 PM. Reason: I got help, explore system working. Thanks Kyttias! |
#2
|
||||
|
||||
Ok, I'll begin with more of a general how-to guide to making your own pages before moving on to your specific questions at the end. It's good to have all this sort of in one place -- it'll help you do other stuff in the future, yeah?
Pages can be found in the root directory - or, well, their hard-coded side is there, anywhere. The view side is found in the view folder. It is necessary, to make a page, to make a file in each, following the same naming conventions as the others. I'd observe donate and donateview as an example, since they're pretty simple files. Usually I've been keeping my own 'page' files nearly empty, save for what needs to be there for it to operate, and only putting code into their 'pageview' file counterparts. Both exist in cases where you'd need to handle things like form submission. Basics As an example, for myself, I'll be creating a new page for pet missions. It will be accessible at "mysite.com/missions": /missions.php PHP Code:
PHP Code:
Pretty basic thus far. You can see that a document in view needs its title set. Then you can see I'm adding text to the page by adding a new Comment to the $document. The comment is in double quotes, and can contain HTML. Any HTML inside it that may need double quotes needs them replaced instead with single quotes. When you absolutely need to use double quotes, escape them by placing a backslash before them: PHP Code:
PHP Code:
Preventing Users Not Logged In In missions.php, this is one of the functions I included: PHP Code:
PHP Code:
Alright, let's talk about what sort of stuff you have access to. Well, anything, actually, so long as you know how! This framework is 'object oriented'. Object oriented PHP differs from standard, procedural PHP only in that it adds some new features. To a beginner, it's a lot of overwhelming, confusing new syntax. I'm new at this myself, but I'll try my best to explain. Let's start with this magical, important line (you'll see I've already included it in the files above): PHP Code:
Let's keep our view/missionsview.php file open (or whatever you chose to name yours), but also go open up our database. (On your hosting look for phpMyAdmin, it'll probably prompt you to log in.) Our first stop will be the table adopts_users. For ease of access, all of the columns in this particular table are accessible with the keyword 'user'. The framework already knows which user is logged in, and will pull data from the current user in the form of a variable. If you want to insert a variable into your page, you can wrap it in curly braces: PHP Code:
You'll notice not all of a user's data was stored in adopts_users. There's some more stored in adopts_users_profile. But how to get at it? Well, we can fetch the whole row relating to a current user like this: PHP Code:
What if we wanted to do something crazier, like count the total number of pets this user owns? Or find out what pet type they own the most of, and just how many of that pet they own? PHP Code:
For more information on database-related stuff, I'm going to direct you to this other post I made, and some more examples of queries I made to add to my stats page. Classes In object oriented programming, classes exist. Classes hold functions as 'methods' that can be reused again and again, to prevent writing redundant code. There's actually some pre-constructed functions you can use with $mysidia->user as before - thanks to the Member class! (Jeez, why didn't you say so, Kyt?) It's not immediately obvious - if you open up classes/class_user.php, you don't actually see much going on. But go open up classes/class_member.php - whaaaat, class Member extends User? Let's test one out PHP Code:
Ok, but what if we're not dealing with an user, but a pet? Well, we can instantiate a pet by it's id number, if we know it, as being a 'new OwnedAdoptable' - and then we'll have access to all the properties and functions available from classes/class_ownedadoptable.php. The OwnedAdoptable class takes the pet's adoptable id, it's aid, as a parameter. So, let's pick a random pet owned by the user: PHP Code:
You want to build an explore page, right? Well, now you know how to insert HTML into a page. I assume you've read up on plenty of tutorials on imagemaps, so you have a pretty good idea of what you're doing, so I'll jump right to your specific questions.
Whew, that was fun. Let me know if there's anything else!
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it. Last edited by Kyttias; 02-17-2016 at 02:06 PM. |
#3
|
||||
|
||||
Wow, thanks. That's pretty much all I need to know. I'll try it out a little later today, since I have some stuff to do. Thank you so much! This was very helpful.
|
#4
|
||||
|
||||
It's working! I just have to make the map, and the items and pets.
|
#5
|
||||
|
||||
Hmm, I take that back. Yesterday it was working just fine, today it is acting as though the explore pages(not the main one, though) don't exist. Hmm, odd...
EDIT: Okay, I got that fixed, but now it's not resetting exploretimes to 0 when it's supposed to... EDIT AGAIN: And I fixed that! Yay! Last edited by cailynmae; 04-11-2015 at 01:24 PM. Reason: found a solution |
#6
|
||||
|
||||
I'm glad things are working out! I actually learned a little bit while making my post, even. Mind if I repost some of this information a little later and ask for it to be stickied as a guide? I want to investigate form submission a little more first, like how to fill a drop down list with a list of pets, and run a few input validation tests so I can discuss security when I teach how to make forms, too. Is there anything else you'd like covered in a guide?
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it. |
#7
|
||||
|
||||
Sure, I actually was thinking this would be very helpful to someone looking to create an explore system. Maybe I'll make a proper mod to make things easier for people when I have some time(with your permission, of course). Thanks for your help, you can totally use your advice elsewhere if you want to.
|
#8
|
|||
|
|||
Kyttias' posts have helped me immensely but it seems I hate to leave well enough alone.
Here's code for more specific seasons: PHP Code:
Last edited by ewe; 03-30-2017 at 12:51 AM. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Quest- Explore System (Open Source) | squiggler | Tutorials and Tips | 4 | 07-23-2020 01:07 PM |
How To Create an Explore System in Mys. 1.3.4 | cailynmae | Tutorials and Tips | 42 | 07-17-2017 02:25 PM |
What's New? |
What's Hot? |
What's Popular? |