We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 630
    • 39 Posts
    There is a reason why I feel sticked to one template for my whole site, where I try to realize different layouts by a couple of TVs instead and by heavy usage of PHx: Templates are not extensible (my modx version is 0.9.6.1p2). If I had multiple templates and I wanted to change something common to all, I would have to make that change(s) on every template manually one after another.

    My ideal modx templating system would have following features:

    • You can define that your new template Y shall extend template X.
    • Instead of one big field for the entire code, we have then multiple fields for Y, one for each template variable used in the extended template X.
    • In any of those fields you can define html code and stuff, e.g. new template variables used exclusively for Y. Leaving a field empty would mean that the respective template variable is set just to itself without extra template code clutter, Y simply inherits that tv from X (i.e. the possibility of setting it, not its value, as opposed to the @INHERIT functionality).

    That kind of multi-level or nested templates could meet needs for which we must use chunks nowadays but had been better off with an appropriate template.

    Maybe an complement idea for the sake of flexibility: A template variable (at least one of type "text") could get templates of its own, which could integrate even other tvs again (but themselves as this would make no sense). When you create a document and define what template to use, you may also choose whatever tv shall use one of its tv-specific subtemplates. Doing or changing these settings would invoke the same manager event of rerendering the docForm as is done today for the monolithic template.

    By the way: Why have template variables to be made usable manually for every template? Why is there no kind of template "preparser" which determines what template variable to activate for the template automatically?
      • 34017
      • 898 Posts
      i have one main template and use includeFile snippet to get it. Then when I need TVs, I just create a new template but include the same file. I havent saved templates in the database for a long time.

      It would be nice to have array/output looping and simple if else without using phx tho.
        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
        • 22303 MODX Staff
        • 10,725 Posts
        agilero: What you are describing sounds like Smarty to me and already exists. I prefer the MODx templating system as it does not allow logic in templates, which IMO is useless for CMS systems where average people will be interacting with the content.

        Quote from: ChuckTrukk at Dec 18, 2008, 05:49 PM

        It would be nice to have array/output looping and simple if else without using phx tho.
        You can; write a snippet called IfThenElse or LoopArray...
          • 630
          • 39 Posts
          Smarty, like the Template Toolkit (Perl), apparently follows a different approach than what I mean here.

          Concerning my first idea, for the modx contributor our template Y is in the end just another ’static’ template that has its set of tvs to fill up like any modx template. The fact that Y extends X is solely the administrator affair.

          The second idea doesn’t imply logic within the template neither, sorry for getting me wrong. I mean just templates where you can choose between alternative components at certain positions. But it is not the template that defines these alternatives, it is rather the template variable for which there could exist a special type "subtemplate".

          An example: A template variable "heading" for which you could define two subtemplates:
          • simple: <h1>[*longtitle*]</h1>
          • extra_info: <h1>[*longtitle*]</h1><div class="small">by [*author*] published on [*publishedon*] / Tags: [*tags*]

          So, when a template using tv "heading" is selected for a document, another option-input field could appear below the template selection:
          heading: [ simple         |v]

          This way you can specify for any specific document whether or not to display author, published date and tags, and only if yes, the respective fields are shown in the doc form. You don’t need a "show extra info" toggle tv, which would require the additional fields to be shown no matter if there are used.

          As a final note, it is clear that those template extensions, if implemented, should be applied with caution lest the presentation of the site as a whole get heterogeneous, even confusing. I won’t deny this danger.


          Thanks,
          agilero.
            • 20413
            • 2,877 Posts
            Snippets like sitemap, ssl encryption and metatagsextra can be controlled for each documents by tvs or all pages by template.
            Then you can make a template like this

            [*header*]
            [*upper_content*]
            [*content*]
            [*lower_content*]
            [*footer*]


            And there you go!

            //PHx is awesome ---> http://wiki.modxcms.com/index.php/PHx

            ...Another tip is tvs for code "notes" (tv-placeholders not placed out) that way you can have
            alternate code ready.

            More ---> http://modxcms.com/forums/index.php/topic,30626.0.html
              @hawproductions | http://mrhaw.com/

              Infograph: MODX Advanced Install in 7 steps:
              http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

              Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
              http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
              • 630
              • 39 Posts
              mrhaw, it seems to me you didn’t read the whole little thread, did you? wink I have tried to point out why PHx and layout-controlling template variables / snippets might not be an ideal solution for sites with multiple document layouts characterized by a bunch of small differences. IMHO page content should rule layout in respect to better/easier comprehension and navigation, by keeping also things in common to all pages of the sites.

              But after all, it was just an idea I thought worth suggesting.
                • 20413
                • 2,877 Posts
                I guess I missunderstand your point. Modx is very optional and let everybody
                do it their way. Are _your way_ not achievable with modx freedom?  :)

                TemplateSwitcher is an awesome plugin. With a tv assigned to all the templates the same changes
                show up on all the templates just like that.
                  @hawproductions | http://mrhaw.com/

                  Infograph: MODX Advanced Install in 7 steps:
                  http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                  Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                  http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                  • 630
                  • 39 Posts
                  I did realize it in the vein of modx freedom, as said with PHx and a bunch of layout-controlling tvs and snippets, but I don’t think it is an ideal solution. But it’s okay. Maybe my problem is somewhat exotic, who knows. (By the way, it’s my homepage project which I do with modx; have no clients on my back)
                    • 20413
                    • 2,877 Posts
                    Do it -- Love modx freedom!!  8)

                    //my clients taken away from joomla does. tongue
                      @hawproductions | http://mrhaw.com/

                      Infograph: MODX Advanced Install in 7 steps:
                      http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                      Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                      http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower