Support » Plugin: Dropdown multisite selector » Display selected title

  • Resolved laima

    (@laima)


    Hi!

    First of all: I love this plugin!

    Is there a way to display the selected title on the widget? What i mean is: If i select a title/link from dropdown, i want this title to be displayed on the selection field. > the “Select site”, “Select Option” text should change to the selected title/link.

    Is this possible? Or could you develop this as a freelance job?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Al

    (@alordiel)

    Hi!

    Thank you for your interest.

    Yes, It is possible. I can add this as an option in the plugin’s admin panel.
    But what is you current setting for the option of select, I mean do you have the “site name -> link” pairs or you are using the automatically generated list of all sites from WordPress Multisite network?

    Hi!

    Thank You!

    Yes i would appreciate it, if you could add this as an option in the admin panel of your plugin. Tell me how we can start with that.

    Attached are screenshots of my current setting.

    screenshot 1

    screenshot 2

    Best,

    Plugin Author Al

    (@alordiel)

    Hi,

    Sorry for the late answer. I’m a bit of overloaded at the moment but will give a try to add the option tomorrow. Can you pass me a link of your site so I can check how the dropdown is working.

    Thanks and regards,
    Al

    Hi,

    thank you very much! Here is the link: http://www.rosendahlnextrom.com/battery-machines/contact/

    Plugin Author Al

    (@alordiel)

    Hello, there,

    I had a look at your site and what was thinking that will work – won’t.
    As your options fields have different names but some times shares the same value (url) I can’t find which was the selected on in the back end so I have to do this in the front end.

    I have wrote a small piece of javascript and have test it on your site and it works well, but as this is quite a custom thing I can’t implement it in my plugin and I don’t recommend to paste it there as well as I might update the plugin and this changes will be lost. So what i advise is to add the piece of code in you theme’s js file (something like custom.js or frontedn.js).

    Here is the code itself:

    
    (function($){
    
    	var currentUrl 	= window.location.href;
    	var lastUrl 	= sessionStorage.getItem('last-option-url');
    	var lastCountry = sessionStorage.getItem('last-option-name');
    	
    	console.log(lastCountry);
    	console.log(lastUrl);
    
    	if (lastUrl !== null && lastCountry !== null && lastUrl == currentUrl) {
    
    		//select the option by name of the country
    		$('.dms-select option:contains("'+lastCountry+'")').prop('selected','selected');
    		sessionStorage.removeItem('last-option-name');
    		sessionStorage.removeItem('last-option-url');
    	}
    
    	$(".dms-select").on('change', function(){
    
    		var name = $('option:selected', this).text();
    		var url  = $(this).val() ;
    
    		//store the data in session so we can check the selected option after the redirect
    		sessionStorage.setItem('last-option-name', name);
    		sessionStorage.setItem('last-option-url', url);
    	})
    
    })(jQuery);
    

    Please do let me know when you get it on your page and is it working correctly,
    Cheers,
    Al

    YES!!! That works! Thank you very much! You are the best!

    Hi again!

    Just detected that your solution does not work for some “Selections” (Links).
    e.g. if you select “Bulgaria” or “Indonesia” on this site: http://www.rosendahlnextrom.com/cable-wire/contact/contactus/ the title changes to “Select Country”.

    Almost all other selections (countries) work. Maybe you can take a look at that?

    Best,

    Plugin Author Al

    (@alordiel)

    Hi!

    Sorry for the late response.

    I saw that the problem comes from the plugin itself. If you have added an url with white space in front of the link like ” http://duckduckgo.com” it will cause a problem when comparing the url from the select and the actual one. Any way here is a fix:

    
    (function($){
    
    	var currentUrl 	= window.location.href;
    	var lastUrl 	= sessionStorage.getItem('last-option-url');
    	var lastCountry = sessionStorage.getItem('last-option-name');
    	
    	if (lastUrl !== null && lastCountry !== null && lastUrl.trim() == currentUrl) {
    
    		//select the option by name of the country
    		$('.dms-select option:contains("'+lastCountry+'")').prop('selected','selected');
    		sessionStorage.removeItem('last-option-name');
    		sessionStorage.removeItem('last-option-url');
    	}
    
    	$(".dms-select").on('change', function(){
    
    		var name = $('option:selected', this).text();
    		var url  = $(this).val() ;
    
    		//store the data in session so we can check the selected option after the redirect
    		sessionStorage.setItem('last-option-name', name);
    		sessionStorage.setItem('last-option-url', url);
    	})
    
    })(jQuery);

    Please delete the previous code and use this one. Also I will update soon the plugin with option to clear all white spaces from the urls.

    Let me know if there is still a problem.

    Regards.
    Al

    It worked!

    Thank you so much!!!

    Best Regards,

    Hi there

    I need to do this too, however I have tried adding the code above to my custom.js and it doesn’t work for me. I don’t know if it matters that I am not using a multi site install. I have 6 separate sites residing on subdomains as listed below:

    http://edmi-meters.co.za
    http://americas.edmi-meters.co.za
    http://asia.edmi-meters.co.za
    http://australasia.edmi-meters.co.za
    http://europe.edmi-meters.co.za
    http://mea.edmi-meters.co.za

    Below is a screenshot of my options

    Screenshot of options

    Could you help me with the code to achieve this on my sites?

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Display selected title’ is closed to new replies.