We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10226
    • 412 Posts
    I am in the middle of a site rebuild due to a server crash, thanks to google I have about 90% of my content.

    Of course this time I am trying to make it a little better, on the site, we sell birds and have a page listing the available birds. On that page I have a link for the species of listed birds. Clicking on that link took you to a profile page for the species.

    This time around I want to pull up an iframe with just their personality details, here is what I have so far. I’m on the right track, but placeholders or something is getting lost in translation.

    here is the code that calls the listing for the birds for sale.

    [[Ditto?tpl=`show_baby` &tplAlt=`show_baby_alt` &display=`all` &summarize=`5` &paginate=`1` &paginateAlwaysShowLinks=`1`]]


    all good there, moving on to the template.

    <div class="bwrap">
    <div class="blist">
    <div class="bld">
    <a href="{{img_path_baby}}[+babypic+]"  rel="lightbox" title="[+baby_type+]"><img class="bpx" src="{{img_path_baby}}th_[+babypic+]" alt="[+babytype+]" width="96" height="96"/></a>
    </div>
    <br/>
    Baby <a href="45" rel="lightbox[personality]" title="[+baby_type+]">[+baby_type+]</a>, [+baby_muta+]<br/>[+baby_sex+]
    <br/>
    <p>Price $ [+baby_price+] (USD) Ref: [+id+]</p>
    <p>[+baby_story+]</p><br/>
    </div>
    </div>


    Now I know you just don’t put in a document number, but for now it is working, 45 is the page with a minimal template for the iframe and holds another ditto call..

    [[Ditto?tpl=`breeder_personality` &parents=`[+baby_link+]`&display=`1`]]


    This is where things break down, FYI [+baby_link+] is a text field that holds the document number for the species profile. Now the template...

    <h3>[+pagetitle+]</h3>
    <p>[+personality+]</P>


    Nice and simple, now this does load in the iframe, but it loads document 44. Regardless of the [+baby_link+] value.

    Probably something simple, but this is a bit advanced for me.

    Any ideas?

    Thanks!



      • 7231
      • 4,205 Posts
      Is 44 the parent of 45? I am thinking that the [+baby_link+] placeholder is not being read correctly and is reverting to the ditto default which is the parent of the current doc.

      Since the second Ditto call is on it’s own document it is looking for the placeholder of that document and not the one being called by the first ditto call. With embedded calls this is not an issue since the data from one call can be used directly in the other call, but if the calls are on isolated documents they need to be able to share the placeholder. You may be able to add a url parameter and use that in the second ditto call. For example:
      <a href="[~45~]?baby_link=[+baby_link+]">
      Then on the second call use either a snippet to get the URL parameter or maybe the build in Ditto functions that allows URL parameters (but I don’t know how to use it).

      Here is a simple get snippet:
      <?php
      $baby_link = isset($_GET['baby_link']) ? $_GET['baby_link'] : '';
      return $baby_link;
      ?>


      Then in the second Ditto call use it like this:
      [[Ditto?tpl=`breeder_personality` &parents=`[!baby_link!]`&display=`1`]]


      THis is 100% untested and my brain is a tired bowl of mush, but this could work shocked
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don&#39;t know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 10226
        • 412 Posts
        Thanks, I’ll check it out tomorrow afternoon.. it’s bedtime for me. Looks like it might work though smiley


        44 is in the ’root’, 45 is a child of 4, 4 is in the root as well, but I see what you are talking about.
        Thanks!
          • 10226
          • 412 Posts
          OK I tried what you suggested, and it changed nothing. Now I did notice something interesting.

          When you specify a lightbox element, you can do rel="lighbox[groupid]" groupid being anything you wish. Iif they are all the same, when it displays the iframe, it assumes they are a series and shows next / prev options. I attempted to add the [+id+] placeholder to make them unique (rel="lightbox[[+id+]]") no go, so I tried rel="lightbox[[+babypic+]]" and rel="lightbox[+babypic+]" but crazy enough, what it renders with all of those is; rel="lightbox[personality]"

          Now we are back to some thing mysterious, because personality = doc 45. but I changed the document name just for kicks and it stays with personality, but the new doc name is visible elsewhere as it should be. Now I have no idea where it might get this from. So we are back to the original question with a bit more insight smiley



            • 7231
            • 4,205 Posts
            Strange, but there must be an explanation.

            Now we are back to some thing mysterious, because personality = doc 45. but I changed the document name just for kicks and it stays with personality, but the new doc name is visible elsewhere as it should be. Now I have no idea where it might get this from.
            This sounds like a cache issue. I had a similar experience recently on my local install. I was only able to fix it by sticking the ditto call into a chunk and calling the chunk rather than the ditto call directly. At the time I figured it was an isolated issue but sound very similar.
              [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

              Something is happening here, but you don&#39;t know what it is.
              Do you, Mr. Jones? - [bob dylan]
              • 10226
              • 412 Posts
              yeah caching did come to mind, but not one document on this install has been cached ever. I’m going to sit down and take a good look at everything now.

              - update -

              The document that loads in the iframe is the newest document!

              The link appears to be populating correctly;

              <a title="Cockatiel" rel="lightbox" href="personality.php?baby_link=35">Cockatiel</a>
                • 10226
                • 412 Posts
                Kick my ass now, because I just realized my target documents are children docs. So everything is working up to the final call where we try to pull details from a parent that has no children!

                At the moment I can not call the parent document because it will return the profiles for ALL children. So filtering would be my next guess smiley I’m not too sharp with the filters, or Ditto as we can tell so far.

                Thanks
                  • 7231
                  • 4,205 Posts
                  Filtering looks worst than it really is. You probably have already seen this page, but just in case:
                  http://ditto.modxcms.com/tutorials/basic_filtering.html

                  What would you filter by?
                    [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                    Something is happening here, but you don&#39;t know what it is.
                    Do you, Mr. Jones? - [bob dylan]
                    • 10226
                    • 412 Posts
                    haha, I was just there... I came up with;

                    [[Ditto? &tpl=`breeder_personality` &parents=`6` &display=`all` &filter=`id,[!baby_link!],1` &debug=`1`]]


                    I have debug on, but I see the baby_link isn’t making it’s way over to the iframe, I tried to show it before the ditto call, but no luck. I got the filter down right, it works fine if you manually enter one of the child docs.
                      • 7231
                      • 4,205 Posts
                      well that is good news, now we know where the problem lies. I will see if I can replicate this here and see what happens.

                        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                        Something is happening here, but you don&#39;t know what it is.
                        Do you, Mr. Jones? - [bob dylan]