List Info

Thread: Re: Too many Bric::Biz::Category objects found.




Re: Too many Bric::Biz::Category objects found.
user name
2007-09-17 11:36:31
On Sep 17, 2007, at 05:27, Matt Rolf wrote:

> Would it be useful to have the first call by default
look in the  
> site the template's being run in?

Yes. For what purpose are you trying to get the category?
Can you  
provide a bit more context (a snippet of your template
code)? That  
will help us figure out how to get you what you want (rather
than  
just provide information for how to make the error go
away).

Best,

David


Re: Too many Bric::Biz::Category objects found.
user name
2007-09-17 11:58:28
On Sep 17, 2007, at 12:36 PM, David E. Wheeler wrote:

> On Sep 17, 2007, at 05:27, Matt Rolf wrote:
>
>> Would it be useful to have the first call by
default look in the  
>> site the template's being run in?
>
> Yes. For what purpose are you trying to get the
category? Can you  
> provide a bit more context (a snippet of your template
code)? That  
> will help us figure out how to get you what you want
(rather than  
> just provide information for how to make the error go
away).


http://www.d
enison.edu/offices/computing

We build our search tool at the upper right using an array
of the  
category names.

Here's some more complete code from that template.  It is a
utility  
template that gets called after the body tag in the
autohandler.  The  
death occurs when we're finding the name of the secondary
category.

<!-- INCLUDE for top nav search - dont forget to use %2F
for slashes!  
-->
<%perl>

#build the subcat from the categories array
my $secondaryCat = '';
my $n = 0;
foreach (categories){
	unless($n < 2){
	$secondaryCat = $secondaryCat.$_.'/';
	}
	$n++;
}

#find the top cat
my $primaryCatTitle;
if($categories[1] eq ''){ $categories[1] = 'campuslife'; }
my cat1 = list Bric::Biz::Category({ uri =>
'/'.$categories[1].'/' });

my $secondaryCatTitle;

#find the name of the secondary Cat if we have one.
if($secondaryCat){

	my $cat2 = Bric::Biz::Category->lookup({ uri =>
'/'.$categories 
[1].'/'.$secondaryCat });
	
	if( $cat2 ){ $secondaryCatTitle = $cat2->get_name;
	} else { $secondaryCatTitle = '' }
	
	#replace spaces with %2F for php and add beginning /
	$secondaryCat =~ s|/|%2F|g;
#	$secondaryCat = '/'.$secondaryCat;
	
}

#print search include with variables
if ($storyType eq "php_story") {
	
	print '	<?php
	$primaryCat = "',$categories[1],'";
	$primaryCatTitle = "',$cat1[0]->get_name,'";
	$secondaryCat = "',$secondaryCat,'";
	$secondaryCatTitle = "',$secondaryCatTitle,'";
	require_once('includes/navigation/searchbar.php');
	?>';
	
} else {
		
	print '<!--#include
virtual="/includes/navigation/searchbar.php? 
primaryCat=%2F', $categories[1],'%2F&primaryCatTitle=',
$cat1[0]- 
 >get_name,'&secondaryCat=',
$secondaryCat,'&secondaryCatTitle=',  
$secondaryCatTitle,'"-->';		
	
}

</%perl>




[1-2]

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