0 Пользователей и 1 Гость просматривают эту тему.
  • 8 Ответов
  • 2513 Просмотров
*

mainet

  • Захожу иногда
  • 148
  • 1 / 0
кто может объяснить эти строки ?
Код
if ($this->countModules("top") && $this->countModules("top2") && $this->countModules("top3") && $this->countModules("top4")) { $top_row="25%"; }
else if (!$this->countModules("top") && $this->countModules("top2") && $this->countModules("top3") && $this->countModules("top4")) { $top_row="33.3%"; }
else if ($this->countModules("top") && !$this->countModules("top2") && $this->countModules("top3") && $this->countModules("top4")) { $top_row="33.3%"; }
else if ($this->countModules("top") && $this->countModules("top2") && !$this->countModules("top3") && $this->countModules("top4")) { $top_row="33.3%"; }
else if ($this->countModules("top") && $this->countModules("top2") && $this->countModules("top3") && !$this->countModules("top4")) { $top_row="33.3%"; }
else if (!$this->countModules("top") && !$this->countModules("top2") && $this->countModules("top3") && $this->countModules("top4")) { $top_row="50%"; }
else if (!$this->countModules("top") && $this->countModules("top2") && !$this->countModules("top3") && $this->countModules("top4")) { $top_row="50%"; }
else if (!$this->countModules("top") && $this->countModules("top2") && $this->countModules("top3") && !$this->countModules("top4")) { $top_row="50%"; }
else if ($this->countModules("top") && !$this->countModules("top2") && !$this->countModules("top3") && $this->countModules("top4")) { $top_row="50%"; }
else if ($this->countModules("top") && !$this->countModules("top2") && $this->countModules("top3") && !$this->countModules("top4")) { $top_row="50%"; }
else if ($this->countModules("top") && $this->countModules("top2") && !$this->countModules("top3") && !$this->countModules("top4")) { $top_row="50%"; }
else if (!$this->countModules("top") && !$this->countModules("top2") && !$this->countModules("top3") && $this->countModules("top4")) { $top_row="100%"; }
else if (!$this->countModules("top") && $this->countModules("top2") && !$this->countModules("top3") && !$this->countModules("top4")) { $top_row="100%"; }
else if (!$this->countModules("top") && !$this->countModules("top2") && $this->countModules("top3") && !$this->countModules("top4")) { $top_row="100%"; }
else if ($this->countModules("top") && !$this->countModules("top2") && !$this->countModules("top3") && !$this->countModules("top4")) { $top_row="100%"; }

Код
if(!$this->countModules('right')) {
$s5_right_width = "0";
}

*

effrit

  • Легенда
  • 10132
  • 1118 / 13
  • effrit.com
Re: кто может объяснить эти строки
« Ответ #1 : 25.02.2011, 13:38:01 »
проверяется наличие опубликованных модулей в разных позициях и на основе этого задаётся ширина какому-то блоку  ($top_row)

countModules("top") возвращает true, если модуль в этой позиции опубликован.
*

kommunizm

  • Осваиваюсь на форуме
  • 32
  • 6 / 0
Re: кто может объяснить эти строки
« Ответ #2 : 25.02.2011, 13:41:41 »
Я плохо дружу с кодом но коли зашел сюда.

На взгляд новичка говорится

Если ((в позиции top опубликован модуль) и (в  позиции top2 опубликован модуль) и (в  позиции top3 опубликован модуль) и (в   позиции top4 опубликован модуль)) ) ширина топ колонок 25 процентов)

Каждая следующая строчка - идут вариации - где установлен "!" модуль не публикуется, соответственно ширина колонки будет больше (четыре вариации если имеем публикацию только трех модулей и 33 процента), шесть вариаций по два модуля в строке - то есть 2 колонки по 50 процентов, и четыре вариации где задействован только одна позиция (в остальных модули не опубликованы),  и само собой 100 процентная в ширину колонка.
*

mainet

  • Захожу иногда
  • 148
  • 1 / 0
Re: кто может объяснить эти строки
« Ответ #3 : 25.02.2011, 13:44:39 »
проверяется наличие опубликованных модулей в разных позициях и на основе этого задаётся ширина какому-то блоку  ($top_row)

countModules("top") возвращает true, если модуль в этой позиции опубликован.

я понимаю, но вот таблица и всего должно быть 4 элемента

1 1 1 1
1 1 1 0
1 1 0 0
1 0 0 0

а  что насчет (!$this->countModules('right')) меня больше интересует вот этот знак "!" что он означает ? сколько я видел кодов есть такой !==
*

mainet

  • Захожу иногда
  • 148
  • 1 / 0
Re: кто может объяснить эти строки
« Ответ #4 : 25.02.2011, 13:52:53 »
Как написать c нормально логикой?
Если  top, top2, top 3, top 4       >= 4 то top_row=25%
Если  top, top2, top 3, top 4       >= 3 НО <= 4 то top_row=33%
и тд...
*

StarCat

  • Захожу иногда
  • 54
  • 8 / 0
Re: кто может объяснить эти строки
« Ответ #5 : 25.02.2011, 13:55:18 »
а  что насчет (!$this->countModules('right')) меня больше интересует вот этот знак "!" что он означает ? сколько я видел кодов есть такой !==
! это НЕ

курите Google и мануал по PHP  ;D Операторы сравнения в PHP
*

mainet

  • Захожу иногда
  • 148
  • 1 / 0
Re: кто может объяснить эти строки
« Ответ #6 : 25.02.2011, 13:57:40 »
! это НЕ
а что насчет 4 поста ?
*

effrit

  • Легенда
  • 10132
  • 1118 / 13
  • effrit.com
Re: кто может объяснить эти строки
« Ответ #7 : 25.02.2011, 14:31:57 »
$count = 0;
if ($this->countModules("top") $count++;
if ($this->countModules("top2") $count++;
if ($this->countModules("top3") $count++;
if ($this->countModules("top4") $count++;

if ($count==4) $top_row="25%";
if ($count==3) $top_row="33%";
...
*

mainet

  • Захожу иногда
  • 148
  • 1 / 0
Re: кто может объяснить эти строки
« Ответ #8 : 25.02.2011, 14:39:07 »
$count = 0;
if ($this->countModules("top") $count++;
if ($this->countModules("top2") $count++;
if ($this->countModules("top3") $count++;
if ($this->countModules("top4") $count++;

if ($count==4) $top_row="25%";
if ($count==3) $top_row="33%";
...
я пробовал сделать вот так - это тоже самое же получается. Спасибо всем. всем +

Код
<?php 
$n=0;
if ($this->countModules('top1')) $n+=1;
if ($this->countModules('top2')) $n+=1;
if ($this->countModules('top3')) $n+=1;
if ($this->countModules('top4')) $n+=1;
?>
 
Код
<div class="width<?php echo $n ?>"><jdoc:include type="modules" name="top1" style="raw" /></div>
   <div class="width<?php echo $n ?>"><jdoc:include type="modules" name="top2" style="raw" /></div>
   <div class="width<?php echo $n ?>"><jdoc:include type="modules" name="top3" style="raw" /></div>
   <div class="width<?php echo $n ?>"><jdoc:include type="modules" name="top4" style="raw" /></div>


CSS
Код
.width1{width:100%}
.width2{width:50%}
.width3{width:33%}
.width4{width:33%}

Странно что S5 применяют такую не логичную калькуляцию
« Последнее редактирование: 25.02.2011, 14:42:46 от mainet »
Чтобы оставить сообщение,
Вам необходимо Войти или Зарегистрироваться
 

Перенос строки в название пункта меню Joomla

Автор skitskis

Ответов: 33
Просмотров: 15983
Последний ответ 29.10.2017, 10:36:30
от xilog
Удаление лишнего текста с адресной строки сайта

Автор SkyAn

Ответов: 1
Просмотров: 1030
Последний ответ 28.10.2014, 15:54:47
от evgen777
Почему может прыгать шаблон?

Автор igoryola

Ответов: 11
Просмотров: 1375
Последний ответ 26.06.2014, 11:15:04
от alex38ann
Может шаблон блокировать Flash?

Автор stardel

Ответов: 2
Просмотров: 939
Последний ответ 16.09.2013, 12:30:14
от stardel
Перенос строки в заголовке таба

Автор zmeyx

Ответов: 2
Просмотров: 1440
Последний ответ 17.06.2013, 12:34:47
от zmeyx