Adding tag cloud to portion of simple page?

How can I add a tag cloud of all tags on the site to a div on a single Simple Page?

As far a I can tell there are no shortcodes, and the TinyMCE editor (rightly) strips out or comments out any php. I also can’t find individual simple pages in the file structure (just the common show.php / add.php / edit.php etc.). And

<?php echo tag_cloud($tags, 'items/browse'); ?>

in show.php returns a “No tags are available”–which is right if it’s only looking for tags associated with this simple page. When I try (from the old Omeka docs):

<?php
$tags = get_tags(array('sort' => 'alpha'), 20); 
echo tag_cloud($tags, uri('items/browse'));
?>

it breaks the entire page.

Hmm…that would make sense as a shortcode if it doesn’t actually work.

It sounds like you are digging into the theme files directly, though, so I’ll go with that approach.

$tags = $this->_helper->db->getTable('Tag')->findBy(array('type'=>'Item'));

might get the list of tags you want to put into

<?php echo tag_cloud($tags, 'items/browse'); ?>

if that’s all in the simple page show. Haven’t tested that, but it’s my best quick guess.

Correction: Digging up the db might not work the way I described above. get_db() is a general way to get the db, then getTable should work.

It worked! Using:

$tags = get_db()->getTable('Tag')->findBy(array('type'=>'Item'));

Now how would I get that to show up on just one of the Simple Pages? (I have a specific div I’m targeting).

You should be able to check the id of the simplepage object that gets passed to the page, and only show the div if it’s the one your want.

Wonderful! Thank you so much!

Thank you very much for this useful thread. i would like to ask, how can i sort and limit the number of the tags shown in cloud. lets say i would like the have 200 most popular tags in alphabetic order.

i tried something like:

<?php $tags = get_db()->getTable('Tag')->findBy(array('type'=>'Item'));?>
<?php $tags = array_diff($tags, array('some-tags-i-dont-want-to-show'));?>
<?php $tags = array('sort' => 'alpha'), 200); ?>

 <?php echo tag_cloud($tags, 'items/browse'); ?>

but obviosly it doesnt work.

thank you very much.

This was extremely helpful, and enabled me to set up a tag list on my homepage! However, it only lists tags associated with items? How can I get it to include all tags on the site, including those in exhibits?

Also, is there a way to display the tags side by side, separated by commas, rather than as a bulleted list?