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

    I have another noob MigX question. I succesfully got MigX listing working - thats great. But is there a way for instance to have it like a Post - with single page view?

    Lets say I have an Item I add to a list like normal - now I want to have a short description of the item, maybe an image - but also a link to a single page of that item on which I will have more text and images connected to the item - but how can I tell MigX to make this single page too?

    Thank you!

    AD
      • 4172
      • 5,888 Posts
      you can have a simple snippet, which switches between listing and detail - view:

      <?php
      //[[switchMigxDetailView? &detailChunk=`detailChunk` &listingChunk=`listingChunk`]]
      
      
      $properties['migx_id'] = $modx->getOption('migx_id',$_GET,'');
      
      if (!empty($properties['migx_id'])){
          $output = $modx->getChunk($detailChunk,$properties);
      }
      else{
          $output = $modx->getChunk($listingChunk);
      }
      
      return $output;
      
      ?>
      


      replace the getImageList-call with this snippet-tag:

      [[switchMigxDetailView? &detailChunk=`detailChunk` &listingChunk=`listingChunk`]]


      then have two chunks, one with the normal Listing, the other one with the getImageList-call for the Detail-View:

      [[!getImageList? &tvname=`yourTvname` &tpl=`detailTpl` &where=`{"MIGX_id":"[[+migx_id]]"}`]]



      in your listing-getimagelist-tpl you will need a link:

      <a href="[[~[[*id]]? &migx_id=`[[+MIGX_id]]`]]">view details</a>


      does this work? Didn't test it, just an idea

      ...............

      and please put MIGX - related questions into the MIGX - board of this forum!

      [ed. note: Bruno17 last edited this post 13 years, 10 months ago.]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 42101
        • 125 Posts


        Dear Bruno - thank you very much for this very detailed answer! I have tried it but maybe it's just a bit too heavy for the beginning...it didn't work right now.


        1. I created a snippet with your php Code. (I just named it "switchMigxDetailView")
        2. I replaced the chunk with yours.
        3. I Created the chunk "detailChunk" with your code.
        4. I Created the chunk "listingChunk.

        I guess I am just a bit confused how to set this up right.

        Do I have to create a "detailTpl" as a chunk? Sorry..me <--- noob

        Quote from: Bruno17 at Nov 27, 2012, 06:31 AM
        you can have a simple snippet, which switches between listing and detail - view:

        and please put MIGX - related questions into the MIGX - board of this forum!


        All right - I will do in the future!

        Thanks!

        AD
          • 4172
          • 5,888 Posts
          sorry, you will need to call it uncached:

          [[!switchMigxDetailView? &detailChunk=`detailChunk` &listingChunk=`listingChunk`]]


          and yes you will need to create two chunks, with names detailChunk and listingChunk

          normally the snippet should call the listingChunk and list all images
          If there is a $_GET - var 'migx_id' this should call the detailChunk
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 42101
            • 125 Posts
            Hi Bruno,

            thanks for the snippet - but I tried it again -> no luck.

            I am getting the whole posts listed with your codes, but the link is not rendered right:
            http://localhost/modx//index.php?id=6&migx_id=[[+MIGX_id]]


            listing chunk:
            [[!getImageList? 
                &tvname=`services`
             
                &tpl=`@CODE:  
            
            
             
            
            <section id="[[+idx]]">
            <div id="md">
            
                <h2>[[+title]]</h2>
               <p>[[+beschreibung]]</p>
            <p>[[+videolink]]</p>
            <p>[[+vorteil]]</p>
            </div>
            
            <a href="[[~[[*id]]? &migx_id=`[[+MIGX_id]]`]]">view details</a>
             
            </section>
            
              `]]


            detailChunk:
            [[!getImageList? &tvname=`services` &tpl=`detailTpl` &where=`{"MIGX_id":"[[+migx_id]]"}` ]]
            


            Finally the "chunk_test" I put in my template [[$chunkt_test]]:

            [[!switchMigxDetailView? &detailChunk=`detailChunk` &listingChunk=`listingChunk`]]


            AD [ed. note: ad2003 last edited this post 13 years, 10 months ago.]
              • 4172
              • 5,888 Posts
              don't use '@CODE:' here, but put the tpl-code in a chunk

              did test it and it was working for me.
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 42101
                • 125 Posts
                Quote from: Bruno17 at Nov 27, 2012, 11:46 PM
                don't use '@CODE:' here, but put the tpl-code in a chunk

                did test it and it was working for me.

                Ok! Thank you very much! I will check it!

                Merci

                AD

                -----------

                Works great! Thank you!! [ed. note: ad2003 last edited this post 13 years, 10 months ago.]