http://modxcms.com/forums/index.php/topic,17180.0.html -> If you viewed that thread, this is the final result of that plugin idea.
http://tales.rpgplanet.gamespy.com/snippet_test.php -> Demostration of this plugin --- this will be removed once it goes final.
Anyways, this plugin is used to output a selected chunk’s data on a specified page. It uses a
?selctedname=chunkname URL scheme. This is useful for MODx CMS installs that are used on RPG websites (if the person puts their item/enemy/etc. in chunks like I did), or for general use, like having a new window with a contact form, etc. It also gives off an error if you put in the wrong URL.
I put this here, because there’s one thing I’m trying to pin down before this can be used by the general public...
I know people may not want
item as their
selectedname field, so I tried putting in a config option to change it, which was based off how some of the other plugins I have installed do it. But when I tried putting in $urlParam in the place of item in the code, it gave the error message. Anyone know what I was doing wrong?
Big thanks to ZAP and sirlancelot for helping me with this plugin. And now for the code...
<?php
// --------------------
// SNIPPET: PopUpChunk
// --------------------
// Version: 0.1 Beta
// Date: August 19th, 2007
// Plugin By: Soshite on ModXCMS.com ([email protected])
// A big thanks goes to...
// - ZAP (MODx CMS Testing Q&A)
// - sirlancelot (MODx CMS Coding)
//
// This snippet is designed to output a selected chunk's data in another page, after
// someone clicks a given link. This is useful for when you need a small piece
// of information, like a conatct form, but can't have it inside the original page.
// CONFIGURATION SETTINGS
// $urlParam [string]
// This field defaults as "item", but you can change the
// field here...
// (isset($urlParam)) ? $urlParam : $urlParam = 'item';
// END CONFIG SETTINGS --- DO NOT EDIT BELOW THIS LINE
$chunk = $_GET['item']; // Grab the url parameter
$chunkText = $modx->getChunk($chunk); // get the item from the chunk
if (!$chunkText) $chunkText = '<b>Error</b>: Cannot locate chunk. Please check to see if the URL specified was valid.'; // :(
return $chunkText; // Output to parser
?>