We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33175
    • 711 Posts
    This is an auto-generated support/comment thread for CssSwitcher.

    Use this forum to post any comments about this addition or any questions you have regarding its use.

    Brief Description:
    A small snippet for users to switch between different style sheets, from the frontend.
      Sorry for my english. I'm french... My dictionary is near me, but it's only a dictionary !
      • 17673
      • 194 Posts

      After succesfully installing and configuring MaxiGallery and DittoCal in one afternoon, I’m struggling with this one!

      It is working when called in the header of my template [!CssSwitcher? &display=`0` !] , thus the $csspath configuration variable is right, but when I try to call it to display an html list with a chunk, I get the Static HTML contained in the chunk (thus all references are correct),but nothing gets substituted in place of the ’[-selectoptions-]’ tag, i.e. no <ul><li>... ?!?! the folder does contain 4 css sample files!

      CssSwitcher call:
      [[CssSwitcher? &display=`1` &parsefolder=`1` &htmllist=`1` &chunk=`StyleSwitch` ]]

      sample code from the StyleSwitch chunk:
      <p>
      Css Choiches: [-selectoptions-]
      </p>
        ----------------------------------------------------------
        http://www.linkedin.com/in/lucapost/
        http://www.twitter.com/lukwe/
        ----------------------------------------------------------
        • 17673
        • 194 Posts

        still experiencing problems and errors -if I call the snippet uncached I get:

        [tt]Fatal error: Cannot redeclare getchunk() (previously declared in /user0/htdocs/modx/manager/includes/document.parser.class.inc.php(724) : eval()’d code:277) in /user0/htdocs/modx/manager/includes/document.parser.class.inc.php(724) : eval()’d code on line 312[/tt]

        I can only run the snippet if I call it in the header part of the template with &display=’0’
          ----------------------------------------------------------
          http://www.linkedin.com/in/lucapost/
          http://www.twitter.com/lukwe/
          ----------------------------------------------------------
          • 10487 MODX Staff
          • 1,535 Posts
          lukwe,

          You can solve that error by looking for where the getchunk() function is specified and wrapping the function code like this:
          if (!function_exists('getchunk')) {
            // insert getchunk function
          }
          

          I’m not sure if the snippet uses any other functions as I haven’t looked at it to be honest. But, if it does, then repeat the same process for all the function declarations in the snippet.

          Hope that helps,
          Garry
            Garry Nutting
            Senior Developer
            MODX, LLC

            Email: [email protected]
            Twitter: @garryn
            Web: modx.com
            • 17673
            • 194 Posts
            Quote from: garryn at Oct 06, 2006, 07:43 AM

            if (!function_exists('getchunk')) {
              // insert getchunk function
            }

            I’m not sure if the snippet uses any other functions as I haven’t looked at it to be honest. But, if it does, then repeat the same process for all the function declarations in the snippet.
            Doing this returns a similar error for another function (freeCommonVars):
            [tt]Fatal error: Cannot redeclare freecommonvars() (previously declared in /user0/htdocs/modx/manager/includes/document.parser.class.inc.php(724) : eval()’d code:322) in/user0/htdocs/modx/manager/includes/document.parser.class.inc.php(724) : eval()’d code on line 327[/tt]
            Treating this other function with
            if (!function_exists('freeCommonVars')) {
              // insert freeCommonVars function
            }
            

            returns:
            [tt]Fatal error: Call to undefined function freeCommonVars() in /user0/htdocs/modx/manager/includes/document.parser.class.inc.php(724) : eval()’d code on line 241[/tt]
            these 2 errors are now generated by any page of the site, not just when calling the snippet (??!?)
            ...reverting the snippet to its original state and leaving it alone for the week-end!
              ----------------------------------------------------------
              http://www.linkedin.com/in/lucapost/
              http://www.twitter.com/lukwe/
              ----------------------------------------------------------
              • 27166
              • 58 Posts
              Hello,

              I’m having the same kind of problem when trying to use the snippet.

              I put in the line in the header - [!CssSwitcher? &defaultcss=`threecolumn` &display=`0` !]

              I then call the snippet like this in the page (through a chunk) - [[CssSwitcher? &display=`1` &parsefolder=`1` &htmllist=`1` &chunk=`styleswitch`]] which means when I go to the page you have to hit refresh to get the page to come up (then the switcher works fine).

              I realize this is a caching problem however when I do - [!CssSwitcher? &display=`1` &parsefolder=`1` &htmllist=`1` &chunk=`styleswitch`!] the page wont display at all.

              Tried unticking cache in the manager for a few pages and looking at them, they don’t display.

              Anyway round this one? I’m using ModX 0.9.2 as unable to update the site at the moment for one reason or another.

              Many thanks,
              Sian



                • 19986
                • 90 Posts
                The problem is that some versions of php require you to declare a function before you use it. Move both function declarations to the top of the snippet and you should be ok.
                  • 21483
                  • 32 Posts
                  In the header, should I link to all the external style sheets that i want this snippet to list? Or is enough just to link to the default sheet, and set the directory in the snippet code?

                  Can anyone help me set this snippet up correctly? http://modxcms.com/forums/index.php/topic,12556.0.html
                    • 21483
                    • 32 Posts
                    Thx again doze, but it seems I’m having serious problems with this snippet.

                    I can call the snippet in the head and make it do stuff, or call it in the body and do stuff, but if I call it in both the head AND the body then i get this error message in firefox: Fatal error: Cannot redeclare getchunk() (previously declared in /mounted-storage/home43c/sub002/sc32329-SIRJ/kreativpotens.dk/modx/manager/includes/document.parser.class.inc.php(748) : eval()’d code:278) in /mounted-storage/home43c/sub002/sc32329-SIRJ/kreativpotens.dk/modx/manager/includes/document.parser.class.inc.php(748) : eval()’d code on line 313

                    IE7 just shows a blank page. I get this error no matter what I put in the body snippet call.
                      • 19986
                      • 90 Posts
                      As mentioned earlier in this thread, you’ll need to modify the snippet to test whether the function already exists before it’s defined.

                      if (!function_exists('functionName')) {
                        // insert functionName function
                      }


                      Do this for every function, obviously replacing functionName with the function name.