[phpBB3] AJAX Userinfo Extension

Magic SEO URLs for phpBB.
Lord Phobos
Posts: 3
Joined: Sat Jan 26, 2019 4:29 pm

[phpBB3] AJAX Userinfo Extension

Postby Lord Phobos » Sat Feb 02, 2019 11:07 am

Hi!

I'm having trouble with this extension: https://www.phpbb.com/customise/db/exte ... _userinfo/

I tried asking support from the author but for no avail, since now.

My request for support describing the issue is at the following link: https://www.phpbb.com/customise/db/exte ... pic/201286

I'll paste it here for your convenience:

Hi

This extension worked nice for me so far, but now I've added this paid SEO extension, and it works nice as well.

But now, each username I hover with my mouse I get informations about "guest" user.
I think this is caused by the modified by SEO user links to profile?

In the FAQ of that SEO extension it says that for some extension I should add these lines:

Code: Select all

define('MSU_LOAD_LIB_ONLY_BB', true);
include('includes/magic_seo_url.php');


Code: Select all

msuTransformUrlBb( string $url )
function (transforms the given URL).

Image


But I really don't know where to add these lines.
Could you plz help me?


I think the problem is in the script file:

I should find a way to tell the script how to read the rewritten SEO url of the user profile link.
This is an example of such a link: https://www.anonimagiocatori.it/members/diego-67

Code: Select all

(function($) {
   'use strict';

   /* Set div to mouse */
   $(document).mousemove( function(e) {
      var docX, docY, posX, posY;
      var popup_height = $('#popup').height();

      docX = e.clientX + $(window).scrollLeft();
      docY = e.clientY + $(window).scrollTop();

      if (docX > $(window).width() - 400) {
         posX = (docX - 350);
      } else {
         posX = docX;
      }
      if (docY > ($(window).height() + $(window).scrollTop()) - popup_height - 40) {
         posY = (docY - (popup_height + 20));
      } else {
         posY = (docY + 30);
      }
      $('#popup').css({'top':posY,'left':posX});
   });

   var data = new Array();
   var show_popup = false;
   $('a.username-coloured, a.username').mouseover(
      function() {
         var id = getURLParameter(($(this).attr('href')), 'u');
         var url = userinfo_url.replace('USERID', id);
         show_popup = true;
         if(typeof data[id] === 'undefined') {
            $.get(url, function( responseText ) {
               data[id] = responseText;
               $.each(data[id], function(index, value){
                  $('#ajax_'+index).html(value);
               });
               if (show_popup) {
                  $( '#popup').show();
               }
            });
         } else {
            $.each(data[id], function(index, value){
               $('#ajax_'+index).html(value);
            });
            if (show_popup) {
               $( '#popup').show();
            }
         }
      }
   );
   $('a.username-coloured, a.username').mouseout(
      function(){
         show_popup = false;
         $('#popup').hide();
         $('#popup').find('span').each(function(){
            $(this).html('');
         });
      }
   );
})(jQuery);

function getURLParameter(url, name) {
    return (RegExp(name + '=' + '(.+?)(&|$)').exec(url)||[,null])[1];
}

inveo
Inveo Support
Posts: 1283
Joined: Sat Feb 02, 2008 12:07 pm
Contact:

Re: [phpBB3] AJAX Userinfo Extension

Postby inveo » Sat Feb 02, 2019 11:55 am

To resolve the issue you are having you may either:

1) edit your tpl file and replace double quotes with single quotes (i.e. " to '). Then MSU will keep the original URL.

OR

2) use the following getUserid() function instead of getURLParameter():

Code: Select all

function getUserid(url) {
    return (RegExp('-([0-9]+)').exec(url)||[,null])[1];
}

Lord Phobos
Posts: 3
Joined: Sat Jan 26, 2019 4:29 pm

Re: [phpBB3] AJAX Userinfo Extension

Postby Lord Phobos » Sun Feb 03, 2019 7:34 am

I tried your second solution, altering only the last part of that script file, from

Code: Select all

function getURLParameter(url, name) {
    return (RegExp(name + '=' + '(.+?)(&|$)').exec(url)||[,null])[1];
}


to

Code: Select all

function getUserid(url) {
    return (RegExp('-([0-9]+)').exec(url)||[,null])[1];
}


but this way the extension simply stopped working.

Maybe I should alter something else in that script file? But I don't know how.

As for the first one solution, what do you mean for a TPL file?

Thanks again.

inveo
Inveo Support
Posts: 1283
Joined: Sat Feb 02, 2008 12:07 pm
Contact:

Re: [phpBB3] AJAX Userinfo Extension

Postby inveo » Sun Feb 03, 2019 8:05 am

To use the solution no.2, you need to ADD:

Code: Select all

function getUserid(url) {
    return (RegExp('-([0-9]+)').exec(url)||[,null])[1];
}


and REPLACE:

Code: Select all

var id = getURLParameter(($(this).attr('href')), 'u');


with:

Code: Select all

var id = getUserid(($(this).attr('href')));


in /tas2580/userinfo/styles/all/template/script.js file and you are done.

Lord Phobos
Posts: 3
Joined: Sat Jan 26, 2019 4:29 pm

Re: [phpBB3] AJAX Userinfo Extension

Postby Lord Phobos » Sun Feb 03, 2019 8:10 am

Now it works perfectly, many thanks!!