On 18 Dec 2006, at 17:09, Scott Lanning wrote:
> What's returned by methods in Bricolage depends on
context.
> In list context, returns a list of objects. In scalar
context,
> returns an array reference.
I think the problem is exactly that. When bricolage returns
one Story
object from the search, I think it tries to call the list
method on
that rather than the TT list method on expected array. But
then I
could be wrong.
I found that creating my own array seemed to solve my
problems. E.g.
[% stories = story.list({...}) %]
[% storylist = [] %]
[% FOREACH item = stoties %]
[% storylist.push( item ) %]
[% END %]
So when I call the "list" or "size"
methods on "storylist" is works
consistently.
Go figure!?
Adeola.
>
> I don't know anything about Template Toolkit
> (other than it seems like an abomination of nature,
IMHO).
>
> On Mon, 18 Dec 2006, Adeola Awoyemi wrote:
>> Right,
>>
>> I created some content to play with. So "[%
related.size %]" returns:
>>
>> - with no related: 1
>> - with 1 related: undef error
>> - with 2 related: 2
>>
>> Something is definitely wrong here?!
>>
>> Adeola.
>>
>>
>> On 18 Dec 2006, at 14:58, Adeola Awoyemi wrote:
>>
>>> When I try the expected "[% related.size
%]" since related should
>>> be a list anyway, I get the error:
>>>
>>> "undef error - Bad AUTOLOAD method
format:
>>> Bric::Biz::Asset::Business::Story::size"
>>> Adeola.
>>> --
>>> Creative Developer - Digital Craftsmen Ltd
>>> Exmouth House, 3 Pine Street
>>> bond, EC1R 0JH
>>> t: 020 7183 1410
>>> f: 020 7099 5140
>>> m: +44 7939 520 786
>>> w: http://www.digitalcr
aftsmen.net/
>>> On 18 Dec 2006, at 14:53, Adeola Awoyemi wrote:
>>>> Also,
>>>> further down I'm iterating over related
"[% FOREACH item =
>>>> related %]" anf that seems to be OK.
>>>> On 18 Dec 2006, at 14:46, Adeola Awoyemi
wrote:
>>>>> Hi all,
>>>>> I am trying to get the size of an array
of stories like this:
>>>>> [% related = story.list({Order =>
'cover_date',
>>>>>
OrderDirection => 'DESC',
>>>>>
publish_status => 0,
>>>>>
related_story_id => story.get_id,
>>>>> }) %]
>>>>> [% related.list.size %]
>>>>> but this is not returning the expected
amount of related
>>>>> stories. Am I doing something wrong
here cause I'm baffled?!
>>>>> Thanks,
>>>>> Adeola.
|