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

    I started to use MODX some weeks ago and I really like how it works and was designed, but I have got a questions about Ditto and UltimateParent.

    I set up my site to be a multi lingual site. I followed the how-to from http://wiki.modxcms.com/index.php/Make_Multi_Lingual_Site to realize that.
    I have got two sub-resources (en, de) where my sites are stored to be able to switch between them with just a click. This works just fine, but now I want to show news in the sidebar, depending on the language, but not depending on the currently selected site.
    In every language-sub-resource, I have got a ’News’-sub-resource containing News-entries.

    That looks like:
    en
      --> News
             --> First entry
             --> Second entry
             --> ...
    de
      --> News
             --> First entry
             --> Second entry
             --> ...
    



    At the moment the part that is responsible for that, looks like this:
    <h3>News</h3>
    <p>
    [!Ditto? &startID=`[[UltimateParent? &topLevel=`2`]]` &summarize=`3` !]
    </p>
    


    When I switch to any other site than the ’News’ site, it does not show me the news, but instead every sub-resource of the selected site.
    I know that this happens, because I use UltimateParent, but I have no idea to achieve what I want do to.
    That is: If I select ’en’, I want to get just ’News’ from ’en’-container and the same thing with ’de’.

    I am using the latest release of Evolution.

    If you need further information, please tell me.

    Thanks,
    zalat
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      In this case, I would use a TV using @INHERIT, and specify the ID desired in the TV for the en and de pages. Their children will inherit that value. You can even hide the TV with ManagerManager to avoid accidental editing of the TV once it’s been set (if you need to change it for some reason you can comment out the MM rule in the mm_rules chunk to make it visible again).
      [[Ditto? &startId=`[*news-start*]]` &display=`3`]]
        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
        • 22427
        • 793 Posts
        Assuming your resources have id numbers like this:
        en                   (10)
          --> News           (11) 
                 --> ...
        de                   (20) 
          --> News           (21)
                 --> ...     


        Then you could try a PHx condition:
        &startId=`[+phx:if=`[[UltimateParent? &topLevel=`1`]]`:is=`10`:then=`11`:else=`21`+]`

        (Or am I wrong, sottwell? - BTW: [*news-start*]] should be [*news-start*] )
          • 22427
          • 793 Posts
          Or may be better (in the template):
          [*phx:if=`[[UltimateParent? &topLevel=`1`]]`:is=`10`
               :then=`[[Ditto? &startId=`11` &display=`3`]]`
               :else=`[[Ditto? &startId=`21` &display=`3`]]`
          *]
            • 36376
            • 2 Posts
            Thank you very much for your responses, I think that’s what I was looking for, but I did not fully get it.

            My page-tree looks like this:
            Start (51)
            
            en (47)
               --> News (52)
            
            de (50)
               --> News (1)
            


            I specified the following in my template:
            [!Ditto? &startId=`[*phx:if=`[[UltimateParent? &topLevel=`1`]]`:is=`47`
                 :then=`[[Ditto? &startId=`52` &display=`3`]]`
                 :else=`[[Ditto? &startId=`1` &display=`3`]]`
            *]` &summarize=`3` !]
            


            but it still does not show me the news on every site. It still shows the sub-pages on every page like before.
            Do I have to disable cache on all sites then?

            How does it work with the @INHERIT TV?
            I specified one TV called ’languages’, its default value is ’en=47,de=50’.

            If I use
            [*phx:if=`[[UltimateParent? &topLevel=`1`]]`:is=`47`
                 :then=`[![Ditto? &startId=`52` &display=`3`]!]`
                 :else=`[![Ditto? &startId=`1` &display=`3`]!]`
            *]
            

            directly in the template, it just shows me
            [*phx:if=`47`:is=`47` :then=`]` :else=`]` *]
            

            in plain instead of the news-entries.

            Thanks,
            zalat