Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
Creating your own theme
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / M-BiTsy / M-BiTsy Support

2022-06-10 19:23:33
Hi guys,

Need a little bit of help on creating my new theme.

I have created the following:

Controller u2torrents folder. And copied the contact.php login.php recover.php nd signup.php files in there. Each file asked to load the "view" u2torrents.
Views u2torrents folder. And copied the contact.php login.php recover.php nd signup.php files in there - each in their own folder..
Libraries Style.php (inside attached file).
Views.php (inside attached file).

And also copied my assets of images and the theme.

Now when I got my Style and View file configured (hopefully correct) to look for the u2torrents controller and views...I am not seeing the changes in my website.
Instead I need to make changes inside the "user" files to make things work.

This I do not understand fully, and wonder if I missed something here in me changing things.

https://drive.google.com/file/d/1mh9aBy8sqlBYNFD0Okxqax7vfPQtyZo3/view?usp=sharing
If It Ain't Dutch, It Ain't Much!!
2022-06-11 04:34:40
the controllers need to go in the user folder replacing existing ones

controllers are done automatic by url so need to be in same place . a example of the controller

// Get Data
$sql = array('some sql query');
$id = $_GET['id'];

// Set Data
$data = [
   'id' => $id,
   'sql' => $sql
]

// Send Data
View::render('signup/index', $data, 'u2torrents');


for style everything is in views folder and your view class is set correctly, so two ways
move controllers to user folder or in any controller change View::render to u2torrents View::render('folder/anyview', $data, 'u2torrents');
2022-06-11 17:23:55
Thanks for the quick feedback!

So in the controllers folder I use the files in the "user" folder.

Then next, if I want a different header for my block for the login page, I would add the following to the Libraries/Styles.php file correct?



And next call this bit in the Libraries/View.php file correct?



Same for the footer etc?

Or am I doing this totally wrong?
If It Ain't Dutch, It Ain't Much!!
2022-06-11 17:49:45
This is actually a really good idea and I want to replicate this to a AJAX-based page that allows custom colours and backgrounds to header, sections, font etc, setting the CSS properties on the fly allows instant changes - as they click it saves both ways.

Very cool idea!
2022-06-11 19:32:45
STorrents2020:
This is actually a really good idea and I want to replicate this to a AJAX-based page that allows custom colours and backgrounds to header, sections, font etc, setting the CSS properties on the fly allows instant changes - as they click it saves both ways. Very cool idea!


This is also where I wanna make my changes, or rather keep my changes --> in the themes folder.

Thus by adding specific theme files (like in my example loginfooter) or by changing the custom css file properties u load a whole new theme.
In my css file for example, I currently have:

.card_login {
.card-header_login {
.card-body_login {
.frame-header_login {

Which will have different properties then the normal card/frame settings in the css file, and which would apply to different pages on the site.

I would like to not edit and change the default M-BiTsy code at all so that it can be easily update.
It should be just a configuration change in the settings for the site to load a whole new interface.

This is also why I got confused that I still had to change current system files....which will may get lost with next update of M-BiTsy code.

If It Ain't Dutch, It Ain't Much!!
Last edited by Propaganda on 2022-06-11 19:34:43
2022-06-12 04:03:09
i would go down a oop way and put any changes in a class

(notice i use self:: in last function)
<?php

class U2
{

   // Default Header
   public static function header($title = "")
   {
       if (!isset($_SESSION['loggedin'])) {
           Guests::guestadd();
       }
       if ($title == "") {
           $title = Config::get('SITENAME');
       } else {
           $title = Config::get('SITENAME') . " : " . htmlspecialchars($title);
       }
       require_once "assets/themes/" . (Users::get('stylesheet') ?: Config::get('DEFAULTTHEME')) . "/header.php";
   }
   
   // Default Footer
   public static function footer()
   {
       require_once "assets/themes/" . (Users::get('stylesheet') ?: Config::get('DEFAULTTHEME')) . "/footer.php";
   }
   
   // Default Block Header
   public static function begin($caption = "-")
   {
       $blockId = 'f-' . sha1($caption);
       ?>
       <div class="card">
           <div class="card-header text-center frame-header">
               <?php echo $caption ?>
               <a data-toggle="collapse" href="#" class="showHide" id="<?php echo $blockId; ?>" style="float: right;"></a>
           </div>
           <div class="card-body frame-body slidingDiv<?php echo $blockId; ?>">
       <?php
   }
   
   // Default Block Footer
   public static function end()
   {
       ?>
           </div>
       </div>
       <div class="block-footer"></div>
       <?php
   }

   public static function render($file, $data = [], $page = false)
   {
       // Start With No Error
       $error = 0;

       // Debug
       $GLOBALS['debugviewdata'] = debugviewdata($data);

       if ($page == 'utorrents') {
           // Does User View Exist
           if (file_exists('../app/views/user/' . $file . '.php')) {
               self::header($data['title']);
               self::begin($data['title']);
               require_once "../app/views/user/" . $file . ".php";
               self::end();
               self::footer();
               return;
           } else {
               $error = 1;
           }
       }

       // The View Isnt There !
       if ($error === 1) {
           Redirect::autolink(URLROOT, "View $file does not exist");
       }
   }

}


this way on home for example you can use U2::header & in other controllers U2::render('page',$data,'u2torrent);
now lets say you update in a year & only have changed 50% of views - with controllers just mass edit view::render to u2::render and drop your template folder in job done.

or another example of the last function where instead we add condition on url if you have seperate style for login, signup etc
    public static function render($file, $data = [], $page = false)
   {
       // Start With No Error
       $error = 0;

       // Debug
       $GLOBALS['debugviewdata'] = debugviewdata($data);

           // Does User View Exist
$url = $_GET['url'] ?? '';
if ($url == 'signup' || $url == 'recover') {
           if (file_exists('../app/views/u2torrent/' . $file . '.php')) {
               self::signupheader($data['title']);
               self::begin($data['title']);
               require_once "../app/views/u2torrent/" . $file . ".php";
               self::end();
               self::signupfooter();
               return;
           } else {
               $error = 1;
           }
} elseif ($url == 'login') {
           if (file_exists('../app/views/u2torrent/' . $file . '.php')) {
               self::header($data['title']);
               self::loginbegin($data['title']);
               require_once "../app/views/u2torrent/" . $file . ".php";
               self::end();
               self::loginfooter();
               return;
           } else {
               $error = 1;
           }
} else {
           if (file_exists('../app/views/user/' . $file . '.php')) {
               self::header($data['title']);
               self::begin($data['title']);
               require_once "../app/views/user/" . $file . ".php";
               self::end();
               self::footer();
               return;
           } else {
               $error = 1;
           }
}
       }

       // The View Isnt There !
       if ($error === 1) {
           Redirect::autolink(URLROOT, "View $file does not exist");
       }
   

}


the last option it good because if url is not listed you could fall back on default so updating would be put controllers in notepad mass edit View::render('signup/index', $data, 'user'); to U2::render('signup/index', $data, 'user');
in last option i removed         if ($page == 'utorrents') {  so you could keep as 'user' notice the require_once the url should be able to cover all changes

update - lets make it so you only edit one file you could replace the View class with something like this
this means you wouldnt have to change to u2torrents from user View::render('signup/index', $data, 'user');
<?php

class View
{
   
   // Default Header
   public static function u2header($title = "")
   {
       if (!isset($_SESSION['loggedin'])) {
           Guests::guestadd();
       }
       if ($title == "") {
           $title = Config::get('SITENAME');
       } else {
           $title = Config::get('SITENAME') . " : " . htmlspecialchars($title);
       }
       require_once "assets/themes/" . (Users::get('stylesheet') ?: Config::get('DEFAULTTHEME')) . "/header.php";
   }
   
   // Default Footer
   public static function u2footer()
   {
       require_once "assets/themes/" . (Users::get('stylesheet') ?: Config::get('DEFAULTTHEME')) . "/footer.php";
   }
   
   // Default Block Header
   public static function u2begin($caption = "-")
   {
       $blockId = 'f-' . sha1($caption);
       ?>
       <div class="card">
           <div class="card-header text-center frame-header">
               <?php echo $caption ?>
               <a data-toggle="collapse" href="#" class="showHide" id="<?php echo $blockId; ?>" style="float: right;"></a>
           </div>
           <div class="card-body frame-body slidingDiv<?php echo $blockId; ?>">
       <?php
   }
   
   // Default Block Footer
   public static function u2end()
   {
       ?>
           </div>
       </div>
       <div class="block-footer"></div>
       <?php
   }

   // Return View Template
   public static function render($file, $data = [], $page = false)
   {
       // Start With No Error
       $error = 0;

       // Debug
       $GLOBALS['debugviewdata'] = debugviewdata($data);

       if ($page == 'user') {

           // GET URL
           $url = $_GET['url'] ?? '';
           if ($url == 'signup' || $url == 'recover') {
               if (file_exists('../app/views/u2torrent/' . $file . '.php')) {
                   self::u2header($data['title']);
                   self::u2begin($data['title']);
                   require_once "../app/views/u2torrent/" . $file . ".php";
                   self::u2end();
                   self::u2footer();
                   return;
               } else {
                   $error = 1;
               }
           } elseif ($url == 'login') {
               if (file_exists('../app/views/u2torrent/' . $file . '.php')) {
                   self::u2header($data['title']);
                   self::u2begin($data['title']);
                   require_once "../app/views/u2torrent/" . $file . ".php";
                   self::u2end();
                   self::u2footer();
                   return;
               } else {
                   $error = 1;
               }
           } else  {
               if (file_exists('../app/views/user/' . $file . '.php')) {
                   Style::header($data['title']);
                   Style::begin($data['title']);
                   require_once "../app/views/user/" . $file . ".php";
                   Style::end();
                   Style::footer();
                   return;
               } else {
                   $error = 1;
               }
           }

       } elseif ($page == 'admin') {

           // Does Admin View Exist
           if (file_exists('../app/views/admin/' . $file . '.php')) {
               Style::adminheader('Staff Panel');
               Style::adminnavmenu();
               Style::begin($data['title']);
               require_once "../app/views/admin/" . $file . ".php";
               Style::end();
               Style::adminfooter();
               return;
           } else {
               $error = 1;
           }

       } else {

           // Does Requalar View Exist
           if (file_exists('../app/views/user/' . $file . '.php')) {
               require_once "../app/views/user/" . $file . ".php";
               return;
           } else {
               $error = 1;
           }
           
       }
       // The View Isnt There !
       if ($error === 1) {
           Redirect::autolink(URLROOT, "View $file does not exist");
       }
   }

}
Last edited by M-jay warn on 2022-06-12 05:07:54
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 2
  • Members: 0
  • Guests online: 2
  • Comments: 3
  • Messages: 1,728