Categories > TinyButStrong general >

Having trouble making [onload.user_mode;onformat=f_user_info;subtpl] work.

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Alan Lake
Date: 2009-12-10
Time: 05:57

Having trouble making [onload.user_mode;onformat=f_user_info;subtpl] work.

I am trying to merge two strings.  PHP's str_replace accomplishes the task.  I am trying to use [onload.user_mode;onformat=f_user_info;subtpl] to do the same thing.  I get the error message TinyButStrong Error in field [onload.user_mode...] : (parameter onformat) user function 'f_user_info' is not found.  Here is my code:

onload_test_1.htm
<html>
<head>
</head>
<body>
<p>Text in the original document.</p>
<p>Merged text "[onload.user_mode;onformat=f_user_info;subtpl]".</p>
<p>More text in the original document.</p>
</body>
</html>
onload_test_1.php
<?
define('ROOT','/home/alan/develop/php/');
define('TINY_MVC_DIR',ROOT.'tinyMVC/');
include_once(TINY_MVC_DIR.'vendor/tbs/tbs_class_php5.php');

class onload_test_1
{
    function __construct()
    {
      global $user_mode;
      $user_mode = "The quick brown fox jumped over the lazy dog.";
      $TBS = new clsTinyButStrong;
      $TBS->MethodsAllowed = true;
      $TBS->LoadTemplate('onload_test_1.htm');
      echo $TBS->Source."<br />";
    }

    function f_user_info($FieldName,&$CurrVal,&$CurrPrm,&$TBS)
    {
        echo "\$user_mode: $user_mode<br />";
        echo "\$FieldName: $FieldName<br />";
        echo "\$CurrVal: $CurrVal<br />";
    }
}

$obj = new onload_test_1();
?>
Thanks for your help.
By: Skrol29
Date: 2009-12-10
Time: 09:44

Re: Having trouble making [onload.user_mode;onformat=f_user_info;subtpl] work.

Hi Alan,

f_user_info() is a method, not a public function.
You can refer to a method with parameter onformat, see the manual here:
http://www.tinybutstrong.com/manual.php#php_oop
By: Alan Lake
Date: 2009-12-10
Time: 14:40

Re: Having trouble making [onload.user_mode;onformat=f_user_info;subtpl] work.

Thanks, Skrol.  That worked.  I assumed that becausethe file onload_test_1.htm was opened within the class that it wouldn't be necessary to specify the class name.  I've made dumber mistakes.  I'm going to post my repaired code here for the sake of others who may have a similar problem.
<html>
<head>
</head>
<body>
<p>Text in the original document.</p>
<p>Merged text "[onload.user_mode;onformat=OnloadTest.f_user_info;subtpl]".</p>
<p>More text in the original document.</p>
</body>
</html>
<?
define('ROOT','/home/alan/develop/php/');
define('TINY_MVC_DIR',ROOT.'tinyMVC/');
include_once(TINY_MVC_DIR.'vendor/tbs/tbs_class_php5.php');

class OnloadTest
{
    function __construct()
    {
      global $user_mode;
      $user_mode = "The quick brown fox jumped over the lazy dog";
      $TBS = new clsTinyButStrong;
      $TBS->MethodsAllowed = true;
      $TBS->LoadTemplate('onload_test_1.htm');
      echo $TBS->Source."<br />";
    }

    function f_user_info($FieldName,&$CurrVal,&$CurrPrm,&$TBS)
    {
        echo $CurrVal;
    }
}

$obj = new OnloadTest();
?>