We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28033
    • 925 Posts
    In my website, I have chunks that hold magic spells, items, equipment, etc, and I show them on my website via that tutorial on the Wiki that shows how to output chunks via a TV.

    Now, for instance, in a Bestiary/Monster List page, I would have one of those items/etc. in a list. I want to have that be linkable to a pop-up page that outputs the selected chunk in a specific template (one separate from the default one, a "minimalistic" one, if you catch my drift).

    I want to try coding this, so I know I’ll need to make a snippet to select the chunk I specify, and then pin a template to that. Is this possible in ModX, or should I forgot about trying this? (If possible, if someone knows about a plugin that already does this, or plugins that are similar that I can learn from, I would appreciate it).

    For an example of what I’m trying to do, click on one of the links in one of the enemy’s tables.

    http://www.cavesofnarshe.com/ff6/enemies.php
      My Snippets
      -> PopUpChunk v1.0
      • 27376
      • 576 Posts
      Personally, I would make the item page a single MODx document (pick the template), and the content will contain one snippet, which will read information from the URL query string (for instance: iteminfo.php?item=antidote) and then grab the information about that item from wherever it’s stored on your website.

      Alternatively, you could create an "Item" template with as many TVs as is needed to describe each item, and create a MODx document for every item. But depending on how you have your information stored, this may or may not be preferable. Also, this might create a large number of documents depending on how many items you have in your database; a lot I assume, being a former RPG gamer myself wink

      It also depends on your knowledge of PHP and MODx snippet programming. If you want a faster, optimized website, go for something similar to option 1. But if you don’t know enough PHP for that, option 2 will also suffice, and you probably won’t notice a speed difference unless you benchmark it using MODx’s "Timing" tags.

      Good luck on your project!
        • 28033
        • 925 Posts
        http://modxcms.com/forums/index.php/topic,12127.msg80789.html#msg80789

        Could that help me at all in trying to do this?

        I think the best way to do this would be to have something like this on the template that’s for the item/etc. data...

         [[dataOutput? &chunk='Antidote']] 


        I think that’s how it’s supposed to look, but you get the idea. Now, here’s where I’m stuck.

        Is there a API function in ModX where it can take...

        http://www.lolfakeurl.com/showdata.php?item=Antidote

        ...the item, and make that the $chunkName, instead of having to specifiy what it is inside the snippet? The template isn’t an issue, since it’ll be outputting on a page specifically for this snippet.

        The template switching plugin seems to use a similar URL structure, so I’ll peak around that,  but if someone with a better knowledge of PHP happens to know how to solve this issue, please feel free to post it. smiley
          My Snippets
          -> PopUpChunk v1.0
          • 33372
          • 1,611 Posts
          Something like this in your snippet should do the trick:
          $chunkText=$modx->getChunk($item);
            "Things are not what they appear to be; nor are they otherwise." - Buddha

            "Well, gee, Buddha - that wasn't very helpful..." - ZAP

            Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
            • 27376
            • 576 Posts
            More specifically:
            <?php
            $chunk = $_GET['item']; // Grab the url parameter
            
            $chunkText = $modx->getChunk($chunk); // get the item from the chunk
            
            if (!$chunkText) $chunkText = '(item not found!)'; // :(
            
            return $chunkText; // Output to parser
            ?>