We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23054
    • 62 Posts
    The following snippet call works:
    [[snippet_name? &param=`[*id*]`]]


    This one not - why ?
    [!snippet_name? &param=`[*id*]`!]


    And what could be a solution ?
      • 36451
      • 264 Posts
      Please check Wendy’s explanation to learn how the Modx Parser works.
        • 23054
        • 62 Posts
        Quote from: yoomai at Jul 04, 2006, 08:28 AM

        Please check Wendy’s explanation to learn how the Modx Parser works.
        I found that - however that means I have to create a further snippet for this instead of using variables ? sad
          • 4041
          • 788 Posts
          perhaps in the top of the existing snippet you can add something like this:

          $pageid = $modx->documentIdentifier;

          this should get you the current doc id of the page the snippet is being called from... ?
            xforum
            http://frsbuilders.net (under construction) forum for evolution
            • 23054
            • 62 Posts
            Quote from: breezer at Jul 04, 2006, 09:44 AM

            perhaps in the top of the existing snippet you can add something like this:

            $pageid = $modx->documentIdentifier;

            this should get you the current doc id of the page the snippet is being called from... ?

            This worked - now I need to find out how to get the page title because [*pagetitle*] does not work if the surrounding snippet is not cached.
            Neither
            $docInfo = $modx->getPageInfo($modx->documentIdentifier);
            $title = $docInfo['pagetitle'];

            nor
            $docInfo = $modx->getDocument($modx->documentIdentifier);
            $title = $docInfo['pagetitle'];

            worked sad
              • 4041
              • 788 Posts
              This should work:

              $pageid = $modx->documentIdentifier;
              
              // grab some page info
              $page_info =$modx->getPageInfo($pageid);
              $pinfo_id = $page_info['id'];
              $pinfo_ptitle = $page_info['pagetitle'];
              $pinfo_desc = $page_info['description'];
              $pinfo_alias = $page_info['alias'];


              $output .="
              pageid = $pinfo_id

              page title = $pinfo_ptitle

              page description = $pinfo_desc

              page alias = $pinfo_alias";

              this produces:
              pageid = 39
              page title = Geshi Highlighter
              page description =
              page alias = highlighter
                xforum
                http://frsbuilders.net (under construction) forum for evolution
                • 23054
                • 62 Posts
                Thanks, found the problem without knowing how to solve ( I am more used to JavaScript than to PHP)


                [!snippet?[[snippet_2]]!]

                whereas in snippet_2 the values are to be determined

                $page_info =$modx->getPageInfo($modx->documentIdentifier);
                $pinfo_id = $page_info['id'];
                $pinfo_ptitle = $page_info['pagetitle'];
                $title = "";
                
                $title = "";
                if (isset($pinfo_ptitle) && strlen($pinfo_ptitle))
                   $title = $pinfo_ptitle;
                
                return "&emailParam=`subject%3DAktualisierung der Seite: " .strlen($title)." (ID [*id*])$title`";
                


                The title contains some ampersands (&) as description for German umlauts (Ä->Ä) that causes the problem  >:(
                So, how to mask the & in the page title ?
                  • 32241
                  • 1,495 Posts
                  You can use an extra snippet for configuration.
                  This is what I usually do. I have a snippet called snippet_name_a, and I have another snippet with snippet_name_a_config

                  Inside snippet_name_a_config, I have this code
                  global $snippet_name_a_config;
                  $snippet_name_a_config = array();
                  $snippet_name_a_config['param1'] = 'value1';
                  $snippet_name_a_config['param2'] = 'value2';
                  


                  While inside the snippet_name_a, I have this code on the beginning, so I can access specific global var from the config
                  global $snippet_name_a_config;
                  if(!isset($snippet_name_a_config)) {
                    // Load all default config parameters needed for the snippet or you can return error, because no config found
                  }
                  


                  The way you use the snippet is
                  [!snippet_name_a_config!]
                  [[snippet_name_a]]
                  


                  Or you can define the snippet calling on the snippet itself by using $modx->runSnippet API.
                  Hope it helps.

                  Sincerely,
                    Wendy Novianto
                    [font=Verdana]PT DJAMOER Technology Media
                    [font=Verdana]Xituz Media