Need something cleaner..

griimnak

You're a slave to the money then you die
Jul 20, 2013
957
800
So, atm i have a very poor widget handler in ghabbo

PHP:
class gWidget {
    public static function loadFooter() {
        return'
            <div id="container-footer">
            <p id="footer">
                '.gConfig::get('site->name').' Hotel is not affiliated with Sulake Co or Habbo Hotel .
                <br>
                <a href="'.gConfig::get('site->path').'/me" target="_self">Homepage</a> | <a href="'.gConfig::get('site->path').'/rules" target="_self">Rules</a> | <a href="#" target="_self">Privacy Policy</a>
            </p>
        </div>
             ';
    }
}

I kinda wanna just have a folder with widgets like widget.footer.html, but i'm not sure how i'd do that in php.
perhaps get_file_contents and return the data??
 

Jaden

not so active
Aug 24, 2014
886
263
So, atm i have a very poor widget handler in ghabbo

PHP:
class gWidget {
    public static function loadFooter() {
        return'
            <div id="container-footer">
            <p id="footer">
                '.gConfig::get('site->name').' Hotel is not affiliated with Sulake Co or Habbo Hotel .
                <br>
                <a href="'.gConfig::get('site->path').'/me" target="_self">Homepage</a> | <a href="'.gConfig::get('site->path').'/rules" target="_self">Rules</a> | <a href="#" target="_self">Privacy Policy</a>
            </p>
        </div>
             ';
    }
}

I kinda wanna just have a folder with widgets like widget.footer.html, but i'm not sure how i'd do that in php.
perhaps get_file_contents and return the data??
Boy that's nasty.
 

LeChris

https://habbo.codes/
Sep 30, 2013
2,786
1,395
I use the database to read what plugins are being used and on what pages for instance on the home page it'll say "Plugin (1) gets loaded (second) on the (right) side and plugins are stored via a class in their owner widget folder and then the plugin developer can make usable asset data for the plugin in the folder. So to clean it up, perhaps plan out a new approach to it rather then the predefined one if you're wanting users to be able to change their experience or just autoload all plugins in a folder if you want to do it an easier way
 

griimnak

You're a slave to the money then you die
Jul 20, 2013
957
800
I use the database to read what plugins are being used and on what pages for instance on the home page it'll say "Plugin (1) gets loaded (second) on the (right) side and plugins are stored via a class in their owner widget folder and then the plugin developer can make usable asset data for the plugin in the folder. So to clean it up, perhaps plan out a new approach to it rather then the predefined one if you're wanting users to be able to change their experience or just autoload all plugins in a folder if you want to do it an easier way
Yeah I thought about that but idk, i feel like using a database for that is too... "normal".
I wanna try something different, either storing them in a file and loading them in. OR storing it in an array? a big, big array.
 

Jaden

not so active
Aug 24, 2014
886
263
This what you looking for?

PHP:
<?php

class gWidget
{
    const WIDGET_LOCATION = HABBO . "/Widgets/widget.";
    const WIDGET_EXTENSION = ".txt";

    public static function getWidget($Widget)
    {
        $Path = WIDGET_LOCATION . $Widget . WIDGET_EXTENSION;
        if (!file_exists($Path)) {
            echo "gCMS Templating Error ~ Could not find widget " . $Widget;
            exit;
        }
        $Contents = file_get_contents($Path);
        // Cache?
        echo $Contents;
    }
}
 

griimnak

You're a slave to the money then you die
Jul 20, 2013
957
800
I'm interested in trying:
PHP:
<?php
class gWidget {
    public static function load($file) {
        if (isset($file)) {
            $docInstance = new DOMDocument();
            $docInstance->loadHTMLFile('pub/'.gConfig::get('site->tpl').'/widgets/$file');
        } else {
            gError::generic('file not set.');
        }

        return $docInstance->saveHTML();
    }
}
thoughts?
 
This what you looking for?

PHP:
<?php

class gWidget
{
    const WIDGET_LOCATION = HABBO . "/Widgets/widget.";
    const WIDGET_EXTENSION = ".txt";

    public static function getWidget($Widget)
    {
        $Path = WIDGET_LOCATION . $Widget . WIDGET_EXTENSION;
        if (!file_exists($Path)) {
            echo "gCMS Templating Error ~ Could not find widget " . $Widget;
            exit;
        }
        $Contents = file_get_contents($Path);
        // Cache?
        echo $Contents;
    }
}
oh, you beat me to it xd
i think i like mines better though :v ggwp
 

Jaden

not so active
Aug 24, 2014
886
263
I'm interested in trying:
PHP:
<?php
class gWidget {
    public static function load($file) {
        if (isset($file)) {
            $docInstance = new DOMDocument();
            $docInstance->loadHTMLFile('pub/'.gConfig::get('site->tpl').'/widgets/$file');
        } else {
            gError::generic('file not set.');
        }

        return $docInstance->saveHTML();
    }
}
thoughts?
 

oh, you beat me to it xd
i think i like mines better though :v ggwp
= Higher memory usage and I'm pretty sure its slower.
You do you man, your CMS.
 

Users who are viewing this thread

Top