We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4195
    • 398 Posts
    *bump* version 1.0
      Armand Pondman
      MODx Coding Team
      :: Jot :: PHx
      • 18219
      • 826 Posts
      Great works Bs.
      I test your plugin now for integrate in a snippet but I have the error message according to:
      Fatal error: Call to a member function addTemplate() on a non-object in D:\www\mx_mac\assets\snippets\maxigallery\maxigallery.php on line 258
      


      Here the code which I placed in the snippet
      $variable='hello';
      $template = $modx->tbsTpl->addTemplate("assets/snippets/maxigallery/maxigallery.tpl");
      $modx->tbsTpl->addField($template,'variable',$variable);
      $modx->tbsTpl->addBlock($template,'myarray',$myarray); 
      $output .= $template;
      

      Do you have an idea of the origin of Pb?
      PS : I installed the plugin (version 1.0.0) as indicated in the post

      Thanks
        Marc
        I'm French... Sorry for my bad English, I use ' Google Translator' or other... but that remains that tools wink
        • 1876
        • 835 Posts
        Hi mark

        Do you copy tbs4modx.class.inc.php in [MODx Directory]/assets/plugins/tbs4modx ?
          • 18219
          • 826 Posts
          Yes,
          I followed the instructions indicated on the post. As I am (locally, conf WAMP5) with PHP5 I changed the name of the class as indicated.
            Marc
            I'm French... Sorry for my bad English, I use ' Google Translator' or other... but that remains that tools wink
            • 18219
            • 826 Posts
            I found: In the file “tbs4modx.plugin.txt” the instruction <?php remained in the first line. I deleted this.
            I also changed the initialization of the variable $template which must contain code HTML and not the URL of the file template.
            On the other hand my variable is not interpreted .
              Marc
              I&#39;m French... Sorry for my bad English, I use &#39; Google Translator&#39; or other... but that remains that tools wink
              • 4195
              • 398 Posts
              you’re right.. template has to be a string smiley

              code looks good... but variable doesn’t display?
              What does your template look like?

              but I think this is a mistake somewhere in my plugin code , i’m on it smiley

              I will also fix the <php issue smiley

              just to be clear with addField you can also use arrays but with addBlock it only makes sense if you use arrays wink
                Armand Pondman
                MODx Coding Team
                :: Jot :: PHx
                • 18219
                • 826 Posts
                Quote from: bS at Jun 15, 2006, 08:20 AM

                ...
                code looks good... but variable doesn’t display?
                What does your template look like?
                ...
                No, my variable is not display.
                My template is content to a variable PHP:
                $tpl1='
                	<h3  style="text-align:center;">test tiny</h3>
                	[{variable}]
                ';
                $variable='hello';
                $template = $modx->tbsTpl->addTemplate($tpl1);
                $modx->tbsTpl->addField($template,'variable',$variable);
                $modx->tbsTpl->addBlock($template,'myarray',$myarray); 
                $returnstring .= $template;
                

                I want test a plugin before going further.

                Other note: if I remove the line $modx->tbsTpl->addBlock($template,’myarray’,$myarray);, I have a fatal error, however in my code I do not have any array but I must keep this line huh


                  Marc
                  I&#39;m French... Sorry for my bad English, I use &#39; Google Translator&#39; or other... but that remains that tools wink
                  • 4195
                  • 398 Posts
                  i found the bugs, hold on smiley
                    Armand Pondman
                    MODx Coding Team
                    :: Jot :: PHx
                    • 4195
                    • 398 Posts
                    Hmm very strange.. it seems that a single variable value isn’t working as it should in TBS huh
                    I will try to figure out why..

                    simple workaround is to use:
                    $array_variables = array(
                    	'name'=>$value,
                            'othername'=>$othervalue
                    );
                    
                    $modx->tbsTpl->addField($tpl,'namespace',$array_variables );
                    

                    and use
                    [{namespace.name}]
                    [{namespace.othername}]
                    


                    in your template.

                    ea.

                    For my upcoming release of the replix snippet I stuffed all the non-block variables in an array with the namespace "replix" so i can check them using [{replix.variable}]
                      Armand Pondman
                      MODx Coding Team
                      :: Jot :: PHx
                      • 4195
                      • 398 Posts
                      release 1.0.2 ->
                      Fixed the error you got when no addBlock or addField was used.
                        Armand Pondman
                        MODx Coding Team
                        :: Jot :: PHx