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
    Ditto can indeed use TVs and Chunks. There’s also Jason’s Maketable class as well.
      Ryan Thrash, MODX Co-Founder
      Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
      • 8960
      • 150 Posts
      The problem I found with using TVs in general is that TVs show up per template they are assigned to. So if I’m editing the Home, Blog, or Contact Us document, my TV, Bibliography for example, shows up on each of these pages in the TV section if I’m using only one template for my entire site. In other words, the TV fields show up on every document whether they pertain to that document or not.

      Let me break it down in case I wasn’t clear. I created a TV called Bibliography and assigned it to the only template that runs my site. Now, whenever I create or edit a document, the Bibliography TV fields shows up in that document even if that document was not meant to be a Bibliography (like the Home, Blog, or Contact Us documents).

      So, this is where true Custom Content Types come in. How can I specify a document to be Bibliography and not just a normal document? On the Page Settings for a document, all I can specify is that document is going to be HTML, CSS, JavaScript, XML, or Plain Text in the Content Types field, but these are more MIME types (that I referred to in a previous post in this thread), rather than Custom Content Types.

      So here are the questions being brought up:

      Q: Can MODx do Custom Content Types?
      A: Not in the manner I just stated in the above paragraph.

      Q: Will future versions support Custom Content Types?
      A: The documentation says so. OpenGeek has also said xPDO will in other threads (right?). But the original question posed in this thread is asking just that. They saw it in the documentation, but couldn’t find the answer.

      Q: Can TV fields only be displayed on certain documents?
      A: huh

      Q: Can the MIME types (what’s currently being called Content Types) be customized to turn them into Custom Content Types (like a Bibliography)?
      A: huh

      If I’m wrong (or unclear) about any of this, please let me know.

      Thanks!
        • 22303 MODX Staff
        • 10,725 Posts
        The whole point with TV’s is you create a template with relevant TV’s attached as a distinct template for your bibliography, separate from other pages to which bibliography is not applicable. This is also the motivation for the inherit parent template plugin. What you want is the ability to have DV’s (Document Variables) that can be randomly attached to an instance of any document without regards to the template. This will be a 1.0 feature.

        And this is not "content types"; we are simply talking about MODx template variables, and all within the context of whatever content type you need to return for a specific document, be it (X)HTML, XML, JSON, a png generated by code, or whatever. These elements of content (they will be called Content Elements in the future) that can be aggregated by template (or document) have nothing to do with the types of web content MODx ultimately delivers, other than they are the building blocks which help produce that end-result.

        So the answer is, no you can’t have TV’s assigned to a document directly, yet; they currently require a unique template, and thus, you would need to create a distinct bibliography template to support your structure.
          • 25663 MODX Staff
          • 12,272 Posts
          A workaround to the template is to put your entire template into chunks, and only add the TVs where needed for specific templates.

          You can then duplicate your base template (which is mostly chunks, so updating common elements is easy and straightforward), and then assign TVs to the new templates as needed.

          Example Template pseduocode-ish-like tongue:
          {{XHTML-header}}
          {{meta-content}}
          {{site-header}}
          {{site-content-open}}
          {{TV-bits-if-appropriate}}
          {{site-content-close}}
          {{site-footer}}
          


          You would simply swap out or replace the "TV-bits-if-appropriate" on each template, and assign the relvant TVs as appropriate. Caching will make this method work wonderfully.

          You cannot selectively display TVs on a per-document basis currently, nor can you make the MIME types into something they’re not intended. (Well you can do both, but good luck with an upgrade path for your hacked version ...)
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 25465
            • 8 Posts
            Quote from: er16004 at Mar 14, 2007, 08:40 AM

            The problem I found with using TVs in general is that TVs show up per template they are assigned to. So if I’m editing the Home, Blog, or Contact Us document, my TV, Bibliography for example, shows up on each of these pages in the TV section if I’m using only one template for my entire site. In other words, the TV fields show up on every document whether they pertain to that document or not [...]

            When reading your thoughts I came up with an idea: maybe the solution to avoid having TVs about publications shown always is to have template in template? Not sure if it is possible now, but it can be implemented or something like enclosing templates could be introduced. But as I see, rthrash came with a good solution, I already know where it will come in handy:)
              • 8960
              • 150 Posts
              The Document Variables sound like exactly what I want. Can’t wait until 1.0 is here!

              The problem I have with creating a new Template for each specific document format is that I’m trying to push MODx to a University. Just one of the 6 schools has 23 departments in which most have about a dozen divisions. Potentially I’m looking at 300 templates just to cover everyone’s homepage for this 1 school. Imagine then each division wants their own Bibliography page to match their own template. That’s now 600 templates. Don’t forget about a faculty bio page, which brings us to 900 templates. See where this is taking me? One of our schools is using Plone and they have 14 templates (as custom content types) just for their Bibliographies alone.

              This is why I need a solution like Document Variables now, or else this University may not go with MODx (and I’ll be extremely disappointed).

              I’ll take a look at Ryan’s last suggestion, but I’m not sure if this fits what I’m talking about here (any more suggestions are welcome).

              Didn’t mean to hijack this thread, but we are still talking about Custom Content Types within MODx.
                • 8960
                • 150 Posts
                Quote from: Romasio at Mar 14, 2007, 11:24 AM

                maybe the solution to avoid having TVs about publications shown always is to have template in template? Not sure if it is possible now, but it can be implemented or something like enclosing templates could be introduced.

                This might be possible. I’ve been using an IncludeFile snippet that came with the Molio templates. This allows you to call up a HTML file that exists on your webserver. I’ve been using the call as my template to call the HTML file that is my template. I like this approach so I can edit my HTML file in Dreamweaver and upload it to the server to see the changes take affect, rather than copy-n-paste the code into the MODx manager each time I make a change.

                With this IncludeFile call, I could see something like creating a template for the publications, then just call the HTML file in some manner. I’ll have to work out the semantics, but I’d still have to enter the TV values in somehow.

                Anyway, it’s a good idea what you mentioned.
                  • 11678
                  • 160 Posts
                  Eric; I’ve had luck using a php switch statement to apply chunks by document ID. So in effect by putting snippets in various divs of your document template you could then call whatever chunks (of markup) that would be appropriate for that particular document(page) ID.
                  For example I created a chunk containing the markup for a list of new articles - which I don’t want on every page . Then in the sidebar div I put a snippet that contains a php switch statement (which I call ’sidebar-content’);
                  <?php
                  $curPageNum = $modx->documentIdentifier;
                  switch($curPageNum){
                  	case 1:    
                  		echo '{{show-articles}}';
                  		break;
                           .
                           .
                           .
                  }
                  ?>


                  Then I have chunks with different content called by document ID. This way you are not bound by the "every page" TV syndrome, and you don’t have to have a bunch of different templates - just one with snippet calls here and there.
                  Probably an easier way - but this work well.
                  Cheers,
                  Hal D
                    "Today’s headlines are nothing more than whispers of history"
                    • 6726
                    • 7,075 Posts
                    Very interresting discussion... like Ryan suggested, chunk-ize your template is one of the way you can go to do what you need, but even better if you want to reduce template number is introduce conditionnals with PHx (if then else)... so that the appropriate TVs are used for a given document... just a thought, never tried since I didn’t have enough time to give PHx a real ride...
                      .: COO - Commerce Guys - Community Driven Innovation :.


                      MODx est l&#39;outil id
                      • 25663 MODX Staff
                      • 12,272 Posts
                      I hesitate to invest too heavily in PHx at the moment because that functionality is still not working in the 097 release and may require some minor syntax tweaks. And I hope now that I’ve stated that it will start working wonderfully in about 14.5 seconds from now! tongue
                        Ryan Thrash, MODX Co-Founder
                        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me