<?php global $modx; $ltpCorePath = $modx->getOption('core_path') . 'components/likeThisPage/'; define('ltp_core_path', $modx->getOption('LTP.core_path', null, $ltpCorePath)); $LTP_classPath = ltp_core_path . 'model/LTP/'; require_once $LTP_classPath . 'LTP.class.php'; $LTP = new LTP(&$modx); if (!$LTP instanceof LTP) { return 'ERROR: Could not initialise LTP class' . "\n"; } $cookieScript = ''; /* setup default properties */ $tpl = $modx->getOption('tpl', $scriptProperties, 'output'); $button = $modx->getOption('button', $scriptProperties, 'Like this Article'); $already = $modx->getOption('button', $scriptProperties, 'You like this article'); $dir = $modx->getOption('dir', $scriptProperties, 'ASC'); // Get this page's resource ID $resID = $LTP->getCurrentResourceID(); // TEMP //$LTP->likeThisPage( $resID ); // Get this users uniqueID (if they done have one, create it) $uuID = $LTP->uuID; // Does the user like this already? $userLikesThis = $LTP->doILikeThisPage(); // Count how many people have liked this page $likes = $LTP->getTotalLikesForThisPage(); // Switch button based on whether user likes already if ($userLikesThis) { if (substr($already, 0, 4) == "img:") { $btn .= '<img src="' . substr($already, 4) . '" alt="Like this Article" />';
<?php error_reporting(E_ALL); $path_to_index = '/var/www/modx/'; define('MODX_API_MODE', true); require_once $path_to_index . "index.php"; ini_set('display_errors', 1); ini_set('log_errors', 1); ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); error_reporting(E_ALL); $ltpCorePath = $modx->getOption('core_path') . 'components/likeThisPage/'; define('ltp_core_path', $modx->getOption('LTP.core_path', null, $ltpCorePath)); $LTP_classPath = ltp_core_path . 'model/LTP/'; require_once $LTP_classPath . 'LTP.class.php'; $LTP = new LTP(&$modx); if (!$LTP instanceof LTP) { return 'ERROR: Could not initialise LTP class' . "\n"; } $uuID = $LTP->uuID; $resID = $_GET["resID"]; $LTP->likeThisPage($resID); die("DONE");