We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1416
    • 75 Posts
    Now I’ve tried this in so many ways I just have to give up for now and see if there is a way to do this.
    (I use MODx 0.9.6.2)

    I’m not shure if this is a Ditto quesion, a TV Datagrid question or a getField question, but here goes.

    It’s a Contact Person-list and needs to be as simple to handle as possible, so I’m thinking a delimited list would work great.

    I have a list consisting of Name, City, Telephone and they need to be displayed like a table, with three columns.
    I actually also need every other row to have a class or style attached to it.
    The list will be populated with a delimited list, so I made a TV for each column, with Text as Input and Delimited List as Widget

    I created this chunk to hold the information
    <tr>
    <td>[+kontaktNamn+]</td>
    <td>[+kontaktOrt+]</td>
    <td>[+kontaktTel+]</td>
    </tr>

    and I use this chunk to call my ditto:
    <table cellspacing="0" cellpadding="5" border="0" width="100%">
    [[Ditto?documents=`3` &tpl=`KontaktTable`]]
    </table>

    And it does display the information but the delimiting is not working.
    What am I doing wrong, aside from sitting at my computer 27 hours a day? wink

    I tried with TV Datagrid aswell, but I don’t know how to fetch data from the different FIELDs the TVs are stored in.
    I would love to be able to use the datagrid since it seems to function the exact way I want to populate my list, but reading around on the forum I’m slightly discuraged when it comes to the datagrid.

    Here is what I’m trying to do:
    http://bcfsormland.bro.org.se/kontaktpersoner.html
    The first list is just an actual table created in the Rich Text Editor.
    Below it is the Ditto trial and below that is a Datagrid I’m fiddling with.

    As you can see the Ditto doesn’t do as I want, it just displays the , aswell.

    I tried with GetField but I couldn’t even get it to work at all.

    Also fiddled around with MakeTable but there I realized I was a bit stumped.
    I might be able to figure MT out, but the I guess I need to learn some seriuos skills. laugh


    Is there ANY way to go about what I’m trying to do with my list?!?
    The site is a mockup for local breastcancer helpsites in Sweden and I will make many more sites to come.
    They will be handled by people who has virtually no other skills then writing text on a computer, so I really need it to be as easy as possible for them to handle it.

    And I’m SO FOREVER grateful discovering MODx since it is by far the best CMS I have ever used.
    (I actually migrate almost every site i admin to MODx because it makes my job sooo much easier)

    Any help would be very much appreciated, and needed.

    Cheers
    Amrit
      • 10449
      • 956 Posts
      Every contact person is saved as a separate document, correct?

      Foreget about delimited list output, you don’t need it. Also, the documents-parameter is not enough. You need a start-id too. And, because the default number of results is 3 documents in Ditto, you need to set the total to a higher number.

      Just create another tpl for your alternate rows, and change your Ditto call to include the parameter &tplAltRows.
      http://ditto.modxcms.com/files/snippet-ditto-php.html#tplAlt

      e.g. if your contacts are stored in container id 34:
      [!Ditto? &startID=`34` &total=`100` &display=`100` &tpl=`KontaktTable` &tplAltRows=`KontaktTableAlt`!]
      
        • 16183
        • 1,390 Posts
        @ganeshXL

        Has &tplAltRows not been changed in Ditto 2 to just &tplAlt?
          • 1416
          • 75 Posts
          Thanks ganeshXL, works sort of great, apart from the sorting order. laugh
          And yes kongodo, the correct string is &tplAlt

          It seems like sorting order is always DESC, and at first I thought the paramater &sortDir was removed, since it isn’t listed in http://ditto.modxcms.com/files/snippet-ditto-php.html though it is listed for the older versions of Ditto.
          So I tried it, and &sortDir still works

          Is there any way of sorting in a predefined order, perhaps with the menu index?

          I also have a board of directors (or whatever it’s called)
          So then it would always be sorted in this order:
          President
          Vice President
          Secretary
          Economics
          etc etc

          As you can see I can’t sort on the letters, and sorting on the document id will make it a hassle because the President might step down to a secretary position, so the positions switch around from time to time.

          But hey, now I got it going and it might fix it. smiley

          Thanks
            • 16183
            • 1,390 Posts
            Glad it worked for you Amrit...and thx for confirming the &tplAlt

            I read this from a Ditto documentation compiled by a community member. It says you can also sort by..&sortBy

            &sortBy  	
            
            This parameter tells Ditto what field to sort the output list by.
            
            Recommended fields include createdon, pub_date, editedon.
            
            If Ditto can't find the field you specify, then it reverts to createdon. 
            
            


            I suppose (just guessing here) that you can tell Ditto to sort by menu index (find its field in the database for the correct name) or some other field?. I have never done this, and I could be wrong. Am sure this will be confirmed by the experts here.... wink

            EDIT: According to a post here by Mark (Ditto’s developer) you can sort by menu index, though this is a 2006 post and don’t know what version of Ditto was used.

            syntax: &sortBy=`menuindex`
              • 1416
              • 75 Posts
              Thanks kongodo. Just found those post myself. smiley

              I’m curious though.
              If I make containers for each post, ag. President, Vice President etc etc, and put documents in them for easy sorting.
              Would this make it possible to take the containers name in one column, and the other column takes the name from the document.
              Hmm. Gonna try.

              I’ll get back. laugh

              EDIT:
              As I suspected it does work to do what I want, but all [+parent+] displays is the ID number.
              Is there any way of converting the ID to the Title of a container?
                • 36592
                • 970 Posts
                &sortBy and &sortDir have been combined into &orderBy with the latest version of Ditto, I believe.
                But they are left available for the compatibility.

                And to get the title of parent document, why don’t you use getField snippet ?
                  • 1416
                  • 75 Posts
                  Thanks for the input tkfm.

                  GetField does work, kind of.
                  But it skips the first parent because that parent is hidden by hideFolders in my Ditto-call:
                  [!Ditto? &startID=`2` &total=`100` &display=`100` &tpl=`StyrelseTable` &tplAlt=`StyrelseTableAlt` &sortDir=`ASC` &depth=`2` &hideFolders =`1`!]


                  So I figured maybe one way around it would be to use the showInMenuOnly instead of hideFolders.
                  No luck.

                  This is my GetField-call:
                  [[GetField? &parent=`1` &parentLevel=`1` &field=`pagetitle`]]


                  I also tried it without the &field. I also tried with almost every reasonable settings.
                  No luck here either.

                  My structure looks like this:
                  Root
                  ->Start (1)
                  ->Board (2)
                  ->President (3)
                  ->Name of Current President. (eg George W Bush right now, but soon needs to easily be changed To Mr Obama) (6)
                  ->Vice President (4)
                  ->Name of current Vice President (Mr Dick, and yeah the Dick will leave and in comes...) (7)
                  ->Senator (5)
                  ->Barack Obama. (I just want to be able to move Mr Obama to the President container, and voilá, his position is updated. (8)

                  etc etc.

                  But no matter how I twist the Ditto-call or the GetField-call around it will only give me the name, or ID, for the Board.
                  I want the subcategories to the board to display.

                  Could it be that the Ditto-snippet is placed in the content of Board (2), as it needs do be displayed there, and thus GetField can’t see the the containers (3,4,5) since they are children and not parent to (2) though it is displaying the info I need from (6,7,8)

                  I guess I need something that can display the title of the child to my Ditto-call.
                  The only thing I can find is getDocumentChildren, but that goes to the API and is sort of way over my head...
                  I see what it does, but I don’t know how to utilize it.

                  Ideas anyone?
                  (I can’t be the only one who has the need for this)

                  Cheers
                  Amrit
                    • 36592
                    • 970 Posts
                    I think you placed this getField snippet call in your Ditto template chunk.
                    [[GetField? &parent=`1` &parentLevel=`1` &field=`pagetitle`]]

                    I think it shoud work, but if it doesn’t why don’t you change it like this ?
                    [[GetField? &docid=`[+parent+]` &field=`pagetitle`]]

                    These two call do result in the same value...
                      • 1416
                      • 75 Posts
                      Once again, thanks. smiley

                      You´re right, the first call is what I used, but it didn’t generate the result I was looking for.
                      I think it is because the parent is hidden, so GetField jumps up one level and gets that pagetitle.

                      But the other GetField call does work. And I beleive it is because you use a Ditto placeholder, and Ditto seem to just go up to the actual parent and not skip the hidden one.

                      So the results differ, and I’m fairly shure it is becuase what I just wrote about the levels...

                      It works great now.

                      Much appreciated. smiley

                      Cheers