We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21778
    • 223 Posts
    Hi is it possible to make a blog with Ditto, and then have an option (using a tv) to choose if the post is an announcement, news item or article. Based on this i want ditto to display a diffrent tpl chunk, so that each "type" of post will have a unique look on the blog.
      • 12379
      • 460 Posts
      phx should do the trick, so, if you have it installed, in your Ditto template chunk try putting something like this:

      [+phx:if=`[+optionTV+]`:is=`announcement`:then=`{{announceChunkTpl}}`:if=`[+optionTV+]`:is=`blog`:then=`{{blogChunkTpl}}`:if=`[+optionTV+]`:is=`news`:then=`{{newsChunkTpl}}`+]
        Mostly harmless.
        • 21778
        • 223 Posts
        Quote from: hotdiggity at May 08, 2010, 05:42 AM

        phx should do the trick, so, if you have it installed, in your Ditto template chunk try putting something like this:

        [+phx:if=`[+optionTV+]`:is=`announcement`:then=`{{announceChunkTpl}}`:if=`[+optionTV+]`:is=`blog`:then=`{{blogChunkTpl}}`:if=`[+optionTV+]`:is=`news`:then=`{{newsChunkTpl}}`+]

        I have installed PHx 2.1.3 and running Modx evo 1.0.3

        My structure is as following:

        [_]Frontpage
        [_]Blog (id=35)
        -post1
        -post2
        -post3

        On my frontpage i have a ditto snippet call:
        [!Ditto? &parents=`35` &paginate=`1` &tpl=`blogTpl` &dateSource=`pub_date` &orderBy=`pub_date DESC` &display=`5` &language=`danish` &dateFormat=`%d/%m/%Y` !]


        My TV for choosing post type is called: "postType" and is a DropDown list menu with these input values:

        Nyhed==Nyhed||Annoncering==Annoncering||Artikel==Artikel


        so the PHx call needs to be something like this right:

        [+phx:if=`[+postType+]`:is=`Annoncering`:then=`{{blogNyhed}}`:if=`[+postType+]`:is=`Nyhed`:then=`{{blogNyhed}}`:if=`[+postType+]`:is=`Artikel`:then=`{{blogArtikel}}`+]

        (Annoncering and Nyhed uses same tpl)

        but where do i place PHx call exactly? in "blogTpl" chunk and then make these two ditto tpl chunks {{blogNyhed}} {{blogArtikel}} - that dosent seem to work for me =)
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Ditto has its own phx, so you don’t need to install the plugin if you’re only using it for Ditto tpls.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 4172
            • 5,888 Posts
            in your blogTpl place:

            [+postType:is=`Annoncering`:then=`{{blogNyhed}}+]
            [+postType:is=`Nyhed`:then=`{{blogNyhed}}`+]
            [+postType:is=`Artikel`:then=`{{blogArtikel}}`+]


            or try to place this snippet:

            [[showchunk? &chunkname=`[+postType+]`]]


            snippet-code:

            <?php
            return '{{'.$chunkname.'}}';
            ?>


            the value in [+postType+] has to be the same as your chunkname then.
            may be you have to use &hiddenFields or &hiddenfields with your placeholder-fields, because they are perhaps hidden for ditto when preparsing the chunk.


              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 21778
              • 223 Posts
              Hmm i cant seem to get any of this to work properly.
              Thanks for trying, i guess ill have to compromise.
                • 12379
                • 460 Posts
                Try pasting the actual code into the phx calls inside "blogTpl", make sure all your `backticks` are in order too:

                [+phx:if=`[+postType+]`:is=`Annoncering`:then=`

                <!-- paste blogNyhed tpl chunk code here -->

                `+]


                [+phx:if=`[+postType+]`:is=`Nyhed`:then=`

                <!-- paste blogNyhed tpl chunk code here -->

                `+]


                [+phx:if=`[+postType+]`:is=`Artikel`:then=`

                <!-- paste blogArtikel tpl chunk code here -->

                `+]
                  Mostly harmless.
                  • 21778
                  • 223 Posts
                  Yay, got it working! Thanks a ton guys laugh

                  I ended up using ditto’s phx, as suggested by sottwell, with hotdiggity’s most recent post. There are some strange things going on i can’t figure out, if i make a normal space between certain div tags (in the tpl code inside then=``) ditto displays nothing. Anyways it works and im very happy with the result. <3