Categories > TinyButStrong general >

splittergrp and

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: ege
Date: 2007-11-13
Time: 14:37

splittergrp and

Hi there,

I have recently started using TBS, and I do like using it. I have actually made 2 sites employing it, they'll be online soon. However, probably because I'm quite a newbie I couldn't get splittergrp working. I need php's implode() kind of functionality with links, using | as the glue. I reviewed what has been written about the issue and http://www.tinybutstrong.com/forum.php?msg_id=3449#msg_3449 is actually what I have been trying to achieve.

My code is as follows (taken & modified from various forum topics):
<a href='?a=[subMenuPages.url]'> [subMenuPages.name] </a>      [subMenuPages;block=begin;splittergrp=url] | [subMenuPages;block=end]

where subMenuPages is an array filled with custom objects. When I MergeBlock I get the following page:
Fatal error: Cannot use object of type _ContentPage as array in C:\wamp\www\karuna\tbs_class.php on line 1641.

I'm using the php5 version of TBS.  Any help will be appreciated.

Also, I have been thinking (I actually need that feature) that it would be really useful if unset variables could be treated as empty ones. That is to say, if $nowhereDeclared variable is not declared anywhere the following code could generete "hello world", instead of throwing an error:

hello <div>[var.nowhereDeclared;magnet=div] ugly</div> world

That kind of a functionality would be more true to the soul of php where undeclared variables are normally treated as null or "". It would also result in less coding on the php side. Is there any way of achieving this functionality?

Sorry if these are covered in manuals or in other posts, as I said I'm just a new TBS user.
Thanks in advance.
By: ege
Date: 2007-11-13
Time: 14:44

Re: splittergrp and

`edit`:

I also forgot that there is that ;block=a parameter in the first [] part.
By: Skrol29
Date: 2007-11-13
Time: 19:36

Re: splittergrp and

Hi Ege,

The problem does not come from the template. It seems that you are merging data which are not a really true array, or it is an array which not not contains sub arrays but objects.

You can treat unset variables like empty variables using parameter "noerr". There is also a property for the TBS objects which make it available for all Var fields.
By: ege
Date: 2007-11-14
Time: 10:06

Re: splittergrp and

Hello,

Yes, I was merging data which aren't array. I mean subMenuPages is an array but what it contains is not sub arrays but objects that have fields 'url' and 'name'. When I tried it using
$subMenuPages=array(array('url'=>url1.com','name'=>'url1'),array('url'=>'url2.com','name'=>'url2'));

it worked. However, when I use normal group merging (without splittergroup) it works with objects as well. Making it work also with objects instead of arrays is very handy, and I strongly suggest implementing it as it would also be more coherent with the rest of the api.

As for the NoErr, it solved the unset variable issue. But it is kind of an overkill, that is, it also supresses other errors. It would be nice if it was possible to set an option to change the engine's default behaviour on undeclared variables without setting NoErr.

Thank you very much.
By: Skrol29
Date: 2007-11-15
Time: 11:05

Re: splittergrp and

Hi Ege,

You're right, merging works with records which are objects, but grouping (headergrp, footergrp, splittergrp) doesn't work with objects. I'll try to fix that in the current beta version.

But I don't agree so much that the noerr is an overkill to avoid unset variables. Even if PHP has a mode for not noticing unset variables in the script, I thing is is note such a good idea to have the same usage at the template side. If you do need it, the "noerr" parameter on a field is stopping quite only message about not existing variables or properties. The NoErr property is much more for web page that should not displaying any error at all.
By: ege
Date: 2007-11-15
Time: 17:07

Re: splittergrp and

Hi,

Can you explain what you mean by" If you do need it, the "noerr" parameter on a field is stopping quite only message about not existing variables or properties." Does that mean I can use it like
[var.undeclared;noerr]
? If it is the case, it's perfectly acceptable to me. Are there 2 noerrs, one of them being NoErr property of the class and one noerr parameter to be written in []?
By: Skrol29
Date: 2007-11-15
Time: 17:14

Re: splittergrp and

> Does that mean I can use it like [var.undeclared;noerr]

Absolutely.

> Are there 2 noerrs, one of them being NoErr
> property of the class and one noerr parameter to be written in []?

Absolutely.
By: ege
Date: 2007-11-15
Time: 17:14

Re: splittergrp and

Aaah, sorry of course there is 2, you told me that twice but for some reason I insisted on thinking of them as they are the same thing. Ok, thanks again.