-
Notifications
You must be signed in to change notification settings - Fork 1k
Custom Templates
When I started developing MPOS I wanted to make sure that pool operators have complete freedom over the template used on the front end. I could say this was the main reason, but to be honest: I am really bad with web design. Since I am unable to work on projects that combine PHP and HTML code, I used an old framework of mine that is using Smarty Templates. It turned out to work really well when migrating the old mmcfe theme over, I decided to stick with it.
Adding your own custom templates to MPOS is pretty easy and can be done in two ways: file based templates or SQL based templates.
Creating your own template, or just copying the original one and customize it, is pretty straight forward:
- Create folders for your template in
site_assets
andtemplates
- Create a master template file
- Create templates for all pages (or start with imported default files)
You can always use the existing template as a reference. If you don't want to use certain data on them, just leave it out from the tpl
version you are creating.
I highly recommend turning on PHP errors to the browser. This will allow for easier error spotting than having to check a logfile! If you still want to use the logfile method, use tail - f which will let you view updates to the file without having to reopen.
#Basics To create a file based template its recommended to use a premade template of some kind and split the code into various sections including:
- Navbar
- Breadcrumb
- Header
- Footer
- Alert
- Main
To create a theme file first run mkdir public/templates/ and mkdir public/site_assets/ To proceed from here copy all the files from the MPOS theme folders into the new theme folder and copy all css, js and img files into the appropriate dir under site_assets. Edit the master.tpl in the public/templates/ and begin to create or paste the code for the main layout including setting the names for all the areas as done already in the mpos theme files.
When creating the globals it is essential for them to be global as they will be used on every page as an exact copy. This includes the header, footer, nav bars, breadcrumbs and other files. It is essential that all possible content is escaped to reduce the likelihood of XSS attacks.
It is now time to add the theme and make any required modifications to each page in order to make it fit the whole site
You can visit the site and switch to the new theme using the theme dropdown in the admin settings panel. To view any errors it is recommended to enable PHP errors or view the apache2 or nginx error logs
Even though supported via GUI, these should only be used for very minor changes in templates. We have had issues in the past with templates not being parsed properly when read from the database. Changing a few lines here and there won't break anything, but for real template work you should consider using the file based template method!
Thanks to a very active community member, MPOS is now supporting SQL based templates! You can simply change default templates supplied by MPOS through the administration panel. The file based version is displayed in the bottom text area and can be copied into the custom template box.
Ensure you activate your SQL template before closing the page. It will not change unless you activated your new content!
As you can see, it's pretty easy to start your own look and feel. If you have created a theme from scratch, please let me know so I can add it to a list of pools running their own customizations!
-
- installation of Redis requires TCL 8.5 or newer TCL Download Page