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

    I want to start working on an idea I got recently and I would like some opinions.
    It’s something like ManagerManager but everything is defined in the template.

    Here is my idea of how a template will look:
    [Note: another API version bellow]

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>[*pagetitle*]</title>
    </head>
    
    <body>
    [*content*]
    </body>
    </html>
    
    [#TemplateManager
    defaultChildTemplateId=6
    content=auto
    pageTitle=hide 6|required|rename <b>Title</b><br/>required field|defaultValue My-Title-default-value
    #]
    
    


    Short API explanation:

    defaultChildTemplateId 6 - will force that when a child is created will have the template id 6[similar to automaticTpl]
    content auto - will display the content textarea only if [*content*] is detected [similar to Hide-Editor]
    pageTitle
    hide - will hide pagetitle field from all the documents having this template
    hide 6 - will hide pagetitle field from all users having role 6
    required - this filed is required [Note: a custom javascript check function will be nice. Will be done in previous versions]
    rename <b>Title</b>
    required field - html tags can be used in renaming the field
    defaultValue My-Title-default-value - sets default value


    Changes: API calls, required field functionality.

    TODO:
    - check if templateFromFile plugin can be integrated into this plugin [API to use file file-name.tpl]


    Thank You
      • 25663 MODX Staff
      • 12,272 Posts
      I like it a lot. Combined with the recent plugin for putting templates on the filesystem I think you’d have an even faster way to set up custom experiences. Keep going with this!
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 16183
        • 1,390 Posts
        xpix...

        I like your idea...esp. the content auto....sorry, I wish I had a more concrete comment wink....

        cheers/k
          • 5340
          • 1,624 Posts
          content auto is similar to
          http://modxcms.com/Hide-Editor-1410.html

          Hides the content editor when using a template that doesn’t contain the content-variable.
            • 16183
            • 1,390 Posts
            uhhh.....there’s so many "hidden" gems in this forum that I don’t know about, ha!

            Thx for the pointer smiley

            /k
              • 30223
              • 1,010 Posts
              I like this idea but instead of having two different plugins I think it would be worth the effort to combine the two into one plugin. I see no obstacles in adding a template parser as the one you describe into ManagerManager.
                • 25663 MODX Staff
                • 12,272 Posts
                Agreed on merging the two for sure. ManagerManger has a great following and good name, too. smiley
                  Ryan Thrash, MODX Co-Founder
                  Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                  • 5340
                  • 1,624 Posts
                  Quote from: rthrash at Jan 31, 2009, 09:13 AM

                  I like it a lot. Combined with the recent plugin for putting templates on the filesystem I think you’d have an even faster way to set up custom experiences. Keep going with this!

                  How about

                  [#TemplateManager
                  file template1.html
                  defaultChildTemplateId 6
                  pageTitle hide
                  longTitle rename Header
                  content auto
                  menuIndex hide editor
                  #]

                  the file needs to be in assets/templates
                  if the file parameter is not defined the html above the code will be used.





                    • 5340
                    • 1,624 Posts
                    I have a dilema:

                    Should I stick with the way I call the TemplateManager or is it better to do it the modx way [#TemplateManager? &file=`template1.html` #]

                    Thx
                      • 30223
                      • 1,010 Posts
                      Quote from: xpix at Feb 03, 2009, 11:24 AM

                      I have a dilema:

                      Should I stick with the way I call the TemplateManager or is it better to do it the modx way [#TemplateManager? &file=`template1.html` #]

                      Thx

                      Whatever is the most efficient and easiest to enter.
                      How about a simple comments tag and one rule per line. That way you’d need one simple regex and split the lines with the advantage that if someone is silly enough to disable the plugin it would not show up in the front-end.
                      <!--#TemplateManager
                      template="assets/templates/my.new.template.tpl";
                      mm_hideFields('pagetitle','!1');
                      mm_renameField('long_title','Heading','!1');
                      #-->

                      In fact you could just hook into ManagerManager and evilly eval() the whole thing.