1084

MM theme install

Comments for “MM theme install”
 

Posted by djnordeen on Wednesday 2nd March 2022 at 15:50 GMT

Ok, when you create a theme for the MM, I would like to know
What is the code to install the line, example from the carserve theme
Is this code generated by the Trongate app or by the creator of the Theme?
$carserv_theme = [
    "dir" => "carserv/default",
    "template" => "carserv.php",
];

$themes['carserv'] = $carserv_theme;
define('THEMES', $themes);
Early Adopter

djnordeen

User Level: Early Adopter

Date Joined: 20/08/2021

Posted by D3mon on Wednesday 2nd March 2022 at 16:13 GMT

I think the concise answer to your question is: when you've built a working theme, all you need is a .zip file of the new theme folder in public/themes. No additional code is required to get the TG Desktop App to install the theme. It's all done for you.

The Trongate DA uses the name of the theme's .zip file to add in all the extra code necessary to make it work.

----------

If you're creating a theme then all you'll need in your .zip file is the named theme folder. So lets say you've created a theme called 'groovytheme':

In your Trongate app you'll make a folder in your public/themes/groovytheme folder when you create your new theme to test it.

In that 'groovytheme' folder, you'll have a folder called 'default', and in that will be all your themes files, like a css folder, a js folder etc.

Make sure to include a file (in the 'default' folder root) with the same name as your theme e.g. groovytheme.php

Make a .zip of the entire groovytheme folder (found in public/themes). That's what you'll upload when you add your theme to the Module Marketplace.

Now, when ever your theme is installed using the Trongate Desktop App, it will copy the folder in your .zip to the public/themes of their app, then it will automagically update all the necessary files to make it a functional theme in Trongate.

If you download the theme directly from the Module Market, you need to:
1. Unzip the folder into the public/themes folder of your app
2. Edit your config/themes.php file and add the following:

$groovytheme = [
    "dir" => "groovytheme/default",
    "template" => "groovytheme.php",
];

$themes['groovytheme'] = $groovytheme;


3. Edit your templates/controllers/Templates.php file and add the following:

    function groovytheme($data) {
        load('groovytheme', $data);
    }


4. Edit your module to use the new theme as follows (I've used the welcome module as an example):

Inside the index() method, comment the default line of code and replace it with this code:
$data['view_module'] = 'welcome';
$data['view_file'] = 'home';
$this->template('groovytheme', $data); 

This comment was edited by D3mon on Wednesday 2nd March 2022 at 16:35 GMT

Level One Member

D3mon

User Level: Level One Member

Date Joined: 6/07/2021

Posted by djnordeen on Wednesday 2nd March 2022 at 17:30 GMT

Thanks for the very descriptive response.
However, my question is much more simple.
I was just wondering how the code was installed when you get the theme from the MM through the Trongate App.
How does the Trongate app know it is a theme?
Does the Trongate app add the lines of code or the theme creator?
Thanks, Dan
Early Adopter

djnordeen

User Level: Early Adopter

Date Joined: 20/08/2021

Posted by D3mon on Wednesday 2nd March 2022 at 17:43 GMT

Ah OK. I'm fairly sure it's the TG Desktop App that adds in the code. Not sure how as it an Electron app IIRC.

This comment was edited by D3mon on Wednesday 2nd March 2022 at 17:46 GMT

Level One Member

D3mon

User Level: Level One Member

Date Joined: 6/07/2021

Posted by DaFa on Wednesday 2nd March 2022 at 22:28 GMT

Nice post Gav on the detail of a theme setup in Trongate and you are right about the desktop app doing the magic when you install a theme from the TMM.

Here is the code that does the config:
    //build sample theme config text...
    var ditchText = `define('THEMES', $themes);`
    var replaceText = `
    $${themeName}_theme = [
        "dir" => "${configDir}",
        "template" => "${themeName}.php",
    ];

    $themes['${themeName}'] = $${themeName}_theme;
    define('THEMES', $themes);
    `;

    var newConfigText = themesConfigContent.replace(ditchText, replaceText)
    await file_manager.upsertFile(themesConfig, newConfigText)
        .catch((err) => {
            throw err
        })
Founding Member

DaFa

User Level: Founding Member

Date Joined: 30/11/2018

Posted by D3mon on Thursday 3rd March 2022 at 00:15 GMT

Thanks Simon. Yes that looks about right from what I've seen. Is that the language Electron uses? It seems very similar to PHP.
Level One Member

D3mon

User Level: Level One Member

Date Joined: 6/07/2021

Posted by DaFa on Thursday 3rd March 2022 at 03:28 GMT

Hi Gavin,

That's JavaScript, where Electron combines the Chromium rendering engine and the Node.js runtime

This comment was edited by DaFa on Thursday 3rd March 2022 at 06:39 GMT

Founding Member

DaFa

User Level: Founding Member

Date Joined: 30/11/2018

Posted by D3mon on Thursday 3rd March 2022 at 11:17 GMT

What would be very cool, is if a MM theme .zip import could have modules, so that a theme with multiple pages could be made fully functional right from installation. Say, if the theme .zip contained a modules folder in the root, then any folders within that could be copied into the users app modules folder.
Level One Member

D3mon

User Level: Level One Member

Date Joined: 6/07/2021

Posted by djnordeen on Thursday 3rd March 2022 at 16:06 GMT

Gavin, Yes that would be cool.

Also, I am wondering what a complete website would look like, Modules, Sub-modules, complete database tables.

Dan
Early Adopter

djnordeen

User Level: Early Adopter

Date Joined: 20/08/2021

Posted by D3mon on Thursday 3rd March 2022 at 16:33 GMT

Yes, me too but I think David has more or less decided to remove the full website type module in favour of a 'games' category.
Level One Member

D3mon

User Level: Level One Member

Date Joined: 6/07/2021

×