Optional DublinCore in Thanks Roy theme?


#1

We want to add a button of some type to hide/reveal the DublinCore metadata set on the public item page - the Itemtype metadata would still always be displayed if the fields had been filled. I have worked with items.php to display the files above the metadata, but haven’t been able to figure how I might work this out. I’m guessing since a button action would be involved I’d need to edit the javascript?

Any tips appreciated, thanks!


#2

Yeah, if you’re going to have a button on the page that performs some action you’re going to need to use some Javascript, pretty much.

I don’t think you’d really be “editing” any existing JS, just adding some of your own.


#3

The javascript to do this is pretty simple. Just add a button with the class “hide-show-meta”.

The html, body code just scrolls to the metadata instead of leaving you where you were when you pressed the button.

You can see this in action at https://www.indianadisabilityhistory.org/items/show/277#

			<!-- Items metadata -->
			<hr>
			<div class="all-metadata">
			    <?php echo all_element_texts('item'); ?>
			</div>		
			
			<script>
				jQuery('.all-metadata').hide();
				jQuery('.hide-show-meta').click(function(event){
					if (jQuery('span#toggle').text()=="Hide"){
						jQuery('span#toggle').text("Show");
						jQuery('.all-metadata').hide();
					}else{
						jQuery('span#toggle').text("Hide");
						jQuery('.all-metadata').show();

						 $('html, body').animate({
						    scrollTop: $('.all-metadata').offset().top}, 500);

					}
				});
			</script>

Will