Remove "already leveled creature today" text?
I'm making simple profile pages for the adoptables on my site using their levelup pages, but the text that pops up when a member has already leveled a creature kind of removes the whole thing.
Basically what I've done is added new comments to the levelup view file, and I want that to display even if a member has clicked the adoptable that day, so is there an easy way to disable the "already leveled creature today" text? I still want the adopts to only be clicked once per user though. |
My work around for this was way too hacky in bypassing the 'error' of 'already leveled creature today'. I'm curious as to HoF's answer.
Perhaps you can glean something out of what I've got (though I toned down the message variable to cut out most of my profile stuff that'd be too custom, left in the usual data) - Note that this is JUST the click function in levelup.php, not the whole file. Don't use it as is, try to understand it. @w@ Good luck! There are numerous reasons you can't use this as-is, mostly because some of it's been modified in ways unique to my site. I've change a few core page urls, so this part, for example - if ($mysidia->user->username == $this->adopt->getOwner()){ $manage_btn = "<a class='btn btn-sm btn-info' href='../../yournovu/manage/{$this->adopt->getAdoptID()}'><i class='fa fa-gear'></i> Manage Your Novu</a>"; } else { $manage_btn = ""; } - has things linking to a yournovu/manage/ page, because my adoptables are called Novu, rather than whatever the original url for that link should be. I forgot. @w@ Stuff like that is different. I also don't know if the system originally kept track of pet birthdays, so that may break, etc. And, all in all, I DON'T recommend what I've done to get the profile page to work. (I also added in some Javascript elsewhere that deletes the error title itself but that's not included.) And why don't I like my solution? Because it's still using what was there - throw new LevelupException($message); - and I just changed the $message. It's still an Exception being thrown and I'd love to rewrite the entire thing and avoid using exceptions but I don't know how. It's expecting an error to be thrown if things are just so, and I'm just making it look like there wasn't an error. . . . Basically, HoF, I think what we want (for future releases) are profile pages for our pets that are the same no matter what - whether you've visited the pet or not, whether it's yours or not, and whether it's frozen or not. Rather than change the entire page, just add in a small memo to the pet's profile that says "Thanks for visiting this pet", a link back to the management page if it's your pet, and/or a notification that the pet didn't gain experience because the owner has it frozen. |
I'm very curious about this as well as I've been trying to do this for a bit now (but 96% fail with understanding PHP).
|
Thank you Kyttias! I'm definitely going to see if I can incorporate any of this into my own site's code! (:
|
Nevermind, I got it working! For anyone who, like me, is not super code savvy but trying to get the image to display in the levelup.php file I used this (I'm sure I could have done something more effective but this works perfectly fine so *shrug*!):
PHP Code:
|
Installed it onto my site but haven't had a chance to change much. Super late right now. Gonna fiddle with it more tomorrow! Thanks so much Kyttias! And thanks Abronsyth for the image code. c:
|
Basically, the error is still being thrown. You could use a bit of jQuery to cover it up (just add it alongside the rest - it's in script element tags, so it won't be seen like ordinary html - I included it after the last </div> I'm using on my pet's profiles before even closing the message variable). Of course, this'll only work if you have jQuery as part of your theme's template (Bootstrap theme definitely does):
Code:
<script>$(\"h2:contains('An error has occurred.')\").remove();</script> And, incidentally, you can change your error message text site-wide from lang/lang_global.php -- so if you happen to change it there, be sure to update the snippet I just provided to reflect that. (** And yeah, Abronsyth, I forgot to include a pet image -- my pet images are rendered with some custom code, so I took my bit out but couldn't remember the original -- thanks for providing that snippet of code!!) |
Thanks so much Kyttias! I'm having trouble with removing the error part. I think the jquery isn't being enabled maybe. How exactly do I enable jquery on my site?
I've tried adding this to my theme's header.tpl but it's not working: HTML Code:
<script src="{$home}/jquery/jquery-1.11.3.min.js"></script> I've also tried the hosted links from google and microsoft but they're not working either. :c |
Weird, but, check that the jQuery library is being loaded with your pages. This really is as simple as linking it and using it. Is the link you added to your header shower up when a page loads/you sure you added it to the right theme? The file does seem to exist in that location on the live version of your site, but a link to it does not appear when I load a page - but maybe you're testing elsewhere.
But, perhaps more to the point, your page titles seem to be in h1 not in h2. Change the code I gave you so it knows to check an h1 tag instead. |
Oh GAWD that was probably the problem. They were h2 and not h1.
I removed the jquery link because i noticed my pages loaded slow after it was added... Like really slow. But that's probably why you didn't see the link anymore. Ahh, thanks! I'll see if it works now. But if it's still slow I think I'll just change the error message instead... Unless there's a way to make it not cause pages to be loaded so slow? Lol Thanks again, you're amazing! <3 |
Is there a way to make it so that the pet's "profile" is shown when the pet is frozen? I've tried several things but to no avail as of yet.
|
I did some thinking on this today. You can find this line in levelup.php and comment it out (just make it so this whole elseif clause doesn't fire) -
PHP Code:
PHP Code:
Instead, we're going to pop on back up to where we checked if the pet had been visited today or not. This line opens up this clause: PHP Code:
PHP Code:
PHP Code:
Okay, so, ACTUALLY, if you used the code I gave originally without modifying it much, you'll see that I already did included something to happen if you're somehow on the page but hadn't visited the pet - the word 'Play' instead of the thankyou message. (To be honest I want to eventually create a feature so pet's aren't automatically counted as being clicked/visited as soon as the page loads, but wait until a button is pressed, so that's why it's there - well that doesn't work like that, and I haven't invented such a thing yet.) Regardless, here's that bit of code how I gave it in the original post: PHP Code:
|
Aha! Excellent, thank you Kyttias! I wasn't too far off but I see now where I was going wrong.
|
Does anyone have the code to make this simple profile page ? I've tried fixing up the code here for levelup and not having too much success.
This is the last thing I need for my sites, a basic working public pet profile page :) Can anyone help on what to change/take out to make it work ? I just get white pages no matter what I do ... |
I have the profiles for my pets set up:
But would it be possible to have the same show up on the view_levelup file? I've tried tinkering but it does not want to work, and I think I lack the understanding to know 100% where I've gone wrong... for now, I've added a link under all the text that refreshes the page to take you to their 'profile'. Thank you ^_^ EDIT: I made some changes to my levelup view file! It now looks the same as my levelup so it's almost like the same page... I'm pretty happy I did it myself XD Took a while to realise I had to do {$adopt->whatever} and not {$this->adopt-whatever}... XD |
I don't understand how to make the public profile. I have it working if you've already played with the pet but where is the code for the actual public profile?
|
All times are GMT -5. The time now is 02:20 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.