How to use link_to_items_with_item_type() function

I'm using the following to link to items with the type "Finding Aid"

<?php echo link_to_items_with_item_type('View Finding Aids',array('class'=>'finding-aid'),'browse','Finding Aid');?>

I think this jives with the documentation, but it's not working as expected.

Regardless of which item type I choose, it returns a link with no query parameters at the end, eg: http://example.com/items/browse?

Any ideas?

The final argument there is supposed to be an ItemType object, not a string.

The easiest thing to do is probably to use get_record_by_id to pull that specific ItemType by its ID number and pass that.

How else can I get an item type object using only its name?

I'd like this link to be non-site-specific. I know the ID of the item type, but that can change (for example, at the moment, I have a live and a test environment where the id is different on each site).

I think then your only option is using the table model directly:

$type = get_db()->getTable('ItemType')->findByName('Finding Aid');

Ok, thanks!

For anyone who's interested, here's a little helper function:

function link_to_item_type_by_name($linkText="View All",$props=array(),$typeName){
	$type = get_db()->getTable('ItemType')->findByName($typeName);
	return link_to_items_with_item_type($linkText,$props,'browse',$type);
}

usage: link_to_item_type_by_name('View Finding Aids',array('class'=>'finding-aid'),'Finding Aid')