Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Addons and Modifications > Mys v1.3.x Mods

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 01-19-2015, 01:35 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 110,919
Kyttias is on a distinguished road
Arrow Index Page Mod (Use PHP inside Index!)

new index
I really wanted to use some PHP inside my index page, but because it was hooked up to the AdminCP as a custom document, no matter how many modifications I made to CKEditor, I still couldn't get it to work. So... I turned to HoF and asked about it. It turns out, we can just modify our view/indexview.php to be like all the other files in view/, and modify it similarly:
PHP Code:
<?php

class IndexView extends View{
    
    public function 
index(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document;        
        
$document->setTitle(" Your Title Here ");
        
        
$document->add(new Comment("<!-- START -->

            <p> Place all your html here! </p>
            
            <div class='well'>
                <p>You MUST use single quotes around src/class/id/attributes/inline styles!!</p>
                <span style='float: left;'>Don't forget!</span>
            </div>

        <!-- END -->"
FALSE));
    
    } 
}
?>
If you ever must use quotations in your html, be sure to cancel them out by adding a backslash before them. \"Okay?\", she asks.

If you ever feel the need to break your html to write more PHP, be sure to close it. Our html is inserted into Comments, so be sure to properly close it. The FALSE parameter means there will be no linebreak. If you leave FALSE out, there will be a linebreak (that is, a <br> will be inserted).
PHP Code:
$document->add(new Comment(" Our HTML here! "FALSE)); 
working with variables
Now you're free to add php wherever you need to. To print a variable into your html, wrap it inside inside {brackets} and always start with a $. Be sure to set variables before you need to use them, to get the intended results.

PHP Code:
/* This will set $name to "Guest" if logged out, or the user's username if logged in! */
$name = (!$mysidia->user->isloggedin)?"Guest":$mysidia->user->username;

$document->add(new Comment(" Welcome, {$name}! "FALSE)); 
five random pets
For something more complicated, try adding this inside the index function! It will show you five random pets!
PHP Code:
$document->add(new Comment("<div class='row'><h4>Random 5 Pets</h4>"FALSE));
        
$stat_rand5 $mysidia->db->select("owned_adoptables", array("aid"), "1 ORDER BY RAND() DESC LIMIT 5");        
        while(
$aid $stat_rand5->fetchColumn()){
            
$adopt = new OwnedAdoptable($aid);    
            
$document->add(new Comment("
                <div style='display: inline-table; text-align: center;'>
                <a href='levelup/click/
{$adopt->getAdoptID()}'><img src='{$adopt->getImage()}'></a></br>
                  <a href='levelup/click/
{$adopt->getAdoptID()}'><b>{$adopt->getName()}</b></a> the <small><b>LVL.</b> {$adopt->getCurrentLevel()}</small> {$adopt->getType()}</div>
              "
FALSE));
        }
        
$document->add(new Comment("</div>"FALSE)); 
You might need to set a width on those images with some inline styling (perhaps even one that's a percentage, which is entirely why I'm not using $this->adopt->getImage("gui");).
__________________
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; 03-05-2016 at 11:14 AM.
Reply With Quote
  #2  
Old 01-19-2015, 11:49 PM
MikiHeart's Avatar
MikiHeart MikiHeart is offline
Premium Member
 
Join Date: Apr 2009
Posts: 187
Gender: Female
Credits: 23,379
MikiHeart
Default

Thank you <3 I was going to do this myself.
I didn't think of listing pets though!
I will be adding news from the news addon onto my front page. That will be fun! I'll share that code when I've got it ^^
Reply With Quote
Reply

Tags
index


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adopt pages, and general adopt/index page :L blondbananamix Questions and Supports 26 07-22-2011 01:12 PM
Replace Index Page SilverDragonTears Questions and Supports 0 06-02-2011 10:24 PM
Implementing Scrollbox on Index Page Plague Questions and Supports 6 04-09-2011 07:28 PM
Error on Install index.php page. Kitty Questions and Supports 4 01-08-2011 03:32 AM
Use CutePHP in index. Xius Questions and Supports 3 10-10-2009 08:37 PM


All times are GMT -5. The time now is 12:51 PM.

Currently Active Users: 766 (0 members and 766 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