Theme Problem with show.php

Hello there, and please forgive me for being a complete and utter newbie with Omeka. I'm afraid I've only used it for two days, and I'm having a little issue I can't solve.

The problem is that we need to have a "recent items" list in a sidebar, and I've got some code (which I've put into the header.php file) that appears to work correctly for generating the list.

Unfortunately, though, that code also prevents the show.php from working properly. What happens is that items with the URL /items/show/2 show the correct information in the page header and in the citation, but all the rest of the information comes from the first item (/items/show/1). If I take that code out of the header.php file the show.php files work correctly. I hope that makes sense ...

The code I was using is reproduced below. If anyone can give me a little insight into what the problem might be, I'd much appreciate it.

I'me developing my own custom theme, by the way, but at the moment the only template files I've modified have been header.php and footer.php,as well as the main CSS file. The show.php file is unchanged from the default template.

Thanks in advance for any help people may be able to give.

<!-- Recent Items -->
				<div id="recent-items">
					<h2>Recently Added Items</h2>

					<?php set_items_for_loop(recent_items(10)); ?>
					<?php if (has_items_for_loop()): ?>
						<ul>
							<?php while (loop_items()): ?>
								<li><?php echo link_to_item(); ?></li>
							<?php endwhile; ?>
						</ul>
					<?php else: ?>
						<p>No recent items available.</p>
					<?php endif; ?>
				</div><!-- end recent-items -->

Have you looked at the Emiglio theme? It offers an example of how to handle a side bar issue. It has a type of sidebar that is a secondary content div, defined in the CSS, and then calls/displays different information on items/show.php and items/browse.php. You can tell it to display the recently added items there in that secondary div.

Sheila

Hey AndrewMac,

If I am correct, you are putting your code above into the header.php file, and when you goto view specific items, the item metadata is incorrect. I think the reason is that the helper functions rely a current item variable, which gets changed by your recent items code.

So replace your code with this code:

<!-- Recent Items -->
			<div id="recent-items">
				<h2>Recently Added Items</h2>
                <?php $currentItem = get_current_item(); ?>
				<?php set_items_for_loop(recent_items(10)); ?>
				<?php if (has_items_for_loop()): ?>
					<ul>
						<?php while (loop_items()): ?>
							<li><?php echo link_to_item(); ?></li>
						<?php endwhile; ?>
					</ul>
				<?php else: ?>
					<p>No recent items available.</p>
				<?php endif; ?>
				<?php set_current_item($currentItem); ?>
			</div><!-- end recent-items -->

Notice how I am temporarily storing the current item and then after the featured item code is done, I reset the current item to what it originally was.

So just put this code in your header.php and let me know if this works.