উন্নত বিষয়গুলি

From Joomla! Documentation

This page is a translated version of the page Advanced topics and the translation is 100% complete.
Joomla! 
2.5 & 3.x
ক্রম

টেমপ্লেট কিভাবে চালানো হয়?

Templates are executed in a 2-phase process that makes full use of the PHP parser to provide considerable flexibility and performance to the template designer. Templates are executed in the context of the document object so that the $this object is always the instantiation of the JDocument class.

Before template execution begins, the component will have been executed and its output buffered for later use.

Template execution then proceeds as follows:

  • template parameters (if any) are loaded.
  • template language (if any) is loaded.
  • if legacy mode is on then the configuration variables are copied as globals.
  • the template file (index.php) is loaded and executed (by PHP). The output is buffered. This is phase 1 of the 2-phase process. Everything between <?php and ?> tags is executed as PHP code. Everything outside of these tags is output but otherwise ignored. As the output is being buffered, nothing is sent to the client web browser at this stage.
  • a favicon.ico file is looked for, first in the Joomla! root directory, then in the template root directory. The latter will override the former if found.
  • the output that was buffered in phase 1 is now parsed for <jdoc:include> elements. This is phase 2 of the process. For each jdoc element found, the appropriate renderer class is loaded and its render method is called. The output from the render method replaces the <jdoc:include> element itself in the output buffer. In the case of module renderer classes this triggers the execution of the modules and the buffering of their output.
  • Certain template-specific HTTP headers are added to the list of headers to be output.
  • Control is then passed back to the JApplication object which will handle the rest of the process of getting the now rendered web page back to the client web browser.


সিস্টেম ত্রুটি পৃষ্ঠাগুলি

Error Page Templates

By default Joomla! uses special templates when it needs to raise an error response. These are located in the templates/system directory. For server-level status codes these are named for the status code that is being raised. The default system error pages are:

  • templates/system/403.php (Status code: 403 Forbidden)
  • templates/system/404.php (Status code: 404 Not Found)
  • templates/system/500.php (Status code: 500 Internal Server Error)

In addition, these system error pages are also available:

  • templates/system/component.php (not sure when this is used)
  • templates/system/offline.php is used to render the "site is offline" message.

Note that jdoc:include elements are not parsed in these error pages.

The status codes are defined as part of the HTTP protocol in RFC2616. For further information on HTTP status codes see: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

Styling the Error Pages

These pages can be styled using the following CSS classes:

  • errorboxheader
  • errorboxbody
  • techinfo


কাস্টম ত্রুটি পৃষ্ঠাগুলি

Joomla! uses the templates/system/error.php file to handle several HTTP Status errors, including "403 Forbidden", "404 Not Found", and "500 Internal Server" errors. You can style the error results, if desired.

It is important to understand that error.php is an independent file from the Joomla! CMS but dependent on the Joomla! Platform. Plugins do not run on the file. You cannot include modules or use <jdoc:include> statements.

Overriding the System Error Results

To override the system error results, copy the templates/system/error.php file into your templates/<template-name> directory.

If it finds one, Joomla! will use the error.php file from the current template, in place of the system file.

You can format the page, as desired, to match your template.

Overriding the System Styling

If you want to change the styling, copy the templates/system/css/error.css file into your templates/<template-name>/css directory. Next, update your templates/<template-name>/error.php file to reference the new location of the stylesheet by changing this line, accordingly:

<link rel="stylesheet" href="<?php echo $this->baseurl; ?>/templates/system/css/error.css" type="text/css" />

Then, simply change the error.css, as desired, for your styling requirements.

Customizing Error Messages

You can add conditional logic to vary the message returned, dependent upon the specific error code.

Here is an example of how to trap a 404 error and provide a custom message.

<?php  if ($this->error->getCode() == '404') { ?>
	<div id="errorboxheader">Page not found</div>
		<div id="errorboxbody"><p>Sorry! That page cannot be found.</p>
		</div>
	</div>
<?php } ?>

HTTP Status Code

When a request is made for a page on your site, the server returns an HTTP status code in response to the request. Joomla! returns a '200 - the server successfully returned the page' for error pages. This is problematic for those working with Google Webmaster Services and trying to get a sitemap resolved.

If you want Joomla! to return a status code for the error, you can do so by adding logic before the DOCTYPE line, as follows:

<?php 
if ($this->error->getCode() == '404') {
	header("HTTP/1.0 404 Not Found");
} ?>

More HTTP Status Code Information

Using Theme Header and Footer on Standard Error Page

Joomla 1.5 If you want to see the error page in theme design and don't like redirecting to error page URL or duplicating HTML in the error page template, here is a way to apply your theme template to the error page.

First, put the following code in templates/<template-name>/error.php:

<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

include dirname(__FILE__) . "/index.php";
?>

Then make the following edits to templates/<template-name>/index.php:

1. Find the following code in index.php

<jdoc:include type="head" />

and replace it with the following

<?php if (!$this->error->getCode()) : ?>
<jdoc:include type="head" />
<?php else : ?> 
<title><?php echo $this->error->getCode() ?> - <?php echo $this->title; ?></title>
<?php endif; ?>

2. Find the following code in index.php

<jdoc:include type="component" />

and replace it with the following

<?php if ($this->error->getCode()) : /* check if we are on error page, if yes - display error message */ ?>
  <p><strong><?php echo $this->error->getCode() ?> - <?php echo $this->error->message ?></strong></p>
  <p><strong><?php echo JText::_('JERROR_LAYOUT_NOT_ABLE_TO_VISIT'); ?></strong></p>
  <ol>
    <li><?php echo JText::_('JERROR_LAYOUT_AN_OUT_OF_DATE_BOOKMARK_FAVOURITE'); ?></li>
    <li><?php echo JText::_('JERROR_LAYOUT_SEARCH_ENGINE_OUT_OF_DATE_LISTING'); ?></li>
    <li><?php echo JText::_('JERROR_LAYOUT_MIS_TYPED_ADDRESS'); ?></li>
    <li><?php echo JText::_('JERROR_LAYOUT_YOU_HAVE_NO_ACCESS_TO_THIS_PAGE'); ?></li>
    <li><?php echo JText::_('JERROR_LAYOUT_REQUESTED_RESOURCE_WAS_NOT_FOUND'); ?></li>
    <li><?php echo JText::_('JERROR_LAYOUT_ERROR_HAS_OCCURRED_WHILE_PROCESSING_YOUR_REQUEST'); ?></li>
  </ol>
  <p><strong><?php echo JText::_('JERROR_LAYOUT_PLEASE_TRY_ONE_OF_THE_FOLLOWING_PAGES'); ?></strong></p>

  <ul>
  <li><a href="<?php echo $this->baseurl; ?>/index.php" title="<?php echo JText::_('JERROR_LAYOUT_GO_TO_THE_HOME_PAGE'); ?>"><?php echo JText::_('JERROR_LAYOUT_HOME_PAGE'); ?></a></li>
  </ul>

  <p><?php echo JText::_('JERROR_LAYOUT_PLEASE_CONTACT_THE_SYSTEM_ADMINISTRATOR'); ?>.</p>
<?php else : ?>
  <jdoc:include type="component" />
<?php endif; ?>

Now your theme template is applied to error pages too.

Note: Module includes in template will not work on error page created by this method (but will work on other pages).

Using modules in error pages

Modules cannot be included in error pages in the same way as the template's index.php because you cannot use <jdoc:include> statements. There is an alternative way using JModuleHelper.

To include a single module by title, you can use:

if (JModuleHelper::getModule('menu')) { 
    echo $doc->getBuffer('module', 'menu');
}

To include multiple modules by position, you can use:

$modules = JModuleHelper::getModules( 'footer_3' );
$attribs['style'] = 'xhtml';
foreach ($modules AS $module ) {
    echo JModuleHelper::renderModule( $module, $attribs );
}


জাভাস্ক্রিপ্ট যোগ

Note that a more up-to-date Joomla document covering this topic can be found at Adding JavaScript and CSS to the page, although it currently doesn't cover the more advanced topics at the bottom of this page.

জাভাস্ক্রিপ্ট (ইসিএমাসক্রিপ্ট নামেও পরিচিত) একটি স্ক্রিপ্টিং ভাষা যা প্রাথমিকভাবে ক্লায়েন্ট-সাইড ওয়েব সাইট ডেভেলপমেন্টে ব্যবহৃত হয় যাতে ব্যবহারকারীদের অভিজ্ঞতা বৃদ্ধি ও উন্নত হয়। জুমলা ডেভেলপারদের কাছে বিদ্যমান এক্সিকিউটিভ পদ্ধতি ব্যবহার করে তাদের এক্সটেনশনে জাভাস্ক্রিপ্ট অন্তর্ভুক্ত করার জন্য সহজেই ব্যবহারযোগ্য মেকানিজমগুলি সরবরাহ করে। আপনার জুমলা এক্সটেনশনে জাভাস্ক্রিপ্ট অন্তর্ভুক্ত করার জন্য বেশ কয়েকটি পদ্ধতি রয়েছে; এইগুলির কিছু নিচে বর্ণিত হয়।

ব্যবহার

Joomla API ব্যবহার করে আপনার কোডে জাভাস্ক্রিপ্ট এম্বেড করার জন্য তিনটি পদ্ধতি রয়েছে; JDocument::addScriptDeclaration, JDocument::addScript এবং

script. এই পদ্ধতিগুলিকে আপনার কম্পোনেন্ট ভিউ ক্লাসে বলা হবে <yourcomponent>/views/<yourview>/view.html.php বা টেমপ্লেট স্ক্রিপ্ট <yourcomponent>/views/<yourview>/tmpl/<yourtemplate>.php বা একটি মডিউল ক্ষেত্রে, তার টেমপ্লেট স্ক্রিপ্ট মধ্যে<yourmodule>/tmpl/<yourtemplate>.php. 

ইনলাইন জাভাস্ক্রিপ্ট

জাভাস্ক্রিপ্ট কোডের ব্লক সরাসরি একটি উপাদান বা মডিউল এর প্রদর্শন টেমপ্লেট মধ্যে ঘোষণা করা যাবে JDocument class' addScriptDeclaration পদ্ধতি:

<?php
$document = JFactory::getDocument();
$document->addScriptDeclaration('
    window.event("domready", function() {
        alert("An inline JavaScript Declaration");
    });
');
?>

বহিরাগত জাভাস্ক্রিপ্ট

বিকল্পভাবে, আপনি আপনার জাভাস্ক্রিপ্ট একটি পৃথক ফাইলের মধ্যে পৃথক করতে পারেন। আপনার জাভাস্ক্রিপ্টকে একটি বাহ্যিক ফাইল থেকে আলাদা করে আপনার টেমপ্লেট কোডটি সহজেই পড়তে পারে, বিশেষ করে যদি জাভাস্ক্রিপ্ট দীর্ঘ বা জটিল হয়।

জুমলা ব্যবহার করে একটি জাভাস্ক্রিপ্ট ফাইল অন্তর্ভুক্ত করার দুটি উপায় আছে! API- টি। প্রথমটি JDocumentশ্রেণীর 'addScriptপদ্ধতি ব্যবহার করে:

<?php
$document = JFactory::getDocument();
$document->addScript('/media/system/js/sample.js');
?>

দ্বিতীয় পদ্ধতি ব্যবহার করে: JHTML class' script

<?php
// Add the path parameter if the path is different than 'media/system/js/'
JHTML::script('sample.js', 'templates/custom/js/');
?>

API 3.x পরিবর্তিত হয়েছে, তাই দ্বিতীয় পরামিতি একটি স্ট্রিং হতে পারে না। আপনি যদি সত্যিই এই পদ্ধতি ব্যবহার করতে হবে, আপনি আপনার জাভাস্ক্রিপ্ট ফাইল পরম লিঙ্ক অন্তর্ভুক্ত করা আবশ্যক:

<?php
JHtml::script(Juri::base() . 'templates/custom/js/sample.js');
?>

You can use options in a third parameter. This example shows the options version and relative . The file example should be saved in the folder media/com_example/js/example.min.js. So you do NOT need to insert the js in the path you insert as second parameter.

<?php
JHtml::_('script', 'com_example/example.min.js', array('version' => 'auto', 'relative' => true));
?>

বিবরণ

জুমলা এপিআই এরJDocument::addScriptDeclaration, JDocument::addScript and script পদ্ধতি jdoc head ট্যাগ মাধ্যমে জুমলা এর index.php মধ্যে জাভাস্ক্রিপ্ট এম্বেড:

<jdoc:include type="head"/>

JDocument::addScript বা script জাভাস্ক্রিপ্ট এম্বেড করার জন্য পদ্ধতিগুলি নিম্নলিখিত এইচটিএমএল এর রূপরেখা index.php এর ফলে হবে:

<head>
...
<script type="text/javaScript" src="/media/system/js/sample.js"></script>
...
</head>

ক্লাস পদ্ধতিতে কল করা JDocument::addScriptDeclaration নিম্নলিখিত HTML রেন্ডার করবে:

<head>
...
<script type="text/javaScript">
window.addEvent("domready", function() {
    alert("Embedded block of JS here");
});
</script>
...
</head>

এই পদ্ধতিগুলি ব্যবহার করা অত্যন্ত গুরুত্বপূর্ণ কারণ এটি প্রধান পিএইচপি কোড থেকে অন্য স্ক্রিপ্টিং ভাষার (জাভাস্ক্রিপ্ট) পার্থক্য করে, নিশ্চিত করে যে সকল জাভাস্ক্রিপ্টটি <head> </head> ট্যাগের মধ্যে সঠিকভাবে সংযুক্ত করা হয় এবং JDocument::addScript and JHTML::script নিশ্চিত করে যে একটি জাভাস্ক্রিপ্ট ফাইল শুধুমাত্র একবার অন্তর্ভুক্ত করা হয়েছে (Ie নেই .js ফাইল দ্বৈততা)।

একটি জাভাস্ক্রিপ্ট ফ্রেমওয়ার্ক ব্যবহার

একটি জাভাস্ক্রিপ্ট কাঠামো একটি পরিচিত, সামঞ্জস্যপূর্ণ এবং প্ল্যাটফর্ম-স্বাধীন ভাবে বিভিন্ন কোডিং কাজগুলি পরিচালনা করার জন্য জেনারিক কার্যকারিতা সহ ডেভেলপারদের সরবরাহ করে। একটি কাঠামো বিকাশকারীকে বিভিন্ন ওয়েব ব্রাউজারে একটি নির্দিষ্ট ফাংশন বাস্তবায়ন এবং সফ্টওয়্যারের প্রয়োজনীয়তার উপর ফোকাস করার জটিলতার কথা ভুলে যেতে সক্ষম করে।

দুটো জাভাস্ক্রিপ্ট ফ্রেমওয়ার্কস জুমলা 3.x এর অংশ হিসাবে প্রদান করা হয়; jQuery এবং Mootools। জুমলা একটি নতুন চালু কাঠামো যা জুমলা এর নতুন বুটস্ট্র্যাপ এইচটিএমএল ফ্রেমওয়ার্কের সাথে সংহত হয়; Mootools হল Joomla এর লেগ্যাসি জাভাস্ক্রিপ্ট লাইব্রেরি যা এখন jQuery দ্বারা স্থানান্তরিত হয় এবং তৃতীয় পক্ষের এক্সটেনশনগুলির সাথে সামঞ্জস্যপূর্ণতা সহ অন্তর্ভুক্ত করা হয়।

আপনার এক্সটেনশান বা টেমপ্লেটগুলিতে জাভাস্ক্রিপ্ট তৈরির সময় এবং জুমলা এর API এর সাথে খুব সহজেই জুড়ে থাকা প্রায় সব ক্ষেত্রে আপনি একটি কাঠামো ব্যবহার করতে হবে।

জুমলা 3.x jQuery

জুমলা 3.x এ একটি ফ্রেমওয়ার্ক সহ তথ্যের জন্য জাভাস্ক্রিপ্ট ফ্রেমওয়ার্কস জুমলা 3.x -এ গাইডটি দেখুন।

জুমলা 1.5 / 2.5 Mootools

যতক্ষণ না আপনি জাভাস্ক্রিপ্ট কোড বজায় রাখেন না যা মুটুলস ব্যবহার করে থাকে বা আপনি জুমলা 2.5 বা তার আগে এর জন্য একটি এক্সটেনশান তৈরি করছেন তবে এটি আপনাকে jQuery এর পরিবর্তে পরিবর্তিত করার সুপারিশ করবে।

প্রথমত, আপনাকে আপনার এক্সটেনশনে Mootools কোড অন্তর্ভুক্ত করতে হবে। আপনার এক্সটেনশনের Mootools ফ্রেমওয়ার্ক অন্তর্ভুক্ত করার জন্য, আপনি আপনার view.html.php বা tmpl ফাইলে নিম্নলিখিত কোডটি যোগ করুন:

জুমলা 1.5 জন্য

JHTML::_('behavior.mootools');

জুমলা 2.5 জন্য

JHtml::_('behavior.framework');

অনুরূপ jQuery ফ্রেমওয়ার্ক বিবৃতি হিসাবে একই ফলাফল উপরের কোড ফলাফল; যে এটি নিশ্চিত Mootools সঠিকভাবে অন্তর্ভুক্ত করা হয় এবং শুধুমাত্র একবার।

তারপর Mootools ব্যবহার করে jQuery এর প্রায় অভিন্ন:

JFactory::getDocument()->addScriptDeclaration('
window.addEvent("domready", function() {
    alert($("list").getElements("li").length);
});
');

Mootools সম্পর্কে আরো তথ্য http://mootools.net/ এ উপলব্ধ। API ডকুমেন্টেশনের জন্য, http://mootools.net/docs/core দেখুন।

তৃতীয় পক্ষের ডেভেলপারদের জন্য গুরুত্বপূর্ণ নোট

যদি আপনি একটি কাস্টম টেমপ্লেট ওভাররাইড বা এক্সটেনশান তৈরি করেন যা একটি কাস্টম JS ফাইল যোগ করার প্রয়োজন হয় তবে আপনার কাস্টম জেস ফাইলগুলির আগে জাকির বা মুটুনালগুলির মত গুরুত্বপূর্ণ নির্ভরতাগুলি যোগ করা নিশ্চিত করুন। জেএস কাঠামো ফাইলগুলি অবশ্যই অন্য কোন ফাইলের আগে লোড হবে না তা নিশ্চিত করার জন্য প্রথমেই তা কার্যকর করা উচিত, অন্যথায় অন্য ফাইলগুলি যেগুলি তাদের প্রয়োজনীয় কাঠামোর আগে লোড হতে পারে সেগুলি বিহীন ব্যতিক্রম।

যেমন Protostar বা Beez কিছু টেমপ্লেট আপনি যেমন ফাংশন ব্যবহার করার প্রয়োজন সব নির্ভরশীলতা সন্নিবেশ

JHtml::_('bootstrap.framework');

Jquery + বুটস্ট্র্যাপ লোড করতে, কিন্তু আপনার এক্সটেনশান বা কাস্টম টেমপ্লেটগুলি ওভাররাইডের উপর নির্ভর করে না। সর্বদা আপনার এক্সটেনশন বা কাস্টম টেমপ্লেট আগে এটি প্রয়োজন নির্ভরতা লোড উপর আধার নিশ্চিত করুন, আমি কেন পরে ব্যাখ্যা করবে:

উদাহরণস্বরূপ, যদি আপনি একটি কাস্টম টেমপ্লেট আড়াআড়ি পেয়ে থাকেন যা কিছু জাকির স্ক্রিপ্টের সাহায্যে JS ফাইল সন্নিবেশ করাতে হয় তবে সেই টেমপ্লেট ওভাররাইডের সমস্ত পৃষ্ঠার উপর অভিনব জিনিসগুলি ব্যবহার করা হয়। সেই ক্ষেত্রে আপনাকে এই ওভাররাইড ফাইলে উপরের অংশে ডিক্লেয়ার করা উচিত:

JHtml::_('jquery.framework');
$doc->addScript('templates/'.$this->template.'/js/fancy-script.js');

আপনি যদি 3 য় পক্ষের এক্সটেনশনটি উন্নয়ন করেন যা আপনি জুমলাতে রাখার পরিকল্পনা করছেন! এক্সটেনশন ডিরেক্টরিটি আপনাকে এই রকম কিছু করতে হবে:

if($params->get('add_extension_resources', false))
{
    JHtml::_('jquery.framework');
    $doc->addScript('media/com_fancy/js/fancy-script.js');
}

এক্সটেনশান রিসোর্সগুলি যোগ করা বা না করা হবে কিনা তা স্থিরীকৃত শর্ত জোরালোভাবে উত্সাহিত এবং ভালো অনুশীলন বলে বিবেচিত হয় কারণ এটি তৃতীয় পক্ষের ডেভেলপারদের নমনীয়তা দেয় যা আপনার এক্সটেনশান ব্যবহার করতে চায় না সম্পদ এবং জুমলা সঙ্গে যুদ্ধ না করে কাস্টম / সংশোধন ফাইল ব্যবহার! সদৃশ এবং হ্যাক ব্যবহার করে আপনার মূল এক্সটেনশানগুলি সরিয়ে ফেলার জন্য ডুপ্লিকেট এবং দ্বন্দ্বগুলি এড়াতে সক্ষম হবেন

ব্যাখ্যা

যদি আপনি প্রোটোস্টার টেমপ্লেট থেকে index.php এর সোর্স কোড চেক করেন, তাহলে আপনি দেখতে পারেন যে বিবৃতিগুলি

JHtml::_('bootstrap.framework');

বিবৃতির আগে উপায় যোগ করা হয়

<jdoc:include type="head" />

এই আপনি মনে করতে পারেন ফ্রেমওয়ার্ক ফাইল এবং আপনার তৃতীয় পক্ষের ফাইল মত পদ্ধতি ব্যবহার করে মত

$doc->addScript('templates/'.$this->template.'/js/fancy-script.js');
$doc->addScript('media/com_fancy/js/fancy-script.js');

ডান প্রান্তে ডান ক্রমে যুক্ত করা হবে, 'কিন্তু এটি' নয়, কারণ এক্সটেনশন ফাইল এবং টেমপ্লেট ওভাররাইড ফাইলগুলি প্রথম এবং আপনার বর্তমানের index.php ফাইল প্রক্রিয়া করা হচ্ছে। টেমপ্লেট 'শেষ' প্রক্রিয়া করা হয়। এটি আপনার কাস্টম জেড ফাইলগুলি প্রথমে ঢোকা এবং টেমপ্লেট থেকে সন্নিবেশকৃত ফ্রেমওয়ার্ক ফাইলগুলি পরে ঢোকা হবে।

এটা জুমলা কারণ! এপিআই (যেমন $doc->addScript) এএস ফাইল পাথ সংরক্ষণ করার জন্য একটি অ্যারের ব্যবহার করে এবং তারা সেই অ্যারে (FIFO stack) এ ঢোকানো একই আদেশে ডকুমেন্টে উপস্থাপিত করে। এছাড়াও, একবার একটি ফাইল পাথ অ্যারে ঢোকানো হয় এবং অন্য API কল একই ফাইল সন্নিবেশ করার চেষ্টা করে, এই ক্রিয়াটি ডুপ্লিকেটগুলি এড়ানোর জন্য উপেক্ষা করা হয়। এটি অর্থাত্ ফাইলগুলির ক্রম পরিবর্তিত হয় না যখন একই ফাইলগুলি বেশ কয়েকবার ঢোকানো হয়।

বলেন যে এই করছেন

JHtml::_('jquery.framework');
$doc->addScript('templates/'.$this->template.'/js/fancy-script.js');

আপনার কাস্টম টেমপ্লেটগুলি ওভাররাইড এবং এক্সটেনশান এ, প্রয়োজনীয়এবং কল দিয়ে ক্ষতি বা সংঘাত সৃষ্টি করে না

JHtml::_('bootstrap.framework');

আপনার টেমপ্লেট index.php ফাইল এ।

বাহ্যিক লিঙ্ক

Joomla 2.5 https://api.joomla.org/cms-2.5/classes/JHtmlBehavior.html#method_framework

Joomla 3.x https://api.joomla.org/cms-3/classes/JHtmlBehavior.html#method_framework

http://en.wikipedia.org/wiki/JavaScript

http://www.w3schools.com/js/default.asp

http://mootools.net/

http://jquery.com/


কিভাবে ব্রাউজার ক্ষমতা নির্ধারণ করা হয়?

Web browsers sometimes differ in the way they render a page. For this reason you may wish to find out which particular browser a visitor is using in order to use some browser-specific CSS.

The following JavaScript defines a simple browser detection object that determines the browser's name and version by decoding the navigator.userAgent string.

function browserDetect()
{
  var browserNames=new Array("Opera", "MSIE","Netscape","Firefox");
  this.name="NK";
  this.mainVersion="NK";
  this.minorVersion="NK";
  
  for (var i=0; i< browserNames.length; i++)
  {
   var pattern='('+browserNames[i]+')'+'.([0-9]+)\.([0-9]+)';    
   var myRegExp=new RegExp(pattern);
   if (myRegExp.test(navigator.userAgent))
    {
      var results=myRegExp.exec(navigator.userAgent);
      this.name=results[1];
      this.mainVersion=results[2];
      this.minorVersion=results[3];
      break;
    }
  }
}

To use this in a script, you create an instance of this object:

var browser = new browserDetect();

The property browser.name will then give you the name of the browser (MSIE, Opera, Netscape or Firefox), browser.mainVersion will show the main version number and browser.minorVersion contains the minor version number.

This is not foolproof. It is much better to avoid writing browser-specific code.


অন্যান্য আউটপুট ডিভাইসের জন্য স্টাইলশিট যোগ করা

সিএসএস স্টাইল শীট ব্যবহার করে ওয়েব পেজ ব্রাউজ করতে ব্যবহৃত ডিভাইসের উপর নির্ভর করে নির্দেশাবলী (শৈলী) ব্যবহার করা সম্ভব।

মিডিয়া প্রকার

স্বীকৃত মিডিয়া ধরনের হয়:

  • all - সব ডিভাইসের জন্য উপযুক্ত
  • aural - স্পিচ সিন্থেসাইজার জন্য.
  • braille - ব্রেইল টাচসাইট প্রতিক্রিয়া ডিভাইসগুলির জন্য অভিপ্রায়.
  • embossed - মুদ্রিত ব্রেইল প্রিন্টারের জন্য.
  • handheld - হ্যান্ডহেল্ড ডিভাইসের জন্য অভিপ্রায়.
  • print - মুদ্রিত পৃষ্ঠাগুলির ফর্ম্যাটিংয়ের জন্য ব্যবহৃত.
  • projection - প্রজেক্ট উপস্থাপনাগুলির জন্য, উদাহরণস্বরূপ প্রজেক্টর বা স্বচ্ছতাগুলিতে মুদ্রণ.
  • screen - মূলত রং কম্পিউটার স্ক্রিনের জন্য.
  • tty - একটি নির্দিষ্ট-পিচ চরিত্র গ্রিড ব্যবহার করে মিডিয়া যেমন, টেলিট্যাপ, টার্মিনাল, অথবা সীমিত প্রদর্শন ক্ষমতা সহ পোর্টেবল ডিভাইসগুলির জন্য। লেখকেরা "tty" মিডিয়া প্রকারের সাথে পিক্সেল ইউনিট ব্যবহার করবেন না।
  • tv - টেলিভিশন-টাইপ ডিভাইসের জন্য (কম রেজোলিউশন, রঙ, সীমিত স্ক্রলবেরি স্ক্রীন, উপলব্ধ শব্দ) জন্য ইচ্ছুক।

উদাহরণ

আপনি নিম্নলিখিত সিনট্যাক্স দিয়ে একটি CSS ঘোষণায় একটি মিডিয়া প্রকার বরাদ্দ করতে পারেন

@media print {
  body { 
    font-size: 12pt;
    font-color: #000000; 
  }
}

একাধিক প্রচারের ধরন একাধিক মিডিয়া প্রকারে প্রদান করতে:

@media print, handheld{
  body { 
    font-size: 12pt;
    font-color: #000000;
  }
  img {
    max-width: 100%;
    height: auto;
  }
}

নির্দেশিকা প্রধান CSS ফাইলে বা একটি নির্দিষ্ট স্টাইল শীট একটি নির্দিষ্ট মিডিয়া প্রকারের জন্য ব্যবহার করা যেতে পারে। টেমপ্লেটের মধ্যে CSS ফাইলে অন্তর্ভুক্ত থাকা আবশ্যক <head> বিভাগ (নিম্নলিখিত জুমলা! বিইজ টেমপ্লেট থেকে নেওয়া হয়েছে):

<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/beez/css/print.css" type="text/css" media="Print" />

একটি স্টাইলশীট অন্তর্ভুক্ত করার প্রস্তাবিত উপায় হল:

<?php
$document = JFactory::getDocument();
 $tpath = $this->baseurl . '/templates/' . $this->template;
$document->addStyleSheet( $tpath . '/css/print.css', 'text/css', 'print'); // arguments: $path, $type, $media
?>

এই ভাবে, আপনি স্টাইলশীটটি নথিতে যুক্ত হবে এবং প্লাগইনগুলি অ্যাক্সেসযোগ্য (যেমন স্টাইলশীট সংমিশ্রণ এবং কম্প্রেস করার জন্য) তা নিশ্চিত করে।