PDA

View Full Version : شرطی کردن متغیر ها برای rtl



مهدی مانیان
شنبه 27 اسفند 1390, 15:01 عصر
با سلام.

من توی منوی قالب سایتم(جوملا 2.5) یک فانکشن دارم که به این صورت تعریف شده است:


<?php
function MenuSystem($name, $menutype, $template_name, $rtl, $fancy = 0,
$transition = 'Fx.Transitions.linear', $duration = '350',
$xdelay = 350, $xduration = 350, $xtransition = 'Fx.Transitions.linear')
{
global $Itemid;
$Itemid = JRequest::getVar('Itemid');
$this->_name = $name;
$this->_template = $template_name;
$this->_suffix = "";
$this->_type = $menutype;
$this->Itemid = $Itemid;
$document = JFactory::getDocument();
$this->mega = '<script>window.addEvent("domready", function(){var megas = $(document.body).getElements(\'div[class="menusub_mega"]\');megas.each(function(mega, i){var id = mega.getProperty("id").split("_");if(id[2] != null){var smart = "_" + id[1] + "_" + id[2];ZTMenu('.$xdelay.', 0, 0, smart, "megamenu_close", true, '.$xduration.', '.$xtransition.');}});});</script>';
$this->moo = '<script>window.addEvent("domready",function() {new MooMenu($("menusys_moo"), {transition: '.$xtransition.', duration: '.$xduration.'})});</script>';
$this->drill = '<script type="text/javascript">var mymenu=new drilldownmenu({menuid: "drillmenu1", base: "'.JURI::base().'", menuheight: "auto", breadcrumbid: "drillcrumb", persist: {enable: true, overrideselectedul: true}, base: "'.JURI::base().'templates/'.$this->_template.'/zt_menus/'.'"})</script>';

if($this->_name == 'mega') {
if(!class_exists('plgSystemPlg_ZTools')) {
echo JText::_('Missing ZTTools plugin.');
die();
}
}

$document->addStyleSheet(JURI::base().'templates/'.$this->_template.'/zt_menus/'.'zt_'.$this->_name.'menu/'.'zt.'.$this->_name.'menu.css');

if($rtl == 'rtl') {
$document->addScript(JURI::base().'templates/'.$this->_template.'/zt_menus/'.'zt_'.$this->_name.'menu/'.'zt.'.$this->_name.'menu.rtl.js');
} else {
$document->addScript(JURI::base().'templates/'.$this->_template.'/zt_menus/'.'zt_'.$this->_name.'menu/'.'zt.'.$this->_name.'menu.js');
}
؟>


حالا نکته ای که هست اینه که یک متغیری هست به نام $rtl که من فکر می کنم که این متغیر به این فانکشن وصل شده است.(اگر اشتباه می کنم لطفا توضیح بدید چطوری است.)

بعد در یک فایل php دیگر من فکر می کنم این فانکشن به یک متغیر وصل شده است:


$menu = new MenuSystem($menustyle, $default_menu, $this->template, $ztrtl, $fancy, $transition, $duration, $xdelay, $xduration, $xtransition);


اگر اینطور نیست لطفا بگید پس این چه معنایی دارد.

بعد این متغیر به یک if دیگه وصل شده است که این if میگه اگر این پارامتر yes بود ، این کار انجام شود:


if($this->params->get('zt_rtl')) {
$ztrtl = 'rtl';
} else {
$ztrtl = 'ltr';
}


و یک کدی هم در xml قالب هست که میگه این عملیات yes یا no شود:

<field name="zt_rtl" type="radio" default="0" label="RTL_LANGUAGES" description="RTL_LANGUAGES_DESCRIPTION">
<option value="0">No</option>
<option value="1">Yes</option>
</field>


حالا اگر من در مدیریت قالب ها این را yes کنم ، سایت rtl می شود. ولی من می خواهم اگر سایت rtl بود ، قالب هم rtl شود و در غیر این صورت ltr شود.

حالا من می خواهم بگم که متغیر $ztrtl وقتی سایت rtl است ، این متغیر اجرا شود شود و در غیر این صورت اصلا این متغیر اجرا نشود.

لطفا کمک کنید.

با تشکر.

مهدی مانیان
شنبه 27 اسفند 1390, 15:10 عصر
حل شد.

با استفاده از این کد:



if($this->direction == 'rtl') {
$ztrtl = 'rtl';
} else {
$ztrtl = 'ltr';
}


خیلی ممنون.