We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27910
    • 48 Posts
    Ok

    Let’s take this a bit furhter.

    How would one make it so that, let’s say I want to create a "module" which can just be dropped into a modules folder, that modx will pick it up, and give you a choise to enable it, and then use it.

    Similar to what Xoops does, I think. Or was it Drupal?

    So, basically you have something like this, @ the top of the file:

    <?
    $type="module"l
    $min_modx="0.9.2";
    $name="Web Calendar";
    $author="Me";
    $other_needed_variable="What else is needed";
    ?>

    that way, it could be rather universal. Mambo uses a similar scenario. Once the file is uploaded, you can find it under either the Modules, Components, or Mambot section. Then you just need to publish it, and make changes to it as you like
      cPanel :: Fantastico :: RVSkin :: WHM :: ModernBill :: Reseller Hosting :: SSL Certificates :: Domain Registrations :: Affiliate Program :: Blog Hosting :: CMS Hosting :: Forum Hosting :: E-Commerce Hosting
      SoftDux- The Leaders in Software
      Use the coupon: modx to get 20% off our packages
    • First, a module in MODx is not the same as in Drupal or Xoops. MODx modules are currently the name for applications that can be integrated into the MODx management interface.

      And I don’t really understand what those vars have to do with anything at the top of the file. You install add-ons in MODx via the manager interface. You can certainly add what variables you want to any PHP component (snippet, module, plugin), or create PHP includes with those variables, but the architecture of MODx does not demand these variables, as equivalents of most of these examples are already available through MODx.

      Future features which may address what you’re looking for include easy-installation and/or configuration wizards for MODx add-ons.
        • 27910
        • 48 Posts
        Ok, so let’s call them add-ons then. Module is a general word, and most systems can refer to it.

        anyway, that set aside.

        If you’v worked on Drupal, Mambo, Xoops, etc etc you’d understand what those do.

        As a developer, if you want to create a module / add-on which can very easily be plugged into the system you need to add a few lines to the top which would "idenitify" the module you are creating.....



        .... something just hit me. What I’m trying to say is probaly already in modx, it’s just called something different to what I’d expect it to be, and it probably functions differently as wel. So, just ignore this post
          cPanel :: Fantastico :: RVSkin :: WHM :: ModernBill :: Reseller Hosting :: SSL Certificates :: Domain Registrations :: Affiliate Program :: Blog Hosting :: CMS Hosting :: Forum Hosting :: E-Commerce Hosting
          SoftDux- The Leaders in Software
          Use the coupon: modx to get 20% off our packages
          • 23054
          • 62 Posts
          Quote from: OpenGeek at Jul 09, 2006, 10:39 PM

          If you mean the parameter string from the client request, you get that with $_REQUEST or $_GET or $_POST as appropriate. If you mean the snippet parameter string, each will be set as a variable with the key as the name, within the scope of the snippet. Your var names would simply be $key_1, $key_2, ...

          $_REQUEST is a good idea, but it returns strange results:
          document code:
          [!snippet?&id=`DisplayName`&param=`%26$name%3DVorspiel`!]
          

          code in snippet
          $x = "";
          foreach ($_REQUEST as $key=>$value)
          $x .= $key . ' ' . $value . '<br>';
          return $id . " : " . $x;
          


          leads to the output:
          DisplayName : SN44a7f555155cd 9325a6fbbf1ca14da11bfcd4e364d419
          webfxtab_resourcesPane 3 embarrassed

          A you can see above I found a way around - to put all parameters in one variable called $param. Therefore you have to mask & as %26 and = as %2D.
          Now I parse the $param and return an array
          function formatURLParameterToArray($paramListe)
          {if (!isset($paramListe) || strlen($paramListe)<1)
                  return null;
          
              $paramListe = urldecode($paramListe);
              $paramArray = array();
          
              # erstes & entfernen
              if (strpos($paramListe,'&')==0)
                  $paramListe = substr($paramListe,1);
          
              $a = explode('&', $paramListe);
              $i = 0;
              while ($i < count($a))
              {   $b = split('=', $a[$i]);
                  $paramArray[htmlspecialchars(urldecode($b[0]))] =
                      htmlspecialchars(urldecode($b[1]));
                  $i++;
              }
          return $paramArray;
          }
          


          This works, but you have to mask the & and = - that is not really a readable code.
          $_REQUEST would be much better


          • Hi persepolis,

            $_REQUEST is a good idea, but it returns strange results ...
            The problem here is that you have mixed and matched $_REQUEST with the snippet parameters being passed into the snippet. They are two very separate sets of values.

            $_REQUEST variables (including $_GET or $_POST) are called client request variables. $_GET variables are passed via the URL (eg. mysite.com/index.html?myGetVar1=1&myGetVar2=2) and $_POST variables are created when a form is posted back from the client.

            Snippet parameters are automatically created as string variables by the MODx document parser, in your example:
            return $id;

            would return the desired value of ’displayName’.

            Hope that helps (rather than confusing further),
            Garry
              Garry Nutting
              Senior Developer
              MODX, LLC

              Email: [email protected]
              Twitter: @garryn
              Web: modx.com
              • 23054
              • 62 Posts
              Quote from: garryn at Jul 10, 2006, 08:33 PM

              Hi persepolis,

              The problem here is that you have mixed and matched $_REQUEST with the snippet parameters being passed into the snippet. They are two very separate sets of values.

              $_REQUEST variables (including $_GET or $_POST) are called client request variables. $_GET variables are passed via the URL (eg. mysite.com/index.html?myGetVar1=1&myGetVar2=2) and $_POST variables are created when a form is posted back from the client.
              Snippet parameters are automatically created as string variables by the MODx document parser, in your example:
              return $id;

              would return the desired value of ’displayName’.

              Hope that helps (rather than confusing further),
              Garry
              Hi Garry

              hm, that doesn’t help much as I need to determine the variable names and their values at runtime.
              So I think my workaround to put the parameter list in a masked parameter $param is the best way although that is not good readable by human eyes.
              But it works grin

              Regards
              Holger