We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49572
    • 8 Posts
    Всем доброго времени суток.

    Решил изучать modx.....

    Есть яваскрипт, который вывод окно с хитрой регистрацией ( но это не важно)...

    Как мне в меню вставить этот яваскрипт?
      • 49529
      • 196 Posts
      tozter, напишите подробнее. Как сейчас выводится меню?
        • 49572
        • 8 Posts
        Подробнее - это сложно... Я только пару дней назад начал изучать modx........

        Что конкретно интересует?
          • 49529
          • 196 Posts
          Покажите кусок html с вашим меню, для начала.
          Покажите кусок шаблона MODX, который отвечает за вывод меню.
          Дайте ссылку на сайт, если это возможно.
          Сейчас ваш вопрос звучит очень общо и ответить на него вряд ли можно.
            • 49572
            • 8 Posts
            Wayfinder:
            <?php
            /**
             * Wayfinder Snippet to build site navigation menus
             *
             * Totally refactored from original DropMenu nav builder to make it easier to
             * create custom navigation by using chunks as output templates. By using
             * templates, many of the paramaters are no longer needed for flexible output
             * including tables, unordered- or ordered-lists (ULs or OLs), definition lists
             * (DLs) or in any other format you desire.
             *
             * @version 2.1.1-beta5
             * @author Garry Nutting (collabpad.com)
             * @author Kyle Jaebker (muddydogpaws.com)
             * @author Ryan Thrash (modx.com)
             * @author Shaun McCormick (modx.com)
             * @author Jason Coward (modx.com)
             *
             * @example [[Wayfinder? &startId=`0`]]
             *
             * @var modX $modx
             * @var array $scriptProperties
             * 
             * @package wayfinder
             */
            $wayfinder_base = $modx->getOption('wayfinder.core_path',$scriptProperties,$modx->getOption('core_path').'components/wayfinder/');
            
            /* include a custom config file if specified */
            if (isset($scriptProperties['config'])) {
                $scriptProperties['config'] = str_replace('../','',$scriptProperties['config']);
                $scriptProperties['config'] = $wayfinder_base.'configs/'.$scriptProperties['config'].'.config.php';
            } else {
                $scriptProperties['config'] = $wayfinder_base.'configs/default.config.php';
            }
            if (file_exists($scriptProperties['config'])) {
                include $scriptProperties['config'];
            }
            
            /* include wayfinder class */
            include_once $wayfinder_base.'wayfinder.class.php';
            if (!$modx->loadClass('Wayfinder',$wayfinder_base,true,true)) {
                return 'error: Wayfinder class not found';
            }
            $wf = new Wayfinder($modx,$scriptProperties);
            
            /* get user class definitions
             * TODO: eventually move these into config parameters */
            $wf->_css = array(
                'first' => isset($firstClass) ? $firstClass : '',
                'last' => isset($lastClass) ? $lastClass : 'last',
                'here' => isset($hereClass) ? $hereClass : 'active',
                'parent' => isset($parentClass) ? $parentClass : '',
                'row' => isset($rowClass) ? $rowClass : '',
                'outer' => isset($outerClass) ? $outerClass : '',
                'inner' => isset($innerClass) ? $innerClass : '',
                'level' => isset($levelClass) ? $levelClass: '',
                'self' => isset($selfClass) ? $selfClass : '',
                'weblink' => isset($webLinkClass) ? $webLinkClass : ''
            );
            
            /* get user templates
             * TODO: eventually move these into config parameters */
            $wf->_templates = array(
                'outerTpl' => isset($outerTpl) ? $outerTpl : '',
                'rowTpl' => isset($rowTpl) ? $rowTpl : '',
                'parentRowTpl' => isset($parentRowTpl) ? $parentRowTpl : '',
                'parentRowHereTpl' => isset($parentRowHereTpl) ? $parentRowHereTpl : '',
                'hereTpl' => isset($hereTpl) ? $hereTpl : '',
                'innerTpl' => isset($innerTpl) ? $innerTpl : '',
                'innerRowTpl' => isset($innerRowTpl) ? $innerRowTpl : '',
                'innerHereTpl' => isset($innerHereTpl) ? $innerHereTpl : '',
                'activeParentRowTpl' => isset($activeParentRowTpl) ? $activeParentRowTpl : '',
                'categoryFoldersTpl' => isset($categoryFoldersTpl) ? $categoryFoldersTpl : '',
                'startItemTpl' => isset($startItemTpl) ? $startItemTpl : ''
            );
            
            /* process Wayfinder */
            $output = $wf->run();
            if ($wf->_config['debug']) {
                $output .= $wf->renderDebugOutput();
            }
            
            /* output results */
            if ($wf->_config['ph']) {
                $modx->setPlaceholder($wf->_config['ph'],$output);
            } else {
                return $output;
            }
            



            Вывод меню, чанк navigation :

            <body id="preload">
              <div class="main">
            	<nav id="navigation" class="genderChange">
            	  <ul class="nav">
            	  [[!changeGender? &gender=`man` &rowTpl=`navMan`]]
            	  [[!changeGender? &gender=`woman` &rowTpl=`navWoman`]]
            			
            
            	</ul>
            		<!--[[Wayfinder? &startId=`0` &level=`1` &outerClass=`nav`]]-->
            		<div id="lightbox">
            
            			<div class="row">
            				<div class="grid-12">
            					<div class="heading genderChange">Уважаемые дамы и господа!</div>
            					<p>У нас существует online запись на все виды услуг! Вы оставляете вашу заявку, заполняя бланк и в течении 15 минут с Вами свяжется администратор, чтобы уточнить и подтвердить вашу заявку.</p>
            					<p>С уважением, <strong>салон красоты BeautyRooms!</strong></p>
            				</div>
            			</div>
            
            
            			<div class="row">
            
            
            
            
            			</div>
            		</div>
            	</nav>
            



            Сайт beauty-rooms.ru
              • 49529
              • 196 Posts
              tozter, чуть понятнее сейчас, но в чем именно проблема? Размещать javascript именно внутри Wayfinder-a необходимости явно нет. Но можно же просто написать его рядом.

              К какому пунку меню на своем сайте вы хотите привязать javascript и что именно он должен делать? Опишите, какого именно результата вы хотите добиться.
                • 49572
                • 8 Posts
                На кнопку "Записаться онлайн" (вверху) хочу повесить скрипт, который вызывается кнопкой что сейчас на сайте в самом низу (Записаться онлайн) прописана.

                Сейчас этот яваскрипт вставлен в чанке "scripts"
                  • 49529
                  • 196 Posts
                  Вам всего-то надо в файле custom.js заменить кусок кода
                  var lightbox = document.getElementById('lightbox'),
                      attr = lightbox.getAttribute('class');
                    if (attr === 'active') {
                      lightbox.classList.remove('active');
                    } else {
                      lightbox.classList.add('active');
                    }
                  


                  на
                  $('.ms-button').trigger('click');
                  
                    • 49572
                    • 8 Posts
                    Да, работает, но это немного не то....

                    Я хочу убрать нижнюю кнопку (Записаться онлайн) совсем.

                    Куда прописать скрипт нижней кнопки (Записаться онлайн), что б при нажатии на верхнюю (Записаться онлайн) открывалось окно записи?
                      • 49529
                      • 196 Posts
                      Судя по коду, скрипт, отвечающий за добавление на сайт и вывод окна регистрации, находится не на вашем сайте, а на сайте moresalonov.ru, поэтому отредактировать его не получится. Самый простой способ скрыть нижнюю кнопку - с помошью css. Добавтьте в свой файл css:
                      #ms-booking-button-container { display: none }