We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21978
    • 59 Posts
    Hello,

    I encountered a problem with TVs. I use Ditto to show all subpages on a parent page. Subpages contain TVs with some "document-specific" values. But when I display the parent page with all subpages taken by Ditto, all the TVs have values for this document but not values set for each subpage.
    Maybe there is some which allows me to templarize the content (TV) but is attached strictly to the document and when ditto takes the content of a page, it renders those "DV - document variable" properly.

    Imagine such example:
    top level: Books
    sub levels:
    Book1
    Book2
    Book3

    Each Book_ contains a variable "author" which a user sets while editing the page. Top level page - "Books" uses Ditto to show all books (Book1, Book2, Book3). If I use Ditto, authors are not presented correctly, because its another page and there can be only one value for "author" TV.

    How to solve this problem?

    Best regards
    Greg
      • 22815
      • 1,097 Posts
      [tvauthor] in your template should show the author of Book1, Book2 etc. What are you using?
        No, I don't know what OpenGeek's saying half the time either.
        MODx Documentation: The Wiki | My Wiki contributions | Main MODx Documentation
        Forum: Where to post threads about add-ons | Forum Rules
        Like MODx? donate (and/or share your resources)
        Like me? See my Amazon wishlist
        MODx "Most Promising CMS" - so appropriate!
        • 11975
        • 2,542 Posts
        Hi,

        we could help you more accurately if you give us more details such as Ditto call and Ditto chunk.


        :-)
          Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
          • 21978
          • 59 Posts
          I know that I use tables and should do this on divs - will be done later smiley

          Ditto call (on parent page):
          [[Ditto? &startID=`9` &trunc=0 &tpl=`Ditto Template`]]

          Ditto Chunk (named "Ditto Template"):
          <table width="100%" border="0" cellspacing="0" cellpadding="3">
          <tr><td align="left">[+summary+]</td></tr>
          </table>



          Subpages content:
          <table width="100%" border="0" cellspacing="0" cellpadding="3">
          <tr><td align="left">[*tvauthor*]</td></tr>
          <tr><td align="left">[*tv_book_description*]</td></tr>
          </table>

          Both template variables defined - first as input, second as rich text field.

          F1, F1, F1, ... smiley
            • 11975
            • 2,542 Posts
            To achieve the expected result you’ll have to change both ditto call and ditto tpl

            ditto call:

            [[Ditto? &tagData=`tvtvauthor` &startID=`9` &trunc=0 &tpl=`Ditto Template` ]]

            If the doc in which the list is displayed does not share the same teplate you’ll have to add the &hiddenTvs`tvtvauthor` param

            In your ditto tpl:

            <table width="100%" border="0" cellspacing="0" cellpadding="3">
            <tr><td align="left">[+tvtvauthor+]</td></tr>
            <tr><td align="left">[+summary+]</td></tr>
            </table>



            As you can see to access TV you have to prefix their name with tv.

            More info here => http://www.modxcms.com/ditto_parameters.html

            :-)
              Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
              • 21978
              • 59 Posts
              Thanks, I’ll try this.

              Some more questions concerning Your idea:

              1. what if I have more (about 5) variables?
              2. parent page and subpages share the same template - does this change anything? Should I chjange this to have two separate templates?
                • 11975
                • 2,542 Posts
                1. what if I have more (about 5) variables?
                Add them to the &tagData param
                for instance:
                &tagData=`tvtvauthor,tvPublishedYear,tvcategory` and so on


                2. parent page and subpages share the same template - does this change anything? Should I chjange this to have two separate templates?

                It doesn’t matter and depends on your site structure.
                If you decide to have two separate templates you’ll have to update your ditto call and include &hiddenTVs param
                  Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
                  • 21978
                  • 59 Posts
                  Thanks a lot. At first I didn’t notice that for "tvauthor" variable a need a "tvtvauthor" entries for the ditto chunk and ditto call.

                  Now everything looks and works great.

                  Thanks again.