We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29796
    • 91 Posts
    Hi,

    I need to develop some CMP for my needs. I've went throught official "doodles" and "Custom Manager Pages" tutorial. I reviewed and tested MyComponent and MIGX plugin. I also own Official modx guide book, but there is only a briefly description about building CMP. I'm famigliar with MVC structure, but I have some problems here in MODX.

    I don't have any knowledge of extJS, so I want to skip it for now (no time to learn it now) and develop my extras using some other JS library + html and of course object php programming.

    I reviewed some of extras and followed varius tutorials ... and now I'm confused how things needs to be done. So if someone can explain me following questions I'll really appreciate it.

    I plan to start developing my extra from build MyComponent creates it, but for some testing and to understand how it works I just created a folder "testcmp" under core/components + created namespace for it.

    About main location od main index file.

    in "custom-manager-pages" index file in root we create core/components/testcmp/index.class.php , in some examples is used only index.php in the root. Some other examples have index.class.php inside controllers folder.

    1. Why is like that and what is the right way ?

    a. core/components/testcmp/index.php
    b. core/components/testcmp/index.class.php

    c. core/components/testcmp/controllers/index.php
    d. core/components/testcmp/controllers/index.class.php

    2. I noticed that usualy ".class" in filename is present except index.php What is difference of index and index.class ??

    3. When you create an action you can specify to use "controllers/index.class.php" which seens the right way to do it .. so if I'm correct in root "testcmp" folder we don't need any php files and all should go into "controllers" ? ... right ?

    Anyway, after I followed "Custom Manager Pages" tutorial I wanted to pass some info to a "view". There is written to set a placeholder and "Simply add a getTemplateFile() method".
    In doodle example I saw that a function is isnide home controller

    public function getTemplateFile() { return $this->doodles->config['templatesPath'].'home.tpl'; }


    When I aded this funcction to my example I got a blank page. Of course I changed "->doodles" to "->testcmp" and also created same name class inside core/components/testcmp/model/testcmp/testcmp.class.php with all configuration.

    4. Inside core/components/testcmp/model why must be folder named "testcmp" and inside that is actual class?


    Basicly what I want to accomplish is start wowking with MVC in modx.

    5. So I need to know what is the right folder structures which is

    M = core/components/testcmp/model/testcmp/...
    V = anywhere inside core/components/testcmp/ ?? ... like /templates/ ?
    C = core/components/testcmp/controllers/

    and ... what are the right filenames.

    6. How to call a model from a controller
    7. How to pass data to a template view
    8. Are any helpers in modx like in other frameworks .. if so .. wherw should be located and how you use them?


    If anyone know for any "blank demo" wihout extJS on git repository please share it... or any other points to right direction.

    Thanx















      • 28042 ☆ A M B ☆
      • 24,524 Posts
        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
        • 3749
        • 24,544 Posts
        I think this might help: http://bobsguides.com/blog.html/2014/03/28/modx-2.2-cmps-an-anatomy-lesson/.

        Be sure you have the current version of MyComponent, which is updated for MODX-2.2-style CMPs. MyComponent comes with a working CMP in the Example project. It does use extJS/modExt, though much of the work is done for you. Once you specify the files you want in the project config file, MyComponent will put them all in the correct places for you.
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting