The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Ego search widget

View previous topic View next topic Go down

Completed Ego search widget

Post by Kestrana on April 7th 2013, 9:00 pm

I'm attempting to turn the egosearch page into a widget that can be used as a sort of "Recent Topics" widget. It's coming along, but I'm not a javascript guru, so when something doesn't work the way I think it should, I'm not very good at debugging it.

The concept is based off of this tutorial: http://www.avacweb.com/t805-19-multiple-news-widgets-from-different-forums

In this widget, an RSS feed is used to collect the data to be used in the widget. So I used feed43.com and created an RSS feed for the egosearch page for one of my users, the idea being to use this RSS feed to grab the data I want to use in the widget. When I try to use $.get to retrieve the feed, though, nothing happens. Right now, I'm just trying to get this to work for a single user; ultimately, I'll create an array of usernames and their associated RSS feeds so that each user can see their own egosearch widget feed.

In the code below, the debug I've added displays up through the red "Kes Debug" text. The blue debug text does not display, which seems to indicate that the $.get function isn't working as expected.

Anyone know javascript enough better than I do to help me out?

I am continuing to futz with the script on my own, so the code below is what I *think* is supposed to be working, based on the tutorial above. Since I'm messing with it, though, the behavior on my site may change at any time. If you need to see it in action on my site, please post here or PM me so I can restore the original for you. This is all "standalone" (doesn't have to be added to templates or anything, it's just a javascript and a portal widget), so you're welcome to copy it to your own site to mess with it if you'd like.

Page where the widget displays (bottom of right-most column, under header "Your Recent Topics"): http://reverie.forumotion.net/

My javascript (located in the Javascript codes management module):
Code:
$(function(){
              ('Create Multiple News Widgets for Forumotion. Copyright (c) AvacWeb 2013. No distribution without consent. No use or modification without this entire copyright notice in the original or modified script.');
           
              var forums = [3]; // add your forum IDs here
              var limit = 10; // choose how many recent topics to display here.
           
    var feed = 'http://feed43.com/6103814738067657.xml';

    var debug = "<b>feed=</b>" + feed;

              var text = function(cont, tag) {
                  tag = cont.getElementsByTagName(tag)[0];
                  return (tag && tag.firstChild && tag.firstChild.nodeValue) || '';
              };
              for(var j = 0, f; (f = forums[j++]); ) {
                  var holder = document.getElementById('LGnews_' + f);
                  if(!holder) continue;
    debug += "<br /><b style='color: red;'><u>Kes Debug</u></b>";
                  $.get('http://feed43.com/6103814738067657.xml', function(xml) {
    debug += "<br /><b style='color: blue;'><u>Kes Debug</u></b>";
                    var forum_title = text(xml, 'title'), topics = xml.getElementsByTagName('item'), i = 0, t = null;
                 
        var html = '<div class="inner_news">';
            html += '<div class="news_topics">';
                    for(; (t = topics[i++]); ) {
                        var topic_title = text(t, 'title'), preview = text(t, 'description'), link = text(t, 'link'), time = text(t, 'pubDate');

    var time_formatted = dateFormat(time, "ddd, mmm d yyyy H:MM Z");

                        var author = t.getElementsByTagName('guid')[0].nextSibling.firstChild.nodeValue;
                        html += '<div class="news_topic"> <a href="' + link + '" class="news_topic_title" onmouseover="$(this.nextSibling).show()" onmouseout="$(this.nextSibling).hide()">' + topic_title + '</a>';
                        html += '<div class="news_topic_desc" style="display:none">' + preview + '</div><br /><span class="news_topic_author">by ' + author + '</span> on <span class="news_topic_time">' + time_formatted + '</span></div><br />';
                        if(i >= limit) break;
                    };
                    holder.innerHTML = html + '</div></div>';
                  });
              };
    document.getElementById("LGnews_3").innerHTML = debug;
            });

Portal widget contents:
Code:
<div id="LGnews_3" class="LGnews"></div>




EDIT

Okay, so this works (line 19 in the script above):
Code:
$.get('/feed/?f=' + f, function(xml) {
And this doesn't:
Code:
$.get('http://feed43.com/6103814738067657.xml', function(xml) {

But...I can't figure out why it wouldn't work.

Kestrana
Forumember

Posts : 25
Reputation : 0
Language : English

Back to top Go down

Completed Re: Ego search widget

Post by kirk on April 8th 2013, 7:44 pm

Have you tried asking at avacweb?

be sure it is compatible with what ever forum version you are using. Most of the stuff there is set for phpbb3 boards only. but do have other stuff that dose work with other versions as well.. I am not sure? But you would be better off asking there since they are the ones that constructed it Smile


kirk
Forumaster

Male Posts : 11037
Reputation : 651
Language : English,Vulcan,Klingon, Romulan,& Gorn

Back to top Go down

Completed Re: Ego search widget

Post by Kestrana on April 9th 2013, 1:05 am

Yes, I've posted in the thread at avacweb as well. It's not a problem with their script, per se (since it works fine if I use "/feed/" instead of a fully-qualified URL). I need someone who knows javascript to help me figure out how to make it work with a fully-qualified URL (since it seems like $.get doesn't play well with fully-qualified feed URLs).

Kestrana
Forumember

Posts : 25
Reputation : 0
Language : English

Back to top Go down

Completed Re: Ego search widget

Post by kirk on April 9th 2013, 8:58 pm

yeah i am not sure? we get so many people here asking for things related to that site, Them guys are going to have to start helping people there. forumotion staff here have enough forumotion related stuff to deal with so cant keep doing support for avacweb. i mean we have really been getting a lot coming here asking, i have helped in the past , but for me to try to figure out what you need help with i have to set it all up on a test forum, and not even sure if i can come to a solution or how long it will take.

So thats why i said. them avacweb guys are going to have to start stepping up and helping people there with this stuff. Sooner or latter we may be forced be forced lock and trash all things related to their site. Once again. We get a lot of people coming here with many different things from that site. I think most of the time people have problems is because they are not following the directions correctly, or trying to do it for a forum version the scripts are not compatible with? Whatever the case?

Not really sure what the deal is, i hate to turn people away but avacweb staff needs to step things up there. thumright If it was just a few things here and there, then sure we have no problem with that. We like to try to help as many we can with whatever we can. But when it is on going continuing post of members coming here because they cant get support there, well then it starts becoming somewhat of a burden and we simply do not have the time.

Anyway.
There are a lot of people here that use things from there so may be another members that has the same thing can help with it Smile If i can find some extra time over the weekend i will try it my self and fiddle with it. In all honestly i am not even sure what you mean until i test/do things my self hands on first Crying or Very sad

kirk
Forumaster

Male Posts : 11037
Reputation : 651
Language : English,Vulcan,Klingon, Romulan,& Gorn

Back to top Go down

Completed Re: Ego search widget

Post by Kestrana on April 12th 2013, 4:05 am

I've got a solution, want to post it so others can use it.

Rather than creating a 3rd-party RSS feed, I'm using the egosearch site search function and some ajax calls to retrieve the data. The objects that you use will have to change depending on what theme you're using, but the non-coding version of it is:
  1. Fetch the content of the /search?search_id=egosearch page
  2. Parse the contents of the tbody tag of the table that contains the search results
  3. From the contents of the tbody, parse the contents of each row
  4. For each row, parse the contents of the h2 tag and the contents of the "Last Posts" td tag
  5. Display those contents with HTML coding


To accomplish this...

...add a class of "searchRow" to the search_results_topics template in Admin > Display > Templates: General > search_results_topics
Code:
<tbody class="statused">
<!-- BEGIN searchresults -->
<tr class="searchRow">
<td class="tcl tdtopics search">


...create a widget in Admin > Modules > Forum widgets management > Create a widget. Give the widget the name and title you'd like, then put this in the contents:
Code:
<div id="egosearchWidget"></div>

...create a JavaScript code in Admin > Modules > Javascript codes management > Create a new javascript. Give the code a title and choose which pages you want it to display on, then put this in the contents:
Code:
$(function(){
  var feed = 'http://reverie.forumotion.net/search?search_id=egosearch';
  $.ajax({
    url:feed,
    success:function(data) {
      var jqobj = $( data ), htmlString = '';
      $( "tbody.statused", jqobj).each(function(){
        $( "tr.searchRow", this).each(function(i){
          if(i <= 10){
            htmlString += "" + $( this ).children("td.tcl").children("h2.topic-title").html() + "<br />";
            htmlString += $( this ).children("td.tcr").html() + "<br /><br />";
          }
        });
      });
      $( "#egosearchWidget" ).html( htmlString );
      }
  });
});

...add the widget to the Portal or Forums, depending on where you want to display it.

To format the display of the contents, put the HTML code inside the double quotes ("") in the htmlString. The code above matches the default punBB display of topics in the "Recent topics" widget.

Feel free to PM me if you have questions about how this works, or need help with something.

Kestrana
Forumember

Posts : 25
Reputation : 0
Language : English

Back to top Go down

Completed Re: Ego search widget

Post by Sir Chivas™ on April 12th 2013, 5:06 am

This is marked, "Completed," is it solved?



Attention!
- Please provide your forum URL at all times.
- When the issue is solved, please mark it as solved.



Sir Chivas™
Support Moderator
Support Moderator

Male Posts : 6783
Reputation : 430
Language : EN, FR, ES
Location : || CSS || HTML || Graphics Designs || Support ||

Back to top Go down

Completed Re: Ego search widget

Post by Kestrana on April 12th 2013, 5:14 am

Yes.

I marked it "completed" rather than "solved" because the original problem still exists...but it's probably not fixable within the security limitations on FM. I developed a new solution rather than fixing the original.

Kestrana
Forumember

Posts : 25
Reputation : 0
Language : English

Back to top Go down

Completed Re: Ego search widget

Post by Sir Chivas™ on April 12th 2013, 5:16 am

Alright then, but can I lock this thread? Or do you still need further more support?



Attention!
- Please provide your forum URL at all times.
- When the issue is solved, please mark it as solved.



Sir Chivas™
Support Moderator
Support Moderator

Male Posts : 6783
Reputation : 430
Language : EN, FR, ES
Location : || CSS || HTML || Graphics Designs || Support ||

Back to top Go down

Completed Re: Ego search widget

Post by kirk on April 13th 2013, 8:57 pm

Topic Solved & Locked

kirk
Forumaster

Male Posts : 11037
Reputation : 651
Language : English,Vulcan,Klingon, Romulan,& Gorn

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum