मुझे लगता है कि आप Joomla1.0 का उपयोग कर रहे हैं?
PHP आउटपुट बफर का उपयोग कर जूमला बफर सामग्री। यानी: ob_start()।
आप का उपयोग सामग्री प्राप्त कर सकते हैं: ob_get_contents();
इस प्रकार आप नियमित अभिव्यक्ति कर सकते हैं जो JQuery के लिए जांच करता है। कुछ ऐसा:
$jquery_loaded = preg_match("/<script.*?src=[\"']jquery[^\"']\"/i", ob_get_contents());
पर्याप्त होना चाहिए। (मैंने इसका परीक्षण नहीं किया है)।
ob_get_contents() का उपयोग स्थितियों में काम नहीं हो सकता है के बाद से पीएचपी उत्पादन बफर नेस्ट जा सकता है। आप बफर के भीतर कई बफर शुरू कर सकते हैं।
Joomla1.5 के लिए, आप एपीआई जो आप हमेशा जूमला उत्पादन हो रही है सुनिश्चित करता है के माध्यम से बफर मिल सकती है।
$Document =& JFactory::getDocument();
$buffer = $Document->getBuffer();
चाहे Joomla1.0 या 1.5 आप ध्यान दें कि जूमला किसी भी बिंदु पर बफर को जोड़ सकते हैं इससे पहले कि यह उत्पादन renders है (ob_flush कॉल() या समकक्ष)। इस प्रकार JQuery के लिए आपकी जांच को ध्यान में रखना है कि चेक के बाद JQuery लोड किया जा सकता है।
ध्यान दें कि जूमला बफर न केवल HTML के लिए बनाई गई है, लेकिन सीएसएस हो सकता है, जावास्क्रिप्ट, एक्सएमएल, JSON आदि आप अपने JQuery परीक्षण करने से पहले HTML के लिए जाँच करने के लिए चाहते हो सकता है तो। आप व्यवस्थापक पैनल के लिए भी परीक्षण कर सकते हैं।
$mainframe =& JFactory::getApplication();
$doctype = $document->getType();
// deactivate for backend
if ($mainframe->isAdmin() || $doctype != 'html') {
return false;
}
संदर्भ यहाँ के लिए आंशिक रूप से चीजों को आप चाहते हैं करता है कि एक उदाहरण प्रणाली प्लगइन है। यह MooTools1.2 के लिए एक संगतता प्लगइन है।
<?php
/**
* MooTools1.2 w/ 1.1 compat for AjaxChat
* @copyright www.fijiwebdesign.com
* @author [email protected]
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
// included only
defined('_JEXEC') or die('Direct Access to this location is not allowed!');
jimport('joomla.plugin.plugin');
/**
* Joomla PHP Speedy Integration
*
* @author [email protected]
*/
class plgSystemAjaxchat extends JPlugin
{
/**
* Constructor
*
* For php4 compatability we must not use the __constructor as a constructor for plugins
* because func_get_args (void) returns a copy of all passed arguments NOT references.
* This causes problems with cross-referencing necessary for the observer design pattern.
*
* @access protected
* @param object $subject The object to observe
* @param array $config An array that holds the plugin configuration
* @since 1.0
*/
function plgSystemAjaxchat(& $subject, $config)
{
parent::__construct($subject, $config);
$mainframe =& JFactory::getApplication();
$document =& JFactory::getDocument();
$doctype = $document->getType();
// deactivate for backend
if ($mainframe->isAdmin()) {
return false;
}
// add mootools 1.2
if ($doctype == 'html') {
$document->addScript('components/com_ajaxchat/js/mootools-1.2-core.js');
$document->addScript('components/com_ajaxchat/js/mootools-1.2-more.js');
$document->addScript('components/com_ajaxchat/js/mootools-1.2-core-compat.js');
$document->addScript('components/com_ajaxchat/js/mootools-1.2-more-compat.js');
}
}
/**
* After Templte output is in buffer
*/
function onAfterRender() {
$mainframe =& JFactory::getApplication();
$document =& JFactory::getDocument();
$doctype = $document->getType();
// deactivate for backend
if ($mainframe->isAdmin()) {
return false;
}
// Only render for HTML output
if ($doctype !== 'html') {
return;
}
// get the output buffer
$body = JResponse::getBody();
// remove mootools if not needed
if (stristr($body, 'mootools.js') || stristr($body, 'mootools-uncompressed.js')) {
$body = preg_replace("/<script.*?mootools(-uncompressed)?\.js.*?<\/script>/i", '', $body);
} else {
$body = preg_replace("/<script.*?mootools-1\.2\-.*?\.js.*?<\/script>[\s\t\r\n]*/i", "\n", $body);
}
JResponse::setBody($body);
}
}
?>
आप के रूप में "अगर jQuery जूमला के साथ शीर्षक में शामिल किया गया है की जाँच करें" इस सवाल का अलग तरीके से व्यक्त कर सकते हैं। – deceze