We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25663 MODX Staff
    • 12,272 Posts
    Consider the following question posed by a hypothetical new user. "I just want to create a new ______ page...", where ______ is catalog, press release, news item, bio, documentation, page, etc. This brings to mind our frequently visited concept of "content templates" or some other sort of added jargon (I’m against that! lol). Now, let’s examine how that’s done, and if it can be improved upon or simplified, or just call things a little differently so they make more sense.

    Here’s the way (I’m *thinking* anyway) pages are structured heirarchically, and how/what the pieces can include, with respect to how they pass through the parser:
    template
    ? static text, HTML, JS, CSS, etc.
    ? [*content*]
    ? [[snippets]]
    ? {{chunks}}
    ? [+placeholders+]
    ? [*TVs*]
    
    [*content*]
    ? static text, HTML, JS, CSS, etc.
    ? [[snippets]]
    ? {{chunks}}
    ? [*TVs*]
    
    [*TVs*]
    ? input options
    ? ? input option values (always visible/never changes based on selection)
    ? ? ? @bindings
    ? default values
    ? ? @bindings
    ? ? static text, HTML, JS, CSS, etc.
    ? ? [[snippets]]
    ? ? {{chunks}}
    ? ? [*TVs*]
    ? widgets/display controls
    


    Two other concepts might come into play also:

    ? Plugins--special code that modifies, intercepts, extends or otherwise alters the default system behavior, function or output based on certain event-points in the parser

    ? Modules--a collection of database structures, templates, pages, plugins, CSS files, JS files, etc.


    Now from an outsiders perspective, I should be able to select a "new page type" button/select-list and it automatically does the following for me. This could be considered to be controlled by a "meta-template" or "page template" perhaps:
    1) navigate to the correct parent
    2) create a new document
    3) select the appropriate template
    4) set the page option flags appropriately (cacheable, searchable, don’t register a hit, meta content, etc.)
    5) select the appropriate TV input options, as appropriate
    6) opens the page for editing

    One thing that is confusing to me (and probably to others) is a logical explanation of the difference between the [*content*] and any other TV. [*content*] just seems like a forced TV on every page, with fewer options like input controls, display controls and default values. Why force me to have a huge text-area block on every manager page? It makes no sense from a usability standpoint, and that’s what the users see.

    I also don’t understand the difference between a chunk and a placeholder. They’re both just "placeholders" for chunks of content that contain no logic.

    So, perhaps the following syntax would make more sense and be more intuitive ( new name -- orignal name / discussion ):

    Template -- Template :) no change!
    ? static text, images, html, etc. -- :) no change!
    ? [*variables*] -- TVs + content, with [*content*] being a non-optional global variable established for every page
    ? [] -- snippets
    ? {{placeholders}} -- chunks + placeholders
    <br /><br />And our affiliated part:? <br />? ? Packages -- Modules ("packages" more accurately describes a collection)<br /><br />You might be wondering what happened to the plugins...? they’re still there, just folded into the packages, because they’re to be handled as part of the package installer/upgrade system internal to the manager. More of an advanced topic I think, but could definitely be part of the base level system.<br /><br />Seems like a heck of a lot less stuff to get into folks’ heads to me. The reason being is because you can cleanly keep the discussion of how the system works to one main level for the simpler version at the bottom, vs. having to exaplain the caveats and intricacies of the difference between content and tvs, including why content doesn’t have all the cool options the TVs do. ’Cause it’s just another piece of content, right? ;) <br /><br />You can even keep the discussion of the system very simple, and all of the sudden the system starts to sound really easy for newcomers: <br />[quote]<br />Pages are based on "templates". Templates can contain some, multiple or all of the following:<br />[*] non-editable or static parts<br />[*] one or more editable variables: [*variables*]<br />[*] code from developers to perform special functions like building the menu from all the differnt pages in the site: [[ code]]<br />[*] pieces of static content used in more than one place, like a copyright line at the bottom of a web page: {{placeholders}}<br />[/quote]<br /><br />Then you can explain to developers how they can have sophisticated control using the same structures:<br />[quote]<br />For developers with complex logic needs, you can do more sophisticated things using simple syntax and normal PHP code like:<br />[list]<br />[*] calling other variables and placholders from each other<br />[*] setting default options and input methods for variables using "input widgets", such as pop-up lists, radio buttons or more<br />[*] use built-in data transforming "output widgets" to build data into the formats that otherwise would take a long time to achieve such as data grids, dynamic scrolling tickers and so on<br />[*] bind different data sources (such as text files, databases or other variables) to default input values or input widgets using "@bindings" <br />[*] override default API, manager and parsing behaviors using plugins<br />[*] combine templates, pages, database files, [[ code]], {{placeholders}} into "packges" for one-click install by end users<br />[*] combine all the above, even recursively, to create powerful solutions limited only by your imagination<br />[/list]<br />[/quote]<br /><br />What are your thoughts on this topic?
      Ryan Thrash, MODX Co-Founder
      Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
      • 22303 MODX Staff
      • 10,725 Posts
      Good stuff Ryan...just some additional thoughts on some of the ideas you presented:

      Quote from: rthrash at Jul 30, 2005, 04:35 PM

      Modules--a collection of database structures, templates, pages, plugins, CSS files, JS files, etc.

      Speaking of database structures, I’m thinking we need to explore adding some extensions to the DBAPI to allow the definition of database tables (and associated business logic) via PHP class definitions that extend a persitable class. This is much like J2EE’s EJB spec which effectively creates what is called Container Managed Persistence (e.g. no one has to write SQL). Further, we could create a Manager module that could allow end-users to define the classes via a simple, intuitive form, defining the properties and methods to be "generated".

      Quote from: rthrash at Jul 30, 2005, 04:35 PM

      Now from an outsiders perspective, I should be able to select a "new page type" button/select-list and it automatically does the following for me. This could be considered to be controlled by a "meta-template" or "page template" perhaps:
      1) navigate to the correct parent
      2) create a new document
      3) select the appropriate template
      4) set the page option flags appropriately (cacheable, searchable, don’t register a hit, meta content, etc.)
      5) select the appropriate TV input options, as appropriate
      6) opens the page for editing

      I personally think this can be accomplished via a Manager module that offers a wizard for creating pages for specific "sections" of the site. Thinking of it as applying default values to a folder document. ??

      Quote from: rthrash at Jul 30, 2005, 04:35 PM

      One thing that is confusing to me (and probably to others) is a logical explanation of the difference between the [*content*] and any other TV. [*content*] just seems like a forced TV on every page, with fewer options like input controls, display controls and default values. Why force me to have a huge text-area block on every manager page? It makes no sense from a usability standpoint, and that’s what the users see.

      Agreed 100%, after some reflection and discussion on the subject.

      Quote from: rthrash at Jul 30, 2005, 04:35 PM

      I also don’t understand the difference between a chunk and a placeholder. They’re both just "placeholders" for chunks of content that contain no logic.

      I can see the confusion here, but I like the separation of chunks from placeholders. Chunks are static code that is persisted in the database, and can be separately cached. Placeholders act similar to chunks within the parsable content, but are not persisted unless the page they are on is cached, and are generated on the fly by a snippet, module, or plugin. Think of placeholders as PHP variables being rendered in the page...

      <div>[+myPlaceholder+]</div>


      is the same as

      <div><?php echo $myPlaceholder ?></div>


      Similarly, think of chunks as PHP file includes (or even .shtml includes) where..

      {{myChunk}}


      is equivalent to

      <?php include('myChunk.php') ?>


      or

      <?php include('myChunk.html') ?>


      This is not to say they couldn’t be consolidated into one, but I think the differences might outweigh the similarities enough in behavior to warrant keeping them separate.

      That in mind, I like most of the simplification ideas you’ve presented, with the exception of merging placeholders with chunks, and folding plugins into modules (aka packages). I think they are way too unique and important to fold in under something I see as a resource aggregator.

      And continuing in the resource aggregator discussion, another idea I’d like to see is different views of the resources based on if you are looking at them individually or through a package. In other words, the package view could present only the resources dependent to it and allow access to those resources directly from the package manager. Or this could be a package filter on the resources view, limiting the list of resources to those directly dependent to the package.
        • 25663 MODX Staff
        • 12,272 Posts
        Jason, I agree with the plugins part, I just want to "hide" it from entry-level folks. It will of course need to be totally separate. However I WOULD like to see them distributed as Packages, even if all they contain is a single plugin file. Make sense?

        I do disagree still with the placeholder and completely very much understand your very logical example. To me that’s just setting a flag (cacheable or not) on the individual chunk/placeholder, that is separate from the caching settings on the page.

        Actually, though, with your statement that they could be merged together, we’re not that far off. I think the marketing aspects of eliminating another perceived "option" so that it continues to seem more simple far outweighs the semantics. Just refer to a cached Placeholder as a Chunk and a non-cached placeholder as a Placeholder.

        Explaining subtleties to a somewhat remotely competent coder (or even a mediocre hacker like myself!) about the proper caching applications will be much easier than teaching a new user about the difference between the two. They’re much likely to want to just stick their headers/footers in a Placeholder (cached) and will never be concerned with a non-cached Placeholder (placeholder as today).

        I even think the API supports treating chunks as placeholders even today, actually.

        It’s a goofy marketing thing, but one that I think would help our effort to gain mind- and marketshare in the future. Have I lost it?

          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • 25663 MODX Staff
          • 12,272 Posts
          Jason, put another way can you explain then what the difference would be in your mind between a placehoder and a snippet returning the value directly to the page?
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 22303 MODX Staff
            • 10,725 Posts
            From my perspective chunks and placeholders are not kin enough to merge. Again, one is programmatically created and assigned, the other is created via the manager and persisted in the database, so as objects models they don’t even come close to the same properties or behavior.

            As for snippets and placeholders, I use the snippets to create the dynamic content, then placeholders to output pieces of it inside a chunk that serves as a template, inserting default form values, entire data tables, and possibly even some error messages from validation, etc; all created in one snippet that creates the placeholders, used in the content and/or chunks serving as templates. Please don’t take that away from me... ;-)

            Maybe we just need two managers. One for the technical people like me and one for the non-techies... lol
              • 25663 MODX Staff
              • 12,272 Posts
              I still don’t understand why a merged placeholder/chunk couldn’t do the same exact thing. There’s no reason why you couldn’t programmatically replace the contents of a chunk every time a page loads, and it’s database-persisted value functioning as it’s default.

              And what you’re describing workflow-wise actually would require three passes through the parser for a page, versus two with a merged placeholder/chunk functionality.

              Or maybe I’m just flat missing the boat.
                Ryan Thrash, MODX Co-Founder
                Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • 25663 MODX Staff
                • 12,272 Posts
                Now where’d that boat go?

                I’m now starting to get it. Placeholders don’t need to be declared as chunks do for persistent re-use. You can use them dynamically and use them as needed. Jason used an example of getting all the values out of a row in a DB table and assigning each value to Placholders in a snippet, then using those placeholders later in a chunk, like for a form’s default value.

                In that application, I say we reserve placeholders for the advanced topics section and leave it out of the basic descriptions... Although I still say that we don’t need a seperate word for them. They’d just be dynamic placeholders accessed by the legacy/deprecated [+ for now or by {{+ for the future... or even just {{ in general!
                  Ryan Thrash, MODX Co-Founder
                  Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me