Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 12-18-2015, 09:55 PM
tahbikat's Avatar
tahbikat tahbikat is offline
Member
 
Join Date: Feb 2014
Location: Louisiana
Posts: 408
Gender: Female
Credits: 57,654
tahbikat is on a distinguished road
Default 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.
Reply With Quote
  #2  
Old 12-19-2015, 04:51 AM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 110,875
Kyttias is on a distinguished road
Default

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!

  Spoiler: hidden 

PHP Code:
public function click(){
    
$mysidia Registry::get("mysidia");
    
$date = new DateTime;
    
$ip secure($_SERVER['REMOTE_ADDR']);

    
/*... First check if the system to levelup pets is enabled ...*/
    
if($this->settings->system != "enabled") { throw new NoPermissionException("disabled"); }

    
/*... Then check if the user has already visited the pet today ...*/
    
elseif($this->adopt->hasVoter($mysidia->user$date)){
        if(
$this->adopt->hasNextLevel()){
            
$nextLevel $this->adopt->getNextLevel();
            
$requiredClicks $nextLevel->getRequiredClicks();
        }

        
$gender_lookup $mysidia->db->select("owned_adoptables", array("gender"), "aid = '{$this->adopt->getAdoptID()}'")->fetchColumn();
        if (
$gender_lookup == "m") { $gender "Male"$pronoun "him"; } else { $gender "Female"$pronoun "her"; } 

        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 ""; }

        if(
$this->adopt->hasNextLevel()){
            
$level $this->adopt->getNextLevel();
            
$levelupClicks $this->adopt->getLevelupClicks();
            
$toNext "(LVL ".$level->getLevel()." in ".$levelupClicks." more EXP)"
        } 
        else { 
$toNext "(MAX)"; }

        if(
$this->adopt->getTradeStatus() == "fortrade") { $tradestatus "<b>For Trade</b>"; } 
        else { 
$tradestatus "<b>Not For Trade</b>"; }

        
$message "<div class='adopt_profile'>    <h2>{$this->adopt->getName()}</h2>    ";
        
        
// If you've already seen the pet today:
        
if ($this->adopt->hasVoter($mysidia->user$date)){
            
$message .= "<div style='float: right; margin-right: 15%; margin-top: -15px;'><b>Thanks!</b>  You played with this Novu today!</div>";
        }
        
// If you haven't seen the pet today:
        
if (!$this->adopt->hasVoter($mysidia->user$date)){
            
$message .= "<div style='display: inline;'><span class='button'><i class='fa fa-paw'></i> Play</span></div>";
        }
            
$message .= "{$manage_btn}
                        <ul>
                        <li>Travels With: <a href='/profile/view/
{$this->adopt->getOwner()}'>{$this->adopt->getOwner()}</a></li>
                        <li>Birthday: 
{$this->adopt->birthday}</li>
                        <li>Species: 
{$this->adopt->getType()}</li>
                        <li>Gender: 
{$gender}</li>
                        <li>LVL: 
{$this->adopt->getCurrentLevel()} {$toNext}</li>
                        <li>Total EXP: 
{$this->adopt->getTotalClicks()}</li> 
                        <li>Trade Status: 
{$tradestatus}</li> 
                        </ul>
                        "
;

        throw new 
LevelupException($message);
    } 

    
/*... But do this if the pet is frozen! ...*/
    
elseif($this->adopt->isFrozen() == "yes") { throw new LevelupException("frozen"); }

    
/*... This one, if enabled, would prevent users from visiting a pet too much a day ...*/
    # elseif($mysidia->user->getVotes() > $this->settings->number) { throw new LevelupException("number"); }

    /*... If this setting were on in the backend, it would prevent the users from visiting their own pets ...*/
    # elseif($this->settings->owner == "disabled" and $this->adopt->getOwner() == $mysidia->user->username){ throw new LevelupException("owner");}
    
    /*... If the visitor has not seen the pet today, this will be displayed and the pet will level up! ...*/
    
else{
        
$newClicks $this->adopt->getTotalClicks() + 1;
        
$this->adopt->setTotalClicks($newClicks"update");
        
$mysidia->db->insert("vote_voters", array("void" => NULL"date" => $date->format('Y-m-d'), "username" => $mysidia->user->username"ip" => $ip"adoptableid" => $mysidia->input->get("aid")));         
        
        
$ago date('Y-m-d'strtotime('-40 days'));
        
$mysidia->db->delete("vote_voters""date < '{$ago}'");    

        if(
$this->adopt->hasNextLevel()){
            
$nextLevel $this->adopt->getNextLevel();
            
$requiredClicks $nextLevel->getRequiredClicks();
            if(
$requiredClicks and $newClicks >= $requiredClicks) { $this->adopt->setCurrentLevel($nextLevel->getLevel(), "update"); }
        }
        
        
$reward $mysidia->user->clickreward($this->settings->reward);
        
$mysidia->user->changecash($reward);            
        
$this->setField("adopt"$this->adopt);
        
$this->setField("reward", new Integer($reward));            
    }



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.
__________________
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; 12-19-2015 at 03:53 PM.
Reply With Quote
  #3  
Old 12-19-2015, 09:37 AM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 133,132
Abronsyth is on a distinguished road
Default

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).
__________________
My Mods Site (1.3.4, 2020 Mods)
Reply With Quote
  #4  
Old 12-20-2015, 03:15 AM
tahbikat's Avatar
tahbikat tahbikat is offline
Member
 
Join Date: Feb 2014
Location: Louisiana
Posts: 408
Gender: Female
Credits: 57,654
tahbikat is on a distinguished road
Default

Thank you Kyttias! I'm definitely going to see if I can incorporate any of this into my own site's code! (:
Reply With Quote
  #5  
Old 12-21-2015, 07:12 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 133,132
Abronsyth is on a distinguished road
Default

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:
<img src='{$this->adopt->getImage()}'/> 
__________________
My Mods Site (1.3.4, 2020 Mods)

Last edited by Abronsyth; 12-22-2015 at 11:57 AM.
Reply With Quote
  #6  
Old 12-24-2015, 06:30 AM
tahbikat's Avatar
tahbikat tahbikat is offline
Member
 
Join Date: Feb 2014
Location: Louisiana
Posts: 408
Gender: Female
Credits: 57,654
tahbikat is on a distinguished road
Default

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:
Reply With Quote
  #7  
Old 12-24-2015, 03:58 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 110,875
Kyttias is on a distinguished road
Default

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>
The code literally removes any h2 element that contains the words "An error has occurred." - gotta love jQuery. The quotes are backslashed as they need to be going into the $message variable. Can't have quotes inside other quotes inside other quotes without the system getting confused, so, backslashes. Yay. -_- (It originally took me a while to figure out.)

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!!)
__________________
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; 12-24-2015 at 04:05 PM.
Reply With Quote
  #8  
Old 12-25-2015, 01:35 AM
tahbikat's Avatar
tahbikat tahbikat is offline
Member
 
Join Date: Feb 2014
Location: Louisiana
Posts: 408
Gender: Female
Credits: 57,654
tahbikat is on a distinguished road
Default

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 made a jquery folder with the jquery library in it, so that's why I was using that. ^
I've also tried the hosted links from google and microsoft but they're not working either. :c
Reply With Quote
  #9  
Old 12-25-2015, 11:50 AM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 110,875
Kyttias is on a distinguished road
Default

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.
__________________
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.
Reply With Quote
  #10  
Old 12-26-2015, 05:53 AM
tahbikat's Avatar
tahbikat tahbikat is offline
Member
 
Join Date: Feb 2014
Location: Louisiana
Posts: 408
Gender: Female
Credits: 57,654
tahbikat is on a distinguished road
Default

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
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 01:12 AM.

Currently Active Users: 716 (0 members and 716 guests)
Threads: 4,081, Posts: 32,031, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636