Categories > TinyButStrong general >

blocks, fields and object oriented programmation

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: arkhi
Date: 2011-05-13
Time: 10:42

blocks, fields and object oriented programmation

Hello again!

We encounter some problems with blocks, fields and object oriented programmation with TBS.

We have an object "Office" which has a method getEmployeeNames().
getEmployeeNames() returns a string array of employee names like "array('Kathy','John','Ben')".
In the viewOffice.php we do the following (NOTE $officeArray is an array of Office objects):

<?php
  $TBS = new clsTinyButStrong;
  *******************************************************************************/
  $TBS->LoadTemplate('design/templates/viewOffice.html');
  *******************************************************************************/
  $TBS->MergeBlock('office', 'array', $officeArray);
  $TBS->Show();
?>

In our template we are trying to iterate over the employee name array returned by the getEmployeeNames() function.

When the designer is using a manually written array of that type for tests, it works:

$officeArray = array(
  'Department' => array(
    'title'       => 'Design',
    'employee'    => array('Kathy','John','Ben')
);

and "viewOffice.htm"

<article id="office_[employee.#;block=article;sub1=(employee)]">
  <ul>
    <li class="employee">
      <small>
        [office_sub1;block=begin;bmagnet=li;when [office_sub1.#]!=1], [office_sub1;block=end]<a>[office_sub1.val;block=a]</a>
      </small>
    </li>
  </ul>
</article>

will display "<a>Kathy</a>, <a>John</a>, <a>Ben</a>" in the item of the list.

But with the following template for "viewOffice.htm", it looks impossible to get a "block type" for the employees.

<article id="department_[office.#;block=article;sub1=(office.getEmployeeNames())]">
  <h3>[office.title]</h3>
  <ul>
    <li class="employee">
      <small>
        [office_sub1;block=begin;bmagnet=li;when [office_sub1.#]!=1], [office_sub1;block=end]<a href="#"><span itemprop="eventType">[office_sub1.val;block=a]</span></a>
      </small>
    </li>
  </ul>
</article>

All we get is a "Field type" data where we can use ";ope=list", which is not what we're looking for: it should behave as a block.
Anybody could tell us what we're missing?

Thanks in advance!
By: Skrol29
Date: 2011-05-16
Time: 00:42

Re: blocks, fields and object oriented programmation

Hello,

parameter "sub1" accepts only column's names, not PHP expressions.
But you can create new columns on the fly (i.e. during the mergin process) at the PHP side, using parameter "ondata".