We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37825
    • 14 Posts
    Hiya,

    I have got a plugin started and I want to use it to generate template variables but I cannot find anywhere that explains how to put them into the template. I have created a template variable, and can see it there when I dump modx object, but it's always the default value no matter what I do.

    Cheers
      • 4172
      • 5,888 Posts
      ok, a plugin, which generates template variables. hmm...

      how to put them into the template? just edit your template and put the tv-tags there. Or what do you mean with put them into the template.

      how do you dump the modx-object ??

      sorry, I don't understand what you are trying todo
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 37825
        • 14 Posts
        Hi Bruno,

        I have made a basic plugin that gets called OnWebPagePrerender

        I want to use it to geneate page content, so need to pass this content as a variable to the template.

        I created the TV, and i've got the default value showing where I want it, but I want to be able to change it using the plugin.

        For example, I am making something that shows a list to a user, but this list is of stuff relating to the user, so I'd like to form that list in the plugin and show it to the user.

        Maybe I have it all wrong in terms of bese use of Mod X, but this seems quite simple.

        I should say that I am still new to Mod X and rather gingerly finding my round it.

        Thanks!

          • 4172
          • 5,888 Posts
          well, the normal way is to put a snippet into your template, where you want to show the list.

          which kind of snippet depends on where you have stored the records for your list.
          If this are modx-resources you can use the getResources-snippet.

          If this are records of custum-tables you can use rowboat or you can use own custom-snippets for more complicated tasks.

          to show only stuff for logged in users you can filter the datas to show by a userid or by usergroups or use modx-permissions

          normally you wouldn't need to create a plugin for that.

            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 37825
            • 14 Posts
            Hiya, thanks... I've just been tring out snippets but it looks like it gets cached.

            In the snippet I've included a file because working on PHP in the browser text box is just annoying but it only loads the changes I make on a new page load.

            Inside my file is a class, but the very fact that this snippet is being called half way through processing the output is a bit weird, is there a way of getting plugins to communicate with snippets? But would that end up being cached too?

            Mod X is weird..
              • 4172
              • 5,888 Posts
              you can call snippets cached:
              [[mySnippet]]
              and uncached:
              [[!mySnippet]]


              and you can switch the page itself, where you have running your snippet cachable/uncachable [ed. note: Bruno17 last edited this post 14 years, 11 months ago.]
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 37825
                • 14 Posts
                Thanks that helps! I'll see what I can do about linking in the plugin.