We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19388
    • 297 Posts
    Welcome to the Forums Jose and thanks for your contribution wink
      • 6228
      • 249 Posts
      Welcome to the community, Jose!

      Well I wanted to see if I could replicate the multiple-execution issue, and I could not. I created a simple snippet, snippet with a function, and a snippet with a function and a call to the function. In each case, the manager log reported only one execution per page load.

      Very strange. Is there something you might have missed, maybe a plugin or customization that is running silently? Have you tried a fresh install? Even just living with the problem, it sounds like your site is not running efficiently with these multiple passes.

      Mike
        lo9on.com

        MODx Evolution/Revolution | Remote Desktop Training | Development
        • 25037
        • 32 Posts
        I think I have a solution for you.

        As I suspected, the problem is with the .htaccess file. With the current .htaccess, if apache finds a url that doesn’t resolve to an existing directory or file, it will send the request through modx:
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?q=$1 [L]
        

        Normally, only the main request would go through modx since all assets (images, css, js) would have the correct urls in your templates. However, this isn’t the case. I’ve tested this with the sample site while logging an error and I can confirm that with your .htaccess I am getting 2 requests running through modx.

        The fix for me was simple though. Simply disallow any urls for the assets directory in particular to go through modx. The solution:
        
        RewriteRule ^(manager|assets)/*$ - [L]
        RewriteRule \.(jpg|jpeg|png|gif|ico)$ - [L]
        
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?q=$1 [L]
        


        This should really be filed as modx a bug if it isn’t already since the .htaccess shipped with modx isn’t sufficient.
          • 3749
          • 24,544 Posts
          Rewrite rules are not my forte, but there is an ht.access file in the manager directory with:

          RewriteEngine Off


          Renaming it to .htaccess might do the trick.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 19388
            • 297 Posts
            Hi guys,
            I’ve tried to rename the .htaccess but as I suspected, the problem persists. I agree with cyclissmo. I think it is something we have missed or some modification caused for us at any moment or in upgrade process. I’ll investigate it deeper, because this is personal now! hehe If we can’t solve it I think we should make a fresh install, that i’m sure will solve the problem.
            Thanks all for your help. We will keep you informed smiley
              • 25037
              • 32 Posts
              mIDO - just to confirm, did you test without a root .htaccess or with fix I made?
                • 19388
                • 297 Posts
                without root htaccess. I renamed it to disable. Any way, this htaccess file is the same that came bundled with MODx Evo. We have it in other installs and works fine.
                  • 3749
                  • 24,544 Posts
                  Did you try enabling the .htaccess in the /manager folder?
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                    • 19388
                    • 297 Posts
                    Hi People,
                    After some aditional tests, I think the problem is PHx related. I didn’t test the page with a blank template and maybe this was the first I should have tested.
                    As I said, the page render is generating only one output but it is like the snippet were executed 3 times. I have made a test in a blank template and the snippet works fine.
                    Then, I took a look to the template, made some modifications and upgraded PHx from 2.1.3 to 2.1.4 but problem persists. I continue looking for the problem, but i’m 99% sure that is template/PHx.
                    As you can see, the template has some conditionals, that must choose one of three chunks depending on a TV value. Each chunk has a [*content*] tag and there is where I think the problem is. But it shouldn’t be a problem because, with the conditionals, this tag should be called only one time.


                    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                    <html xmlns="http://www.w3.org/1999/xhtml">
                    <head>
                    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                    <title>[*pagetitle*] | [(site_name)]</title>
                    <meta name="description" content="Diasan S.A., constituida en 1979, ofrece el servicio de instalación de puertas automáticas y automatismos varios en todas las islas del archipiélago canario, siendo lideres en este sector, con un servicio post venta cualificado." />
                    <meta name="keywords" content="puertas automáticas, puertas garaje, puertas, garaje, seccional, rapidas, batientes, correderas, enrollables, diasan, peatonales, automatismos, barrera de paso, carpintería de aluminio, aluminio, corredera, mantenimiento, breda, faac, canarias, gran canaria, tenerife, fuerteventura, la gomera, el hierro, lanzarote, la palma, troqueladas" />
                    <script type="text/javascript" src="[(base_url)]assets/templates/diasan/Scripts/lightbox/js/prototype.js"></script>
                    <script type="text/javascript" src="[(base_url)]assets/templates/diasan/Scripts/lightbox/js/scriptaculous.js?load=effects"></script>
                    <script type="text/javascript" src="[(base_url)]assets/templates/diasan/Scripts/lightbox/js/lightbox.js"></script>
                    <link rel="stylesheet" href="[(base_url)]assets/templates/diasan/Scripts/lightbox/css/lightbox.css" type="text/css" media="screen" />
                    
                    <link href="assets/templates/diasan/css/style.css" rel="stylesheet" type="text/css" />
                    <link href="[(base_url)]assets/templates/diasan/css/style.css" rel="stylesheet" type="text/css" />
                    <base href="[(site_url)]"></base>
                    <script src="assets/templates/diasan/Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
                    </head>
                    
                    <body>
                    <div id="contenedor">
                    	<div id="cabecera"><img src="assets/templates/diasan/images/diasan_01.png" alt="Diasán. Puertas automáticas" width="900" height="88" /></div>
                    	<div id="menu"><img src="assets/templates/diasan/images/menu2/menuSup_03.png" width="148" height="39" alt="." /><a title="inicio" href="[(site_url)]"><img src="assets/templates/diasan/images/menu2/menuSup_04.png" width="64" height="39" alt="Inicio" /></a><a  title="La Empresa"  href="[~1~]"><img src="assets/templates/diasan/images/menu2/menuSup_05.png" width="92" height="39" alt="Empresa" /></a><a  title="Productos"  href="[~2~]"><img src="assets/templates/diasan/images/menu2/menuSup_06.png" width="118" height="39" alt="Productos" /></a><a  title="Novedades"  href="[~14~]"><img src="assets/templates/diasan/images/menu2/menuSup_07.png" width="129" height="39" alt="Novedades" /></a><a  title="Enlaces"  href="[~4~]"><img src="assets/templates/diasan/images/menu2/menuSup_08.png" width="105" height="39" alt="Enlaces" /></a><a  title="Saldos"  href="[~28~]"><img src="assets/templates/diasan/images/menu2/menuSup_09.png" width="98" height="39" alt="Saldos" /></a><a  title="Contacto"  href="[~5~]"><img src="assets/templates/diasan/images/menu2/menuSup_10.png" width="111" height="39" alt="Contacto" /></a></div>
                    
                    [*subplantilla:is=`profesionales`:then=`
                       {{profesionales_tpl}}
                    `:else=`
                        [*subplantilla:is=`1columna`:then=`
                           {{diasan_1col}}
                        `:else=`   
                    	    [*subplantilla:is=`2columnas`:then=`
                       			{{diasan_2col}}
                    		`*] 
                        `*] 
                    `*] 
                    
                        <div style="clear:both"></div>
                        <div id="pie">Diasán S.A.</div>
                        <div id="logosPie"><img src="assets/templates/diasan/images/logosPie.png" width="111" height="36" alt="Sistema arbitral de consumo. Cerficado de calidad ISO. Marcado CE EN13241-1" /><br/><br/><br/></div>
                    </div>
                    
                    <script type="text/javascript">
                    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
                    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
                    </script>
                    <script type="text/javascript">
                    try {
                    var pageTracker = _gat._getTracker("UA-9345662-1");
                    pageTracker._trackPageview();
                    } catch(err) {}</script>
                    </body>
                    </html>


                    It uses 3 chunks:

                    diasan_1col
                    [*tituloPagina:is=`1`:then=`
                     	   <h1>[*pagetitle*]</h1>
                    `*]
                    <div id="breadcrumbs">[[Breadcrumbs? &showCurrentCrumb=`0` ]]</div>
                    [*content*]


                    diasan_2col
                    <div id="colIzq">[*imagenLateral*]
                        [*botonPPTO:is=`si`:then=`
                     	   {{solicitudPPTO}}
                        `*]
                    </div>
                           <div id="colDer"> 
                    [*tituloPagina:is=`1`:then=`
                     	   <h1>[*pagetitle*]</h1>
                    `*]
                    
                    [*id:ne=`6`:then=`
                    <div id="breadcrumbs">[[Breadcrumbs? &showCurrentCrumb=`0` ]]</div>
                    `:else=`
                    <br/>
                    `*]
                    [*parent:is=`28`:then=`
                           [*saldosFoto:ne=``:then=`<img src="[*saldosFoto*]" alt="[*pagetitle*]" align="right" style="margin-left:10px;"/>`:else=``*]
                    `*] 
                    [*content*]
                            </div>


                    profesionales_tpl
                    <script src="assets/templates/diasan/Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
                    <link rel="stylesheet" href="assets/templates/diasan/css/menuProfesionales.css" type="text/css" />
                    <script src="assets/templates/diasan/css/menuProfesionales.js" type="text/javascript"></script>
                    <link rel="[(base_url)]stylesheet" href="assets/templates/diasan/css/menuProfesionales.css" type="text/css" />
                    <script src="[(base_url)]assets/templates/diasan/css/menuProfesionales.js" type="text/javascript"></script>
                    
                        <div id="colIzq" class="colIzqProfesionales">
                    [*id:ne=`50`:then=`
                    [!WebLoginPE? &type=`simple` &liHomeId=`38` &regHomeId=`50` &loHomeId=`51` &lang=`es` &loginFormTpl=`loginLateral` &successTpl=`menuProfesionales` &messageTpl=`errorLogin` &resetTpl=`recPassword`  !]
                    `:else=`
                    <p>Gracias por darse de alta en la zona de profesionales de Diasan. Una vez dado de alta podrá acceder a los siguientes servicios: </p>
                    <ul>
                      <li>Noticias: Información actualizada de nuevos productos, comunicados técnicos, etc...</li>
                      <li>Productos: Fotos e información sobre los productos disponibles.</li>
                      <li>Documentos: Material que le ayudará en su trabajo diario.</li>
                      <li>Solicitud de presupuestos on-line.</li>
                      <li>Enlaces: Links a sitios web de interés.</li>
                    </ul>
                    <p>El registro no será inmediato, ya que debemos comprobar sus datos antes de activar su cuenta. Una vez completado el proceso de registro, nos pondremos en contacto con usted para completar el proceso de alta.</p>
                    `*]
                        </div>
                        <div id="colDer" class="colDerProfesionales">
                    [*tituloPagina:is=`1`:then=`
                    <h1 class="tituloProfesionales">[*pagetitle*]</h1>
                    `*]
                    [*content*]
                        </div>

                      • 19388
                      • 297 Posts
                      I tried it with a less nested version of the template, but same problem:
                      [*subplantilla:is=`profesionales`:then=`
                         {{profesionales_tpl}}
                      `*] 
                      
                      [*subplantilla:is=`1columna`:then=`
                         {{diasan_1col}}
                      `*]  
                      
                      [*subplantilla:is=`2columnas`:then=`
                         {{diasan_2col}}
                      `*]  
                      


                      EDIT: I changed PCRE in php.ini too