Activate specific TAB when entering page from external link

3 replies · opened Oct 2, 2019

TTuckerComstockOct 2, 2019

Hi, and thank you for al the help you provide us!

I am using portfolio-3 to create a travel site. I would like to link from other pages to specific TABS in the PORTFOLIO-FILTER. I added id="icons" id="uielements", etc. to the <li> for the tabs, and in the page linking to the page I added #icons and #uielements etc.

I have modified the PORTFOLIO-3 to include the id= anchors, and uploaded it:

http://ser2019.serendipitycostarica.com/portfolio-3-sampleIndex.php#uielements

The landing anchor did not work.

Can you find a way to (1) reach a specific landing tab and (2) change tab to show it as the active tab (in your sample, make it blue background/white letters)

SSemicolon WebSTAFFOct 4, 2019

Hello,

This is Definitely Possible! Simply add the following JS Code at the bottom of the Portfolio Page after the js/functions.js JS File Linking:


	jQuery(window).on( 'load', function(){

		var $container = $('#portfolio');

		function getHashFilter() {
			var hash = location.hash;
			// get filter=filterName
			var matches = location.hash.match( /filter=([^&]+)/i );
			var hashFilter = matches && matches[1];
			return hashFilter && decodeURIComponent( hashFilter );
		}

		var isIsotopeInit = false;

		function onHashchange() {
			var hashFilter = getHashFilter();
			if ( !hashFilter && isIsotopeInit ) {
				return;
			}
			isIsotopeInit = true;
			// filter isotope
			$container.isotope({ filter: hashFilter });
			// set selected class on button
			if ( hashFilter ) {
				$('.portfolio-filter li').removeClass('activeFilter');
				$('.portfolio-filter li').find('[data-filter="' + hashFilter + '"]').parent('li').addClass('activeFilter');
			}
		}

		$(window).on( 'hashchange', onHashchange );
		// trigger event handler to init Isotope
		onHashchange();

		$('.portfolio-filter a').click(function(){
			var filterAttr = $( this ).attr('data-filter');
			location.hash = 'filter=' + encodeURIComponent( filterAttr );
			setTimeout(function(){
				$( '.flexslider .slide' ).trigger( 'resize' );
			}, 1500);
			return false;
		});

	});

and then use portfolio.html#filter=.pf-graphics as Links.

This will definitely work fine. Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

TTuckerComstockOct 5, 2019

IT WORKED IT WORKED IT WORKED IT WORKED! Thanks again.

SSemicolon WebSTAFFOct 5, 2019

Hello,

Really Glad that your issues were resolved. Thanks for your Patience.

Do let us know if we can help you with anything else or if you find any further issues with Canvas.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard