Displaying metadata of parent vs. child collections

I’ve managed to hack my theme’s items/show page to customize the metadata display, but I’m struggling with how to display info for the parent vs. info for the child collection (I’m using the CollectionTree plugin). Example: http://michaelsand.com/archives/items/show/1244

What I want:

  • In the “Client” field: IF this collection has a parent collection, display the parent collection’s title, ELSE display this collection’s title.
  • In the “Project” field: Display this collection’s title.

Current code displays this collection’s title in both the “Client” and “Project” fields:

<!-- Display Parent Collection (Client) metadata -->

    <?php if (metadata('item', 'Collection Name')): ?>
        <div id="collection" class="element">
            <h3><?php echo __('Client'); ?></h3>
            <div class="element-text"><p>
                <?php if 
                    echo link_to_collection_for_item(); 
                ?></p>
            </div>
        </div>
    <?php endif; ?>


<!-- Display Collection (Project) metadata -->

    <?php if (metadata('item', 'Collection Name')): ?>
        <div id="collection" class="element">
            <h3><?php echo __('Project'); ?></h3>
            <div class="element-text"><p>
                <?php echo link_to_collection_for_item(); ?></p>
            </div>
        </div>
    <?php endif; ?>

Not only am I struggling with understanding CollectionTree’s architecture, I’m also brand new to php. It’s pretty clear I need to replace <?php echo link_to_collection_for_item(); ?> with an if/else statement, but I don’t know how to structure that and my days of trial-and-error have yielded nothing.

Any idea how to call CollectionTree’s parent-level title?

Thanks!!
J.

This topic was automatically closed after 250 days. New replies are no longer allowed.