We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29858
    • 13 Posts
    I’m posting here to determine if there is any interest in a tool I am writing for myself.

    I was inspired by the MODxFS initiative to write my own tool that allows me to edit files and then re-commit them to the MODx database. The modxfs-php tool will be a superior, albeit more complicated, solution in the end. Given the development of modxfs-php, I’m not sure if there is a point in publishing this tool. Thoughts?

    A perl script is used to checkout the templates, snippets, and chunks into the developer’s file system.

    tool> checkout manager/includes/config.inc.php fs

    This command will parse the config.inc.php file in order to connect to the database, then write all the files to ./fs/templates, ./fs/snippets, and ./fs/chunks.

    tool> commit fs/chunks/MyChunkName

    This command will write any changes made to MyChunkName back to the database.

    The tool also logs its actions to the modx_manager_log table.

    On my list of to do items:

    • find changes in the database and write them to the file system
    • find changes in the file system and write them to the database

    I’m hesitant to allow the tool to actually create templates, snippets, and chunks and circumvent the MODx manager. Thoughts?

    Some notes:

    • for logging purposes, a manager user (using the tool name) should be manually created
    • due to its infancy (and security issues!), the tool only supports development on local hosts
    • it provides a way to version control the templates, snippets, and chunks via the file system
    • the developer can use their file editing tool of choice
    • perl is fairly portable (or so I’ve been told)
      • 4172
      • 5,888 Posts
      Hi thissideup,

      for developing ’snippets’ for special projects I created bloX. With this tool I can have all snippets and chunks in Files. I have for example this structure for projects: see screenshot.

      this way I can edit all chunks and ’snippets’ in files and can edit them in aptana for example.

      for running a project-task I only need to call bloX like this:

      [!bloX? &project=`regatta`&task=`meldung`!] 

      or I can use config-files when I have a lot of config-parameters:
      [!bloX? &configs=`regatta,meldungen_eingabe`!] 


      per default bloX uses chunks from project/task-folder. but you can also use db-chunks like that:
      [!bloX? &configs=`regatta,meldungen_eingabe` &tpls=`bloxouter:meldung_outerTpl,meldung:meldungTpl`!] 



      sometimes it would be nice to have a module where I could import/export chunks of projects from files to db and back
      chunks could be named like this for example: regatta.meldung.meldungTpl
      this way you could hold also chunks for other snippets than bloX on the file-system under projects/custom/projectname/taskname/templates/

      if you are interested ->http://github.com/Bruno17/bloX-Xedit/tree/master/snippets/



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

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 29858
        • 13 Posts
        Thanks, Bruno17

        I reviewed the documentation to install it, but didn’t find anything that actually explains what the tools does.

        I’ve worked in a UNIX/Linux environment for all of my s/w development career, and am more efficient with the command line than GUIs. Yes, that means I use VIM. smiley I also use SVN for my version control.

        Does it sound like your tool is more than I need?

          • 4172
          • 5,888 Posts
          Quote from: thissideup at Dec 16, 2009, 03:56 PM

          I reviewed the documentation to install it, but didn’t find anything that actually explains what the tools does.
          in short words. with bloX you can organize your php-scripts and html-chunks for projects and there tasks in files. bloX takes an array from the file getdatas.php and renders these datas into chunks from filesystem.
          you can use it like ditto, if you want, but you can also list datas from custom-tablerows or create you own array in getdatas.php, which you want to render into chunks.

          ok, will try it as short as possible.
          I found, when developing webprojects for modx you have to switch often between snippets and chunks to edit them. To do that from modx-manager it is not very efficient and you have no version control. then I found for most projects I need a part for getting datas into an array and one part which renders this datas into my chunks. Additionally sometimes you have to store datas from frontend into the database.
          So I was looking for a way
          1. how to organize my project-files in directories
          2. how to get the different needed datas easy into one array
          3. how to render these array into different chunks from filesystem (often there are also nested chunks, for example calendar views, dropdowns, ralational-subdatas....)

          To 1
          How to organize the files you can see in the screenshot.
          There are folders under custom/ for projects with subfolders for tasks belonging to these projects.
          in these task-folders there are two folders templates/ and includes/
          under templates ...guess... there are all chunks needed for this task.
          under includes there is mostly only one file ’getdatas.php’ sometimes there is also a file onsavedatas.php or additional files ith functions and classes
          special for this task.

          To 2
          to get datas into arrays I have the the file getdatas.php for each project. Here I can use modx-api functions and some special functions from blox-class, for example $this->getrows() which gets all datarows depending of parameters from my bloX-snippetcall.
          these parameters can be for example
          &parents
          &documents
          &filter //creates the where clauses for mysqlstatment
          &orderBy
          &tablename
          &IDs
          &pagestart
          &perPage
          there are some more and you can add your own..........
          there are also functions to create arrays for month-calendar-views and to put events into these arrays for render them later.
          ...and more.
          at the end of getdatas.php blox needs an array

          $bloxdatas
          this array can have $bloxdatas[’innerows’][’nestedarray’]=$nestedarray
          $nestedarray can have more innerrows and so on.

          To 3
          ok, now these datas are rendered into chunks. the outer chunk by default is bloxouterTpl.html
          if there is a arraykey [’innerows’][’nestedarray’] bloX looks for an chunk nestedarrayTpl.html to render the array under [’innerows’][’nestedarray’] into that.
          and so on.
          I had a look to some snippets how they do that, mainly ditto and maxigallery and use the same technic a little bit modified with the chunkie-class for phx.work and setting the placeholders and rendering the chunks and so on.
          Did also some tests with revolution and found we do no longer need this chunky-class and phx. First tests are looking good in revo.

          ok in short word this is what bloX can do for you. Hold all your files on filesystem and use them directly, without the need to create chunks and snippets in the database for special projects. As they are now in files it is easy to use SVN or Git and edit them directly in your editor or IDE (I use the aptana-plugin for eclipse, because I can develop directly on my online-files from different computers at home and at work).
          Of course you can also use modx-chunks. You only need the parameter &tpls=`bloxouter:myouterchunk,nestedarray:mynestedchunk,....andSoON`

          bloX has also some special functions to work together with Xedit. Xedit is our frontend-editor-project we are working on, see my signature for infos.


          I’ve worked in a UNIX/Linux environment for all of my s/w development career, and am more efficient with the command line than GUIs. Yes, that means I use VIM. smiley I also use SVN for my version control.

          of course you can also use VIM and SVN, why not, because all chunks and snippets for your projects are in files.
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 29607
            • 14 Posts
            I want it I want it I want it ! (modxfs-php)

            Is just the thing that I need, i have more than 30 snippets/chunks/modules/plugins/codes to import in the "normal" website from my "tests" one and this is a lot of work, a real PAIN to open all the time the manager pages and move the mouse... could be REALLY handy to do it just like files as you described

            # due to its infancy (and security issues!), the tool only supports development on local hosts

            Im concerned about this point ^ huh, it is not usable for real websites ? I also don’t found any code... what about just use it for the "big import" and then just use it as normal mode later, i mean about that security problem
              • 34017
              • 898 Posts
              Bruno,

              You may really really want to look at h2o-php or Twig. It’s a really light templating engine I use for all my custom stuff.

              One main reason- No inner/outer chunks. You can nest loops. It’s absolutely amazing.
                Chuck the Trukk
                ProWebscape.com :: Nashville-WebDesign.com
                - - - - - - - -
                What are TV's? Here's some info below.
                http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
                http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008
                • 4172
                • 5,888 Posts
                @ChuckTrukk:

                I think its easier to read and to understand to have chunks and innerchunks together with phx for formatting and if/else like that :

                outer chunk:
                <ul>
                [+innerrows.person+]
                </ul>


                person-chunk:
                <li>[+blox.iteration+].   [+name+] - [+age+] years old</li>


                instead of:
                <ul>
                {% for index, person in persons %}
                  <li>{{ index}}.   {{ person.name }} - {{ person.age }} years old</li>
                {% endfor %}
                </ul>
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!