Invision Community 5: A video walkthrough creating a custom theme and homepage By Matt Thursday at 04:02 PM
EricT Posted December 14, 2016 Posted December 14, 2016 Hi I would like to add a dynamic link in the menu (using Menu Manager) to a member page (for example the member's profile page) Could anyone help me to do that ? (if it is possible) Thank you !
EricT Posted December 21, 2016 Author Posted December 21, 2016 4 minutes ago, opentype said: It isn’t possible. I think there is a solution, but I hope there is a better one : The link goes to a php page which get the id member and redirect to the member page : this should work, but not very sexy solution If there is not other solution, I will try to build this one
Nathan Explosion Posted December 22, 2016 Posted December 22, 2016 KLUDGE!!!!!!!!! Create your menu item - put whatever URL you want in there (maybe make a copy of the one that exists for /profile/id-?? already but remove the id bit? Or create one called myprofile? Your choice entirely) Publish the menu. Go to your set, view the page source and search for the new menu item you added. Note the data-navItem-id value Go back to the ACP, search for Google Analytics and open up the section for "Enable analytics tracking code" In the tracking code section put the code below in place, replacing XX with the value you noted in step 4, and then save the change. Back to the site, refresh and click the menu item you put in place. <script> $("a[data-navItem-id='XX']").click(function(e) { e.preventDefault(); window.location = 'profile/' + ips.getSetting('memberID') + '-a/'; }); </script> Note: if you do not have "Rewrite URLs" enabled in the ACP's friendly urls options then add index.php?/ before profile/ in the line for window.location
EricT Posted December 22, 2016 Author Posted December 22, 2016 Thank you ! Seems to be a very good solution I am going to test it
EricT Posted December 22, 2016 Author Posted December 22, 2016 I am impressed by the solution It is working very fine. I only one question : google analytics will still working ? Now I have this on the Google Analytics tracking code area on ACP : Quote <script> $("a[data-navItem-id='52']").click(function(e) { e.preventDefault(); window.location = '../profile/' + ips.getSetting('memberID') + '-a/content/?type=classifieds_advert'; }); (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-xxxxxxxxx', 'auto'); ga('send', 'pageview'); </script> Is there another place I could add your code ? Thank you very much !
Nathan Explosion Posted December 22, 2016 Posted December 22, 2016 Google analytics will not stop working, unless you break the code.....but test it to make sure it is still working Any amount of javascript code can go in that section. You can put the code wherever you want in your themes though too - all up to you. Putting it in the analytics section is just convenient as you don't have to edit a theme there...you could make a plugin, if you wanted, to achieve the same thing.
Jaymez Posted January 23, 2017 Posted January 23, 2017 This is great. Is there a solution for dropdown menu items?
Adriano Faria Posted January 29, 2017 Posted January 29, 2017 On 14/12/2016 at 5:51 PM, EricT said: I would like to add a dynamic link in the menu (using Menu Manager) to a member page (for example the member's profile page) A simple example using Pages app:
Recommended Posts
Archived
This topic is now archived and is closed to further replies.