За последние 24 часа нас посетили 34263 программиста и 1314 роботов. Сейчас ищут 1008 программистов ...

Ещё одна модель сайта

Тема в разделе "Прочие вопросы по PHP", создана пользователем kadet, 2 ноя 2012.

  1. kadet

    kadet Активный пользователь

    С нами с:
    2 авг 2010
    Сообщения:
    79
    Симпатии:
    0
    Доброго времени суток.
    Возможно сабж, на поверхности похожей темы не нашёл.

    Есть идея сделать конструкцию сайта немного другой, чем обычно. Надо обсудить плюсы, минусы. Для начала немного кода:
    Код (Text):
    1.  
    2. class THtml
    3.     {
    4.      var $settings;
    5.      var $head = array(
    6.          title=>array(),
    7.          meta=>array(),
    8.          link=>array(),
    9.          script=>array()
    10.      );
    11.      var $logo = 'здесь можно сразу писать html-код logo сайта';
    12.      var $menu;
    13.      ....
    14.      var $footer;
    15.      function PrintHtml();
    16.     }
    вся идея в том, чтобы сначала производить наполнетие THtml элементами, а потом делать вывод. сейчас для работоспособности сайта большое значение имеет CSS, его столько, что соперничает с основным html-кодом по размерам.
    При таком подходе каждый элемент THtml может добавлять свои классы и стили в style-раздел $html->head, и в итоговой функции PrintHtml() производить генерирование конечного css-файла, либо осуществить вывод как <style>...</style> а заодно и <script>...</script> что зависит от настроек в $html->settings.
    Это будет избавлять файл css от лишнего кода.
    Следующий момент такого подхода. В таком стиле можно выстраивать компоненты сайта, которые можно многократно повторять используя механизм. И менять только настройки. Например одно и тоже меню можно исп. как главное (горизонтальное), как боковое (отображающ. некий список, вертикальное, с другими настройками). При желании можно ещё придумать применение такой компонентной системы построения сайта.

    Вот например "Летающее меню на CSS3" (http://css-live.ru/tricks/letayushhee-menyu-na-css3.html)
    HTML:
    Код (Text):
    1. <div class="fly-menu">
    2.         <div class="fly-hover"></div>
    3.                 <ul>
    4.                         <li class="fly-item home"></li>
    5.                         <li class="fly-item about"></li>
    6.                         <li class="fly-item setting"></li>
    7.                         <li class="fly-item portfolio"></li>
    8.                         <li class="fly-item mail"></li>
    9.                 </ul>
    10.                 <div class="fly-main"></div>
    11.         </div>
    12. </div>
    CSS:
    Код (Text):
    1. content:"";
    2.   width:10px;
    3.   height:20px;
    4.   position:absolute;
    5.   top:22px;
    6.   left:20px;
    7.   background-color:#21383E;
    8.    display:inline-block;
    9. }
    10.  
    11. .fly-menu:hover .about {
    12.   top: -120px;
    13.   left:50px;
    14.   -moz-transform: rotate(360deg);
    15.   -webkit-transform: rotate(360deg);
    16.    -o-transform: rotate(360deg);
    17.     transform: rotate(360deg);
    18.   -moz-animation: it-2 1.1s 1 linear;
    19.   -webkit-animation: it-2 1.1s 1 linear;
    20.    -o-animation: it-2 1.1s 1 linear;
    21.     animation: it-2 1.1s 1 linear;
    22. }
    23.  
    24. @-moz-keyframes about {
    25.   0% {-moz-transform: rotate(-360deg); top: 15px;}
    26.   50% {-moz-transform: rotate(0deg); top: -110px;}
    27.   100% {-moz-transform: rotate(360deg); top:-100px;}
    28. }
    29.  
    30. @-webkit-keyframes about {
    31.   0% {-webkit-transform: rotate(-360deg); top: 15px;}
    32.   50% {-webkit-transform: rotate(0deg); top: -110px;}
    33.   100% {-webkit-transform: rotate(360deg); top:-100px;}
    34. }
    35.  @-o-keyframes about {
    36.   0% {-webkit-transform: rotate(-360deg); top: 15px;}
    37.   50% {-webkit-transform: rotate(0deg); top: -110px;}
    38.   100% {-webkit-transform: rotate(360deg); top:-100px;}
    39. }
    40. @keyframes about {
    41.   0% {transform: rotate(-360deg); top: 15px;}
    42.   50% {transform: rotate(0deg); top: -110px;}
    43.   100% {transform: rotate(360deg); top:-100px;}
    44. }
    45.  
    46. .setting {
    47.   background: #FE9732;
    48.   width:50px;
    49.   height:50px;
    50.   top: 15px;
    51.   right: 15px;
    52.   -moz-transform: rotate(-360deg);
    53.   -webkit-transform: rotate(-360deg);
    54.    -o-transform: rotate(-360deg);
    55.     transform: rotate(-360deg);
    56.   -moz-transition-delay: 0.4s;
    57.   -webkit-transition-delay: 0.4s;
    58.    -o-transition-delay: 0.4s;   transition-delay: 0.4s;
    59.   cursor:pointer;
    60. }
    61.  
    62. .setting:after{
    63. position:absolute;
    64. width:7px;
    65. height:20px;
    66. top:17px;
    67.  left:14px;
    68. content:"";
    69.  background-color:#693E13;
    70.   -moz-transform: rotate(45deg);
    71.   -webkit-transform: rotate(45deg);
    72.    -o-transform: rotate(45deg);
    73.     transform: rotate(45deg);
    74.  
    75. }
    76. .setting:before{
    77.    border:6px solid #693E13;
    78.   border-top:0px;
    79.   border-radius:0px 0px 10px 10px;
    80.     top: 12px;
    81.     left:19px;
    82.     height: 6px;
    83.   width:10px;
    84.   position:absolute;
    85.   content:'';
    86.   -moz-transform: rotate(45deg);
    87.   -webkit-transform: rotate(45deg);
    88.    -o-transform: rotate(45deg);
    89.     transform: rotate(45deg);
    90.  
    91. }
    92.  
    93. .fly-menu:hover .setting {
    94.   top: -20px;
    95.   right: -120px;
    96.   -moz-transform: rotate(360deg);
    97.   -webkit-transform: rotate(360deg);
    98.    -o-transform: rotate(360deg);
    99.     transform: rotate(360deg);
    100.   /*==== Animasi Efek Bouncing ====*/
    101.   -moz-animation: it-3 1.2s 1 linear;
    102.   -webkit-animation: it-3 1.2s 1 linear;
    103.    -o-animation: it-3 1.2s 1 linear;
    104.     animation: it-3 1.2s 1 linear;
    105. }
    106.  
    107. @-moz-keyframes setting {
    108.   0% {-moz-transform: rotate(-360deg); top: 15px; right: 15px;}
    109.   50% {-moz-transform: rotate(0deg); top: -70px; right: -70px}
    110.   100% {-moz-transform: rotate(360deg); top:-60px; right: -60px; }
    111. }
    112.  
    113. @-webkit-keyframes setting {
    114.   0% {-webkit-transform: rotate(-360deg); top: 15px; right: 15px;}
    115.   50% {-webkit-transform: rotate(0deg); top: -70px; right: -70px}
    116.   100% {-webkit-transform: rotate(360deg); top:-60px; right: -60px; }
    117. }
    118.  @-o-keyframes setting {
    119.   0% {-moz-transform: rotate(-360deg); top: 15px; right: 15px;}
    120.   50% {-moz-transform: rotate(0deg); top: -70px; right: -70px}
    121.   100% {-moz-transform: rotate(360deg); top:-60px; right: -60px; }
    122. }
    123. @keyframes setting {
    124.   0% {transform: rotate(-360deg); top: 15px; right: 15px;}
    125.   50% {transform: rotate(0deg); top: -70px; right: -70px}
    126.   100% {transform: rotate(360deg); top:-60px; right: -60px; }
    127. }
    128.  
    129. .portfolio {
    130.   background-color:#FDE674;
    131.   bottom: -10px;
    132.   right: 5px;
    133.   width:50px;
    134.   height:50px;
    135.   -moz-transform: rotate(-360deg);
    136.   -webkit-transform: rotate(-360deg);
    137.    -o-transform: rotate(-360deg);
    138.     transform: rotate(-360deg);
    139.   -moz-transition-delay: 0.5s;
    140.   -webkit-transition-delay: 0.5s;
    141.    -o-transition-delay: 0.5s;
    142.     transition-delay: 0.5s;
    143.   cursor:pointer;
    144. }
    145.  
    146. .portfolio:after{
    147. content:"";
    148. background:#86680E;
    149.   width:30px;
    150.   height:20px;
    151.   position:absolute;
    152.   top:16px;
    153.   left:10px;
    154. }
    155.  
    156. .portfolio:before{
    157. content:"";
    158. background:#86680e;
    159.   width:15px;
    160.   height:10px;
    161.   position:absolute;
    162.   top:12px;
    163.   left:25px;
    164.  
    165. }
    166. .fly-menu:hover .portfolio {
    167.   bottom: -90px;
    168.   right: -110px;
    169.   -moz-transform: rotate(360deg);
    170.   -webkit-transform: rotate(360deg);
    171.    -o-transform: rotate(360deg);
    172.     transform: rotate(360deg);
    173.   -moz-animation: portfolio 1.2s 1 linear;
    174.   -webkit-animation: portfolio 1.2s 1 linear;
    175.    -o-animation: portfolio 1.2s 1 linear;
    176.     animation: portfolio 1.2s 1 linear;
    177. }
    178.  @-o-keyframes portfolio {
    179.   0% {-moz-transform: rotate(-360deg); bottom: 15px; right: 15px;}
    180.   50% {-moz-transform: rotate(0deg); bottom: -70px; right: -70px}
    181.   100% {-moz-transform: rotate(360deg); bottom:-60px; right: -60px; }
    182. }
    183. @-moz-keyframes portfolio {
    184.   0% {-moz-transform: rotate(-360deg); bottom: 15px; right: 15px;}
    185.   50% {-moz-transform: rotate(0deg); bottom: -70px; right: -70px}
    186.   100% {-moz-transform: rotate(360deg); bottom:-60px; right: -60px; }
    187. }
    188.  
    189. @-webkit-keyframes portfolio {
    190.   0% {-webkit-transform: rotate(-360deg); bottom: 15px; right: 15px;}
    191.   50% {-webkit-transform: rotate(0deg); bottom: -70px; right: -70px}
    192.   100% {-webkit-transform: rotate(360deg); bottom:-60px; right: -60px; }
    193. }
    194.  
    195. @keyframes  portfolio {
    196.   0% {transform: rotate(-360deg); bottom: 15px; right: 15px;}
    197.   50% {transform: rotate(0deg); bottom: -70px; right: -70px}
    198.   100% {transform: rotate(360deg); bottom:-60px; right: -60px; }
    199. }
    200.  
    201. .it-5 {
    202.   background: url(http://cahcepu.com/v3/anim/plus2.png) no-repeat center top;
    203.   bottom: 15px;
    204.   left: 15px;
    205.   -moz-transform: rotate(-360deg);
    206.   -webkit-transform: rotate(-360deg);
    207.    -o-transform: rotate(-360deg);
    208.     transform: rotate(-360deg);
    209.   -moz-transition-delay: 0.6s;
    210.   -webkit-transition-delay: 0.6s;
    211.    -o-transition-delay: 0.6s;
    212.     transition-delay: 0.6s;
    213. }
    214. .fly-menu:hover .it-5 {
    215.   bottom: -100px;
    216.   -moz-transform: rotate(360deg);
    217.   -webkit-transform: rotate(360deg);
    218.    -o-transform: rotate(360deg);
    219.     transform: rotate(360deg);
    220.   -moz-animation: it-5 1.3s 1 linear;
    221.   -webkit-animation: it-5 1.3s 1 linear;
    222.    -o-animation: it-5 1.3s 1 linear;
    223.     animation: it-5 1.3s 1 linear;
    224. }
    225.  @-o-keyframes it-5 {
    226.   0% {-moz-transform: rotate(-360deg); bottom: 15px;}
    227.   50% {-moz-transform: rotate(0deg); bottom: -110px;}
    228.   100% {-moz-transform: rotate(360deg); bottom:-100px; }
    229. }
    230. @-moz-keyframes it-5 {
    231.   0% {-moz-transform: rotate(-360deg); bottom: 15px;}
    232.   50% {-moz-transform: rotate(0deg); bottom: -110px;}
    233.   100% {-moz-transform: rotate(360deg); bottom:-100px; }
    234. }
    235.  
    236. @-webkit-keyframes it-5 {
    237.   0% {-webkit-transform: rotate(-360deg); bottom: 15px;}
    238.   50% {-webkit-transform: rotate(0deg); bottom: -110px;}
    239.   100% {-webkit-transform: rotate(360deg); bottom:-100px; }
    240. }
    241.  
    242. @keyframes it-5 {
    243.   0% {transform: rotate(-360deg); bottom: 15px;}
    244.   50% {transform: rotate(0deg); bottom: -110px;}
    245.   100% {transform: rotate(360deg); bottom:-100px; }
    246. }
    247.  
    248. .it-6 {
    249.   background: magenta;
    250.   background: url(http://cahcepu.com/v3/anim/plus2.png) no-repeat center top;
    251.   bottom: 15px;
    252.   left: 15px;
    253.   -moz-transform: rotate(-360deg);
    254.   -webkit-transform: rotate(-360deg);
    255.    -o-transform: rotate(-360deg);
    256.     transform: rotate(-360deg);
    257.   -moz-transition-delay: 0.7s;
    258.   -webkit-transition-delay: 0.7s;
    259.    -o-transition-delay: 0.7s;
    260.     transition-delay: 0.7s;
    261. }
    262. .fly-menu:hover .it-6 {
    263.   bottom: -60px;
    264.   left: -60px;
    265.   -moz-transform: rotate(-360deg);
    266.   -webkit-transform: rotate(-360deg);
    267.    -o-transform: rotate(-360deg);
    268.     transform: rotate(-360deg);
    269.   -moz-animation: it-6 1.4s 1 linear;
    270.   -webkit-animation: it-6 1.4s 1 linear;
    271.    -o-animation: it-6 1.4s 1 linear;
    272.     animation: it-6 1.4s 1 linear;
    273. }
    274.  @-o-keyframes it-6 {
    275.   0% {-moz-transform: rotate(-360deg); bottom: 15px; left: 15px;}
    276.   50% {-moz-transform: rotate(0deg); bottom: -70px; left: -70px}
    277.   100% {-moz-transform: rotate(360deg); bottom:-60px; left: -60px; }
    278. }
    279. @-moz-keyframes it-6 {
    280.   0% {-moz-transform: rotate(-360deg); bottom: 15px; left: 15px;}
    281.   50% {-moz-transform: rotate(0deg); bottom: -70px; left: -70px}
    282.   100% {-moz-transform: rotate(360deg); bottom:-60px; left: -60px; }
    283. }
    284.  
    285. @-webkit-keyframes it-6 {
    286.   0% {-webkit-transform: rotate(-360deg); bottom: 15px; left: 15px;}
    287.   50% {-webkit-transform: rotate(0deg); bottom: -70px; left: -70px}
    288.   100% {-webkit-transform: rotate(360deg); bottom:-60px; left: -60px; }
    289. }
    290.  
    291. @keyframes it-6 {
    292.   0% {transform: rotate(-360deg); bottom: 15px; left: 15px;}
    293.   50% {transform: rotate(0deg); bottom: -70px; left: -70px}
    294.   100% {transform: rotate(360deg); bottom:-60px; left: -60px; }
    295. }
    (фих его знает работает не работает, не проверял)

    можно было бы соорудить такой класс:
    Код (Text):
    1.  
    2. class TFlyMenu
    3.     {
    4.      var $settings;
    5.      function TFlyMenu($setts)
    6.          {
    7.           $this->settings = $setts;
    8.           ...
    9.          }
    10.     }
    начальная инициализация:
    Код (Text):
    1.  
    2. $SettsMainFlyMenu = array(
    3.     position=>'vertical',
    4.     color=>'red',      // )))
    5.     width=>'150px', // ну и так далее
    6. );
    7.  
    8. $MainMenu = new TFlyMenu($SettsMainFlyMeny);
    9.  
    10. $html->MainMenu = $MainMenu;
    11.  
    12. if( $cat == 10 )   /*если вызывается соответствующая страница */
    13.     {
    14.      $settsProdukshenMenu = array(
    15.          position=>'horizontal',
    16.          color=>'white',      
    17.          width=>'300px', ...
    18.      );
    19.  
    20.      $ProdukshenMenu = new TFlyMenu($SettsProdukshenMenu);
    21.  
    22.      $html->ProdakshenMenu = $ProdukshenMenu;
    23.     }
    само описание класса TFlyMenu гдето спрятано в аналах ресурсных каталогов, и уже больше не беспокоит как оно работает.

    Ещё один плюс: распространять компоненты при такой модели станет намного проще.
     
  2. artem-Kuzmin

    artem-Kuzmin Активный пользователь

    С нами с:
    16 фев 2012
    Сообщения:
    809
    Симпатии:
    0
    Скажу вам сразу минусы если собираетесь внешние цсс генерить то))сами понимаете лишние запросы к серверу)...
    Если в код страницы то представьте 2000тысячи страниц был бы цсс внешний хакэшировался а в тегах стайл повысит размер страницы на кб допустим 5 а зачем это надо)...
    Если хотите как то минимизировать)не знаю есть ли такое уже мысль как то пришла после изучения бэм...
    Все файлы пропустить через скрипт который минимизирует названия классов до 1,2,3 символов сколько понадобится)...
    Это уже думаю экономия..и само собой результат такого хапоминать чтоб постоянно не делать..
    То есть исходник в котором правите длинные имена потом собрать для людей короткие))
     
  3. Your

    Your Старожил

    С нами с:
    2 июл 2011
    Сообщения:
    4.074
    Симпатии:
    7
    Я вообще не понял ваше намерение в создании этой темы.
    Смысл давать, то, что вы не проверяли.

    Или вы надеетесь, что за вас все сразу начнут проверять и писать?)
     
  4. kadet

    kadet Активный пользователь

    С нами с:
    2 авг 2010
    Сообщения:
    79
    Симпатии:
    0
    смысл была в смысле))
     
  5. Your

    Your Старожил

    С нами с:
    2 июл 2011
    Сообщения:
    4.074
    Симпатии:
    7
    Вы находку открыли.
     
  6. kadet

    kadet Активный пользователь

    С нами с:
    2 авг 2010
    Сообщения:
    79
    Симпатии:
    0
    Я же говорил , что может быть сабжем, так что можно закрыть тему..