List Info

Thread: solved: how to get a category object using the category uri




solved: how to get a category object using the category uri
user name
2006-10-27 07:12:36
Nevermind - it seems this works:

my ($category) = Bric::Biz::Category->list({ uri =>
$category_uri });

I found the reference in the http://bricolage
.cc/templates/story/ 
publish_daily_archive.mc  template.

The brackets around the word ($category) seem to make it
work.

Ah perl- I still have so much to learn about you!

Dawn

On 26-Oct-06, at 10:41 PM, Dawn Buie wrote:

> HI - I might be missing something obvious but- I can't
figure out  
> how to obtain a category object using a uri.
> I want to create an archive page that prints out all
stories for  
> that day but with the stories clustered into their
categories.
>
> I have an array of category uris I will be using:
>
> my category_uris = ('/News/', '/Views/',
'/Entertainment/');
>
> and I know how I can get the stories for each category
using  the   
> Bric::Biz::Story->list method. However I also want
to print of the  
> names of the categories above the clustered stories and
can't seem  
> to find a method similar to story list that will give
me a category  
> object so I can do something like
>
>    <% $category->get_name; %>
>
> I have tried:
>
>   my $category = Bric::Biz::Category->lookup({ uri
=> '/News/' });
>
> I get the error:
>
>    Too many Bric::Biz::Category objects found.
>
> I then tried:
>
>    my $category = Bric::Biz::Category->list({uri
=> '/News/',  
> active => 1,});
>    print $category->get_name;
>
> But the $category->get_name causes the next error:
>
>    Can't call method "get_name" on unblessed
reference
>
> So I'm obviously missing something important about how
categories  
> are referenced. Could someone enlighten me?
>
> Thank you-
> Dawn
>
>
>
>
>
>
>
>
>

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )