We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42503
    • 120 Posts
    Hi,
    I have a requirement, under one parent there are multiple child content. All the child should open in a fancybox popup. I have plotted the page with getResources. Every thing is working fine only with one thing I getting issue. On clicking the link the fancybox popup is coming but with the content is same for all the popups.

    Chunk are
    [getResources? &parents=`[[*id]]` &tpl=`Practice_Areas_tpl` &includeContent=`1` &limit=`100` &showHidden=`1`]]
    <script type="text/javascript">
    		$(document).ready(function() {
    			/*
    			 *  Open manually
    			 */
    
    			$("a#fancybox-manual-d").click(function() {
    				$.fancybox.open({
    					href : '#data',
    					padding : 5
    				});
    			});
    			});
    </script>


    TPL chunk
    <a id="fancybox-manual-d" href="javascript:;">[[+pagetitle]]</a>
    
    <div style="display:none">
        	<div id="data">
            [[getResourceField:ifempty=`[[+introtext]]` ? &id=`[[*parent]]` &field=`introtext`]]
            </div>
            </div>


    Please help me to find the problem.
      • 3186 ☆ A M B ☆
      • 279 Posts
      You should change a thing in your chunk. You're now loading the parents introtext, which probably is the reason you see the same content over and over again.

      Try this;

      [[+introtext:isempty=`[[getResourceField? &id=`[[*parent]]` &field=`introtext`]]`]]


      That should work.
        MODX Ambassador (NL) & Professional MODX developer
        Follow me on Twitter | Visit my page on Facebook | View my code on Github | View my script posts
        MODX e-commerce solution SimpleCart
        • 42503
        • 120 Posts
        I have tried but the problem is still same. I have changed in this code.
        <div style="display:none">
            	<div id="data">
                [[+introtext:isempty=`[[getResourceField? &id=`[[*parent]]` &field=`introtext`]]`]]
                </div>
                </div>

        Quote from: bertoost at Feb 19, 2014, 08:05 AM
        You should change a thing in your chunk. You're now loading the parents introtext, which probably is the reason you see the same content over and over again.

        Try this;

        [[+introtext:isempty=`[[getResourceField? &id=`[[*parent]]` &field=`introtext`]]`]]


        That should work.
          • 3186 ☆ A M B ☆
          • 279 Posts
          I have searched a bit and discovered you should create HTML like;

          <a href="#some-id-for-your-content">Your title</a>
          <div id="some-id-for-your-content">The content here</div>


          As you can see the href should link to the content ID. You can make this dynamic like:

          <a href="#[[+alias]]-[[+id]]">[[+pagetitle]]</a>
          <div id="[[+alias]]-[[+id]]">
              [[+introtext:isempty=`[[getResourceField? &id=`[[*parent]]` &field=`introtext`]]`]]
          </div>


          Like to hear if it works (or not)
            MODX Ambassador (NL) & Professional MODX developer
            Follow me on Twitter | Visit my page on Facebook | View my code on Github | View my script posts
            MODX e-commerce solution SimpleCart
            • 42503
            • 120 Posts
            No it is not working, instead it is redirecting into other page.
            The code I have changed.
            [getResources? &parents=`[[*id]]` &tpl=`Practice_Areas_tpl` &includeContent=`1` &limit=`100` &showHidden=`1`]]
            <script type="text/javascript">
                    $(document).ready(function() {
                        /*
                         *  Open manually
                         */
             
                        $("a#[[+alias]]-[[+id]]").click(function() {
                            $.fancybox.open({
                                href : '#data',
                                padding : 5
                            });
                        });
                        });
            </script>


            <div style="display:none">
                    <div id="[[+alias]]-[[+id]]">
                    [[+introtext:isempty=`[[getResourceField? &id=`[[*parent]]` &field=`introtext`]]`]]
                    </div>
                    </div>
            


            Got fully stuck, please help.
            Quote from: bertoost at Feb 19, 2014, 08:33 AM
            I have searched a bit and discovered you should create HTML like;

            <a href="#some-id-for-your-content">Your title</a>
            <div id="some-id-for-your-content">The content here</div>


            As you can see the href should link to the content ID. You can make this dynamic like:

            <a href="#[[+alias]]-[[+id]]">[[+pagetitle]]</a>
            <div id="[[+alias]]-[[+id]]">
                [[+introtext:isempty=`[[getResourceField? &id=`[[*parent]]` &field=`introtext`]]`]]
            </div>


            Like to hear if it works (or not)
              • 3186 ☆ A M B ☆
              • 279 Posts
              Your fancybox call is not right. You should not use [[+alias]] etc. in your javascript call. Just assign fancybox to all links, and fancybox will do the rest. Please read the Fancybox docs. Give all your <a> tags a class like "grouped_elements" and apply fancybox like;

              $("a.grouped_elements").fancybox({ options here });
                MODX Ambassador (NL) & Professional MODX developer
                Follow me on Twitter | Visit my page on Facebook | View my code on Github | View my script posts
                MODX e-commerce solution SimpleCart
                • 42503
                • 120 Posts
                I have tried a lot but still couldnot figure that out.
                How you want me to place the call and group. Please help. Tried a lot but could not fixed this problem.
                Quote from: bertoost at Feb 19, 2014, 09:49 AM
                Your fancybox call is not right. You should not use [[+alias]] etc. in your javascript call. Just assign fancybox to all links, and fancybox will do the rest. Please read the Fancybox docs. Give all your <a> tags a class like "grouped_elements" and apply fancybox like;

                $("a.grouped_elements").fancybox({ options here });
                </a>
                  • 3186 ☆ A M B ☆
                  • 279 Posts
                  You should definitely read the manual of Fancybox. This is not related to MODX.
                  Fancybox should do the rest, also with grouped elements.
                    MODX Ambassador (NL) & Professional MODX developer
                    Follow me on Twitter | Visit my page on Facebook | View my code on Github | View my script posts
                    MODX e-commerce solution SimpleCart