We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    This is an auto-generated topic for Personalize 3.2-beta1 by bobray.

    Brief Description:

    Shows one chunk to logged-in users and another to everyone else.
    Optionally sets username or user full name as a placeholder.
      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
      • 6531
      • 154 Posts
      Is it possible to call a Snippet rather than a Chunk?
      Or do I have to nest the Snippet within a Chunk?
        • 3749
        • 24,544 Posts
        I’m afraid you’d have to put the snippet in the chunk as it is now, although it shouldn’t be hard to modify it to run a snipppet instead:

        just change

        $modx->getChunk($whatever);


        to

        $modx->runSnippet($whatever);
          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
          • 6531
          • 154 Posts
          OK, thanks.
          Ideally, as a request for next version, I’d love to be able to call it like so:
          [[!Personalize?
             &yes=`[[YesSnippet]]`
             &no=`[[$NoChunk]]`
          ]]
          

          ... if you know what I mean...
            • 3749
            • 24,544 Posts
            Quote from: danzg at Nov 05, 2010, 04:59 PM

            OK, thanks.
            Ideally, as a request for next version, I’d love to be able to call it like so:
            [[!Personalize?
               &yes=`[[YesSnippet]]`
               &no=`[[$NoChunk]]`
            ]]
            

            ... if you know what I mean...

            I do, but I don’t think it will work that way. It would have to look more like this:

            [[!Personalize?
               &yes=`SnippetName]]`
               &no=`[[$ChunkName]]`
               &yesType=`snippet`
               &noType=`chunk`
            ]]
            


            And you’d have to promise not to ask for parameters for the yes or no snippets. wink
              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
              • 6531
              • 154 Posts
              OK, Maybe I’ll just make a PersonalizeSnippet snippet to call snippets!

              Also -- I tried lifting this bit of code from Personalize:

              [tt]if ($modx->user->hasSessionContext($modx->context->get(’key’)) )[/tt]

              for use in one of my own snippets to add a bit stuff when someone is logged in. But it did not work! It rendered the following [tt]{}[/tt] regardless.

              Do you know why this might be?
                • 6531
                • 154 Posts
                Upon reflection ... I think I COULD make it do what I want ... if I call it using
                [tt][[!Personalize?
                &yes=`!YesSnippet`
                &no=`$NoChunk`
                ]]
                [/tt]

                then I could add some code the the snippet to parse the first character, strip it off, then execute the matching modx call ....

                Right? Just might do that ...
                  • 3749
                  • 24,544 Posts
                  Yes, that should work. You’d have to parse any snippet argumenst also, which would be trickier.

                  On the hasSessionContext() call: It’s always worked for me and your code looks right, though it would depend on what comes after the "if" statement.
                    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
                    • 20014
                    • 200 Posts
                    BobRay was wondering if there is some documentation and examples on this package, checked RTFM the Wiki, and your site, plus core components (and packages just in case) in my revo install and can’t seem to find any.
                      • 3749
                      • 24,544 Posts
                      Quote from: modxlearner123 at Dec 05, 2010, 12:10 PM

                      BobRay was wondering if there is some documentation and examples on this package, checked RTFM the Wiki, and your site, plus core components (and packages just in case) in my revo install and can’t seem to find any.

                      There’s not much to it:

                      Install with Package Manager
                      Call with

                      [[!Personalize? &yesChunk=`chunk1` &noChunk=`chunk2`]]


                      Optional parameters:
                      &ph=`name` -- sets placeholder for user’s username in [[+name]] placeholder
                      &fullName=`1` -- uses full name for placeholder instead of username

                      Just create two chunks called chunk1 and chunk2 and put the snippet tag abovein your document content section or in the page’s template.

                      The tag will be replaced by the content in chunk1 for logged-in users and by the content in chunk2 for all other users.


                        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