User Tools

Site Tools


phplugins_limit_the_number_of_selected_images_in_crg

The purpose of this modification is to put an upper limit on the number of images which may be selected in a Client Response Gallery. For example, you may publish a gallery of 100 images from which the client is able to select no more than 10 images.

When the select counter reaches its ceiling, unselected images will be hidden from view. If the client then unselects images to bring the count below the specified ceiling, unselected images will return to view and the client may continue to browse.

I have created a demonstration page to show this modification in action.

To implement this mod, enable PHPlugins, then copy-and-paste the below function into your phplugins.php file. Edit the path and set a count ceiling as necessary.

function ttg_body_bottom( $style, $path ) { 
	if (G_PATH == 'LIMIT-SELECTS') { // set folder name of gallery in all CAPITAL LETTERS
	echo '
	<style>
	html.tallied .hs_checkbox input { display: none; }
	html.tallied .hs_checkbox input:checked { display: block; }
	</style>
	
	<script>
	function tallyCount() {
		checkedCount = $("#gallery input[type=checkbox]").filter("input:checked").length;
		if(checkedCount >= 5) { // set ceiling for select counter
			$("#gallery").removeClass("dim-elements");
			$("#gallery").addClass("hide-elements");
			$("a#lights-low, a#lights-off, a#lights-on").css("display", "none");
			$("html").addClass("tallied");
		} else {
			$("#gallery").removeClass("dim-elements");
			$("#gallery").removeClass("hide-elements");
			$("a#lights-low, a#lights-off, a#lights-on").css("display", "block");
			$("html").removeClass("tallied");
		}
	}
	$(function(){
		tallyCount();				
		$("#gallery input[type=checkbox]").click(function(e) {
			tallyCount();
		});
	});
	</script>
	';
	}
} // END

When creating your gallery, you should provide some visual aid to the client that there is a limit in effect on the gallery. For example, use the text “of 10 images” in your status bar:

phplugins_limit_the_number_of_selected_images_in_crg.txt · Last modified: 2013/04/12 05:22 by admin