View All Items button in parent vs child collections

Our project uses the collection tree plug-in to organize the collections, but the parent collection does not actually contain items. I would like to remove the View All Items button from the display page: http://digitalvermont.org/collections/show/11

However, I need to keep the View All Items button on the child collection pages: http://digitalvermont.org/collections/show/9

I’m not sure this can be done but if anyone knows differently, would love to find out. Thanks!

You should be able to do this by editing your theme.

The default emiglio theme already won’t show the “view” link if there are no items in the collection. It looks like your View All Items may be a customization of the theme, so you probably can just apply the same if check to the part that prints that link:

<?php if (count($collectionItems) > 0): ?>
<!-- your View All Items link code -->
<?php endif; ?>

(Make sure it appears below the line that first mentions $collectionItems.)

I’ll give this a try, thanks so much for the help!

Gave this a try and it deleted all of the View All Items buttons, even for collections that have items. Any other hints you might have?

Thanks.

Can you show your whole collections/browse code? (After you paste it in, select it all and click the </> in the editor to make it display readably.) The problem here is probably something small in the way of naming or organization of what’s on the page.

<?php 
$pageTitle = __('Browse Collections');
echo head(array('title'=>$pageTitle,'bodyclass' => 'collections browse')); 
?>

<div id="primary">
    <h1><?php echo $pageTitle; ?> <?php echo __('(%s total)', $total_results); ?></h1>
    <?php echo pagination_links(); ?>
    
    <?php
    $sortLinks[__('Title')] = 'Dublin Core,Title';
    $sortLinks[__('Date Added')] = 'added';
    ?>

    <div id="sort-links">
        <span class="sort-label"><?php echo __('Sort by: '); ?></span><?php echo browse_sort_links($sortLinks); ?>
    </div>

    <?php if (total_records('collection') > 0): ?>
    <?php foreach (loop('collection') as $collection): ?>
        <div class="collection">
            <h2><?php echo link_to_collection(); ?></h2>
            <?php if ($collectionImage = record_image('collection', 'square_thumbnail')): ?>
                <?php echo link_to_collection($collectionImage, array('class' => 'image')); ?>
            <?php endif; ?>

            <?php if (metadata('collection', array('Dublin Core', 'Description'))): ?>
            <div class="collection-description">
                <?php echo text_to_paragraphs(metadata('collection', array('Dublin Core', 'Description'), array('snippet'=>150))); ?>
            </div>
            <?php endif; ?>
        
            <?php if ($collection->hasContributor()): ?>
            <div class="collection-contributors">
                <p>
                <strong><?php echo __('Contributors'); ?>:</strong>
                <?php echo metadata('collection', array('Dublin Core', 'Contributor'), array('all'=>true, 'delimiter'=>', ')); ?>
                </p>
            </div>
            <?php endif; ?>

            <p class="view-items-link"><?php echo link_to_items_browse(__('View the items in %s', metadata($collection, array('Dublin Core', 'Title'))), array('collection' => $collection->id)); ?></p>
    
            <?php echo fire_plugin_hook('public_collections_browse_each', array('view' => $this, 'collection' => $collection)); ?>
    
        </div><!-- end class="collection" -->

    <?php endforeach; ?>

    <?php echo pagination_links(); ?>
  
    <?php else: ?>
      <p><?php echo __('There are no collections.'); ?></p>
    <?php endif; ?>
    
    <?php echo fire_plugin_hook('public_collections_browse', array('collections'=>$collections, 'view' => $this)); ?>
</div><!-- end primary -->
<div id="secondary">
    <div id="featured-collection" class="featured">
        <h2><?php echo __('Featured Collection'); ?></h2>
        <?php echo random_featured_collection(); ?>
    </div><!-- end featured collection -->
</div>
<?php echo foot(); ?>

WAIT, sorry, use this code, it has a tiny change in it from the original code which is the above. Thanks!

<?php 
$pageTitle = __('Browse Collections');
echo head(array('title'=>$pageTitle,'bodyclass' => 'collections browse')); 
?>

<div id="primary">
    <h1><?php echo $pageTitle; ?> <?php echo __('(%s total)', $total_results); ?></h1>
    <?php echo pagination_links(); ?>
    
    <?php
    $sortLinks[__('Title')] = 'Dublin Core,Title';
    $sortLinks[__('Date Added')] = 'added';
    ?>

    <div id="sort-links">
        <span class="sort-label"><?php echo __('Sort by: '); ?></span><?php echo browse_sort_links($sortLinks); ?>
    </div>

    <?php if (total_records('collection') > 0): ?>
    <?php foreach (loop('collection') as $collection): ?>
        <div class="collection">
            <h2><?php echo link_to_collection(); ?></h2>
            <?php if ($collectionImage = record_image('collection', 'square_thumbnail')): ?>
                <?php echo link_to_collection($collectionImage, array('class' => 'image')); ?>
            <?php endif; ?>

            <?php if (metadata('collection', array('Dublin Core', 'Description'))): ?>
            <div class="collection-description">
                <?php echo text_to_paragraphs(metadata('collection', array('Dublin Core', 'Description'), array('snippet'=>150))); ?>
            </div>
            <?php endif; ?>
        
            <?php if ($collection->hasContributor()): ?>
            <div class="collection-contributors">
                <p>
                <strong><?php echo __('Contributors'); ?>:</strong>
                <?php echo metadata('collection', array('Dublin Core', 'Contributor'), array('all'=>true, 'delimiter'=>', ')); ?>
                </p>
            </div>
            <?php endif; ?>

          
    
            <?php echo fire_plugin_hook('public_collections_browse_each', array('view' => $this, 'collection' => $collection)); ?>
    
        </div><!-- end class="collection" -->

    <?php endforeach; ?>

    <?php echo pagination_links(); ?>
  
    <?php else: ?>
      <p><?php echo __('There are no collections.'); ?></p>
    <?php endif; ?>
    
    <?php echo fire_plugin_hook('public_collections_browse', array('collections'=>$collections, 'view' => $this)); ?>
</div><!-- end primary -->
<div id="secondary">
    <div id="featured-collection" class="featured">
        <h2><?php echo __('Featured Collection'); ?></h2>
        <?php echo random_featured_collection(); ?>
    </div><!-- end featured collection -->
</div>
<?php echo foot(); ?>

It looks like you posted your collections browse code, but we were talking about the show.


<?php
$collectionId = $collection->id;
echo head(array('title'=>metadata('collection', array('Dublin Core', 'Title')), 'bodyclass' => 'collections show')); ?>

<h1><?php echo metadata('collection', array('Dublin Core', 'Title')); ?></h1>
<div id="primary" class="show">
    <?php if ($collectionDescription = metadata('collection', array('Dublin Core', 'Description'))): ?>
    <div id="description" class="element">
        <h2><?php echo __('Description'); ?></h2>
        <div class="element-text"><?php echo $collectionDescription; ?></div>
    </div><!-- end description -->
    <?php endif; ?>
    <?php if (metadata('collection', array('Dublin Core', 'Contributor'))): ?>
    <div id="collectors" class="element">
        <h2><?php echo __('Contributor(s)'); ?></h2>
        <div class="element-text">
            <ul>
                <li><?php echo metadata('collection', array('Dublin Core', 'Contributor'), array('delimiter'=>'</li><li>')); ?></li>
            </ul>
        </div>
    </div><!-- end collectors -->
    <?php endif; ?>
    <?php echo fire_plugin_hook('public_collections_show', array('view' => $this, 'collection' => $collection)); ?>
</div>
<div id="secondary">
    <div id="collection-items">
		<div class="collection-button-link"><h3><p class="button-link"><?php echo link_to_items_browse(__('View All Items'), array('collection' => $collectionId)); ?></p></h3></div>
        <?php $collectionItems = get_records('item', array('collection' => $collectionId), 3); ?>
        <?php foreach (loop('items', $collectionItems) as $item): ?>

            <h3><?php echo link_to_item(metadata($item, array('Dublin Core', 'Title')), array('class'=>'permalink'), 'show', $item); ?></h3>

            <?php if (metadata($item, 'has thumbnail')): ?>
            <div class="item-img">
                <?php echo link_to_item(item_image('square_thumbnail', array('alt'=>metadata($item,array('Dublin Core', 'Title'))))); ?>
            </div>
            <?php endif; ?>

            <?php if ($text = metadata($item, array('Item Type Metadata', 'Text'), array('snippet'=>250))): ?>
                <div class="item-description">
                <p><?php echo $text; ?></p>
                </div>
            <?php elseif ($description = metadata($item, array('Dublin Core', 'Description'), array('snippet'=>250))): ?>
                <div class="item-description">
                <?php echo $description; ?>
                </div>
            <?php endif; ?>
    <?php endforeach; ?>
    </div><!-- end collection-items -->
    <?php if (count($collectionItems) > 0): ?>
      <?php endif; ?>
</div>
<?php echo foot(); ?>

So, I think the problem is just one of order. Your “View All Items” link is above the line that defines $collectionItems. So, if you just replaced it in place without moving things around, it wouldn’t work.

The code in that area should look like this, with the $collectionItems line and the View All Items link swapped so the link comes second:

<?php $collectionItems = get_records('item', array('collection' => $collectionId), 3); ?>
<?php if (count($collectionItems) > 0): ?>
    <div class="collection-button-link"><h3><p class="button-link"><?php echo link_to_items_browse(__('View All Items'), array('collection' => $collectionId)); ?></p></h3></div>
<?php endif; ?>
<?php foreach (loop('items', $collectionItems) as $item): ?>
<!-- file continues unchanged -->

If you look at the bottom of the file you’ll actually see the same if construct already there: it’s the one from the default version of the file, which prints the link to all items at the bottom of the list. When your copy of the theme was edited to move and restyle that link, the if got left behind.

Woo Hoo! Fixed! Thanks again for all of your help.