We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17125
    • 11 Posts
    Can we call a snippet from a chunk ?

    When I do so, the call is rendered without execution !

    I mean it just shows [!Personalize? &message=`Welcome back,` &wrapper=`h3` &class=`welcome`!] without
    processing it.
    I expected the output of snippet in the form of Welcome back, username

    I was calling this snippet in the FormLogin chunk.

    Is it not allowed or some other reason ?
    huh
      • 7231
      • 4,205 Posts
      try changing the tags to the cached version [[ ]] rather than [! !], this often resolves these problems.
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 17125
        • 11 Posts
        It does not work, even with cached version of the call.
        With cached version([[..]]), nothing is displayed.
        Whereas with noncached ([!..!]) the call is displayed as it is in text form!

        These calls are working fine from a normal document.
        So, there is no syntaxical error or anything in the call.
        They just fail to work from within a chunk ?!
          • 7231
          • 4,205 Posts
          Try disabling the cache of the document itself. I use snippets within chunks all of the time with out any problems. I suspect that the problem may be related to personalize itself, making it more susceptible to cache issues.
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don't know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 17125
            • 11 Posts
            Thanks.
            Since this is the "FormLogin" chunk appearing in the sidebar called from the snippet "WebLogin",
            it appears in all pages, disabling cache would be difficult... huh
              • 7231
              • 4,205 Posts
              It just accured to me that you are not using valid Personalize snippet perameters.

              # Params:
              # &yesChunk [string] [REQUIRED]
              # Output for LOGGED users
              #
              # &noChunk [string] [REQUIRED]
              # Output for NOT logged users
              #
              # &ph [string] (optional)
              # Placeholder for placing the username
              # ATTENTION!: place this ph only in yesChunk!
              #
              #
              # Example Usage:
              #
              # [[Personalize? &yesChunk=`Link` &noChunk=`Register` &ph=`name`]]

              Did you create your own snippet named Personalize? If so you may have two snippets with the same name.
                [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                Something is happening here, but you don't know what it is.
                Do you, Mr. Jones? - [bob dylan]
                • 17125
                • 11 Posts
                Thanks, but I am using the 1.0 version of Personalize snippet.
                This snippet just checks to see if webusers are logged in, and if they are displays their login name.

                It is working on normal page but not when i run in a chunk.

                Ofcourse, I could use the newer version, but just got stuck up as to why the chunk cannot show output from a snippet.
                This is more to know whether snippet calls are allowed in chunks, if they are not, then I would avoid coding this way.

                  • 36592
                  • 970 Posts
                  Why do you have to put your snippet code in Weblogin template ?
                  The template consists of three sections
                  section 1: login template
                  section 2: logout template 
                  section 3: password reminder template 
                  

                  It is a little different from other templates system like Ditto...
                    • 17125
                    • 11 Posts
                    Thanks.
                    I was putting this is in the "logout section" to show a welcome message with username.
                    If it does not work in Weblogin template, then its fine.

                    But does a snippet call generally work in a chunk ?
                    Also, is there some other way to pass the username to Weblogin template somehow ?

                    I just want to show a simple "Welcome $username" on the sidebar to all the logged in users.
                      • 36592
                      • 970 Posts
                      Quote from: lightx at May 08, 2008, 01:51 AM

                      But does a snippet call generally work in a chunk ?
                      I’m sure it does !

                      I just want to show a simple "Welcome $username" on the sidebar to all the logged in users.
                      I tried the same thing, but with Personalize 2.0.

                      I put this Personalize snippet call in the logout section of WebLogin template ’FormLogin’.
                      [[Personalize? &yesChunk=`WelcomeWebUser` &ph=`webusername`]]
                      


                      The ’WelcomeWebUser’ chunk has these lines.
                      <div id="welcome_message">
                      Welcome, [+webusername+] !
                      </div>
                      


                      And my template has WebLogin snippet call like this.
                      [!WebLogin? &tpl=`FormLogin` &loginhomeid=`[(site_start)]`!]
                      


                      I get ’Welcome, tkfm!’ on my page !