We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42110
    • 5 Posts
    Hello,
    I'm coming from CodeIgniter and Yii Php frameworks, and I feel that I have to learn about Modx (I also try concrete5).
    It is very surprising when using Modx because a lot of things come under the hood.
    After half a day I can set up a web site, with pages ...
    But I'm unaware how to set up, programmatically, a theme, a template.
    ---
    I downloaded the bootstrap theme proposed in the add-on. And I have a look on it.
    It creates template, chunks, snippets.... I understand all the logic, BUT i'm completely lost to know HOW it makes this just in the installation process.
    To be more precise:
    Is there a way to create by hand, template, chunks, ... without passing by the dashboard ?

    How the Bootstrap theme add-on can achieve this (installing new category, new template, new chunks ...) ? Because it passes through the package installation process ?

    Hope I'm clear enough ....

    Thanks to your answers
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      All the Bootstrap installer is doing is inserting these elements into the database.

      You can also use files, specifying the element to be "static" and giving the path to the file. But in the end, they all have to be represented in the database, so that the MODx engine knows what each one is.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 42110
        • 5 Posts
        Quote from: sottwell at Nov 18, 2012, 01:41 AM
        All the Bootstrap installer is doing is inserting these elements into the database.

        You can also use files, specifying the element to be "static" and giving the path to the file. But in the end, they all have to be represented in the database, so that the MODx engine knows what each one is.

        Thanks to your reply,

        Then, To add a new theme, or managing let's say new objects as vehicle, carMakers and so on, one has to follow the case study 'doodle" provided by Modx in its documentation.
        I mean, wrapping all the stuff in a package in order to be properly installed.

          • 4172
          • 5,888 Posts
          you didn't tell why and where you want to do that.

          If you want transport templates,snippets,chunks,files from one installation to another you can use packman to create a tranport-package, copy the created package into the core/packages - folder, search localy for new packages in package-management and install the package on your new site.

          If you want to use the api for creating a new template, you would do something like that:

          $template = $modx->newObject('modTemplate');
          
          $template->set('templatename','myTemplate');
          $template->set('content','here your template Content');
          
          $template->save();
          


          You can also use the runProcessor - method and call the template-create-processor.


            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 42110
            • 5 Posts
            Quote from: Bruno17 at Nov 18, 2012, 01:55 AM
            you didn't tell why and where you want to do that.

            If you want transport templates,snippets,chunks,files from one installation to another you can use packman to create a tranport-package, copy the created package into the core/packages - folder, search localy for new packages in package-management and install the package on your new site.

            If you want to use the api for creating a new template, you would do something like that:

            $template = $modx->newObject('modTemplate');
            
            $template->set('templatename','myTemplate');
            $template->set('content','here your template Content');
            
            $template->save();
            


            You can also use the runProcessor - method and call the template-create-processor.


            Thanks for your reply,

            what I'm trying to do is maybe the wrong things because I have in mind the way I did with more "basic" frameworks and because with modX there are many things already wired (but you must have in mind the good way of doing)
            ---
            What I want to achieve is 2 things
            1- creating my own theme, but without passing through the dashboard
            I would like to reproduce the Bootstrap theme add on but without using the packaging system. As I would do with basic frameworks (creating directories, adding css, js, and smarty template because it is used)
            2- creating a site dealing with cars. then one can add a car, delete a car. With other classes than car, which would have one to many relation ship between them.

            ---
            concerning the snippet you gave me, it is perhaps the way I searched.
            where do you call those line of code ?


            Thanks -- vielen Dank