Select client Envira galleries using a form

Hi, before i dive in to this i thought I would ask - in principle - if this might work?
I want to have a gallery page where a user can enter a gallery name, click ok and then the browser jumps to the url for that specific envira gallery ( I have all the galleries set as standalone with permalinks) I imagine i could do this with a form element, but i am going to need some funky logic in that form (php ?!) to jump to the url (and not if the entry does not exist) ?

Any advice would be great please.

Cheers

  • Charlie

Hi Charlie,

You can try with this code:

<form id="change_slug" method="GET">
	<input type="text" id="slug" name="slug" />
</form>

<script type="text/javascript">
	function convertToSlug(Text)
	{
	    return Text
	        .toLowerCase()
	        .replace(/[^\w ]+/g,'')
	        .replace(/ +/g,'-')
	        ;
	}
	jQuery(document).ready(function($) {
		$("#change_slug").on('submit', function(event) {
			event.preventDefault();
			var slug = $(this).find('input#slug').val();
			if(slug){
				window.location.href = document.location.origin + '/' + convertToSlug(slug);
			}
		});
	});
</script>

Please consider that you are talking about a custom development which is outside of our support scope. You need to hire a developer for this.

Thanks.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.