Related links

Register an Account
Pligg Chat Room
Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-27-2008, 01:30 PM
AnAlienHolakres3's Avatar
Pligg Donor/Coder
 
Join Date: Jul 2007
Location: Prague
Posts: 116
Send a message via ICQ to AnAlienHolakres3
Hello everyone. As you well know there are related links to each link on story page. In some cases (i.e. when title on published or upcoming page is used directly as a link to destination page) related links are not shown.

In that case we have two choices:
1) forget related links
2) implement related links to same area as Bury or Save button.



The idea is pretty simple, when user clicks on specific "Related links"(Související) button, related links are shown right below specific link.




Ways of implementation:
- Easy synchronous solution
- Asynchronous solution (using AJAX)

Necessary icons and files are as an attachment.

Comparation of these solutions:
- Easy synchronous solution is easy to implement and it works smoothly
- Asynchronous solution is far better for performance. Necessary data are loaded when user desires to do so,not in advance like when synchronous solution is used.
- Asynchronous solution keeps information updated, you do not have to refresh the whole page to reload related links info.
- Asynchronous solution is a little more difficult to implement

Easy synchronous solution implementation
We need to modify 2 files:
- link.php in libs folder
- link_summary.tpl in templates/template folder

Link.php:

find function fill_smarty() and at the end of these function add following code:
PHP Code:
         //=============================================
         // Related links in link     
      
        
$rel_stor=related_stories($this->id$this->tags$this->category);     
        
$smarty->assign('rs_exist',count($rel_stor));        
         
$smarty->assign('related_story',$rel_stor);       
        
//============================================= 
Link_summary.tpl
Find {if $link_shakebox_currentuser_reports eq 0 AND $user_logged_in neq ""} and after this section (which is ended by {/if}) add following code:
Code:
{if $rs_exist neq 0}
     &nbsp;<span>
     <img src="{$my_pligg_base}/templates/{$the_template}/images/similar.gif" 
style="width:16px;height:16px;margin-bottom:-3px" /> 
<a href="javascript://" 
onclick="new Effect.toggle('rel_links-{$link_shakebox_index}','blind', {queue: 'end'});">{#PLIGG_Visual_Story_RelatedStory#}</a></span>
     <div id="rel_links-{$link_shakebox_index}" 
     style="border:4px solid {if $pagename eq "upcoming"}#AEF1FF{else}#AED7FF{/if};padding-left:5px;margin-top:10px;background:white;display:none">              
    {section name=nr loop=$related_story}
      - <a href = "{$related_title_url}{$related_story[nr].link_title_url}">{$related_story[nr].link_title}</a><br/></li>
    {/section}                                                                
    </div>    
{/if}
Feel free to customize this code. Highlihted code should work with Prototype Javascript library but personally I use JQuery and in that case you would need edit this code also.

Find {if $Enable_Recommend eq 1} and before this section add following code:
Code:
            <span id="related_load-{$link_shakebox_index}" style="display:none">
            </span>
Asynchronous solution implementation (ajax)
We need to modify 3 files and create new 2 files:
- link.php in libs folder
- link_summary.tpl in templates/template folder
- xmlhttp in js folder
- create relatedlink_request.php in root folder (attachment)
- create related_link.tpl in /templates/template folder (attachment)

Link.php
Customization of this file is really short. Position of new added code is the same as in synchronous way of implementation, at the end of fill_smarty() function:
PHP Code:
        //=============================================
        // Related links in link ADDON
            
$smarty->assign('tags_str',$this->tags);       
        
//============================================= 

Link_Summary.tpl
Exactly the same position as in synchronous way of implementation. Code:
Code:
     &nbsp;<span>
     <img src="{$my_pligg_base}/templates/{$the_template}/images/similar.gif"  style="width:16px;height:16px;margin-bottom:-3px" />
      <a href="javascript://" onclick="relatedlink_request('related_load-{$link_shakebox_index}',{$link_id},'<br />{#PLIGG_Visual_Loading_Wait#}<img src=\'{$my_pligg_base}/templates/{$the_template}/images/load.gif\'  style=\'width:16px;height:16px\' />','{$tags_str}','{$pagename}')">{#PLIGG_Visual_Story_RelatedStory#}</a></span>
      <div id="rel_links-{$link_shakebox_index}" style="border:4px solid {if $pagename eq "upcoming"}#AEF1FF{else}#AED7FF{/if};padding-left:5px;margin-top:10px;background:white;display:none">
     </div>
Find {if $Enable_Recommend eq 1} and before this section add following code (yes, the same code and the same position as in sync. way):
Code:
            <span id="related_load-{$link_shakebox_index}" style="display:none">
            </span>
xmlhttp.php
We need do some javascript,add following 2 functions:
Code:
function EL(id){
 return document.getElementById(id);
}

function relatedlink_request(target_id,link_id,input_html,tags,pagename) 
{ 
    new Effect.toggle(target_id,'blind', {queue: 'end'})   
            
    if (EL(target_id).style.display=="") {
        EL(target_id).innerHTML = input_html;
          
    
        url = "/relatedlink_request.php";
        
    
            mycontent = "link_id=" + link_id + "&"+"tags="+tags+ "&"+"pagename="+pagename;                
        
         mnmxmlhttp = new myXMLHttpRequest ();
         
         if (mnmxmlhttp) {   
          mnmxmlhttp.open ("POST", url, true);
           mnmxmlhttp.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded');    
            mnmxmlhttp.send (mycontent);
                        
          }
        mnmxmlhttp.onreadystatechange = function () {
                    if (mnmxmlhttp.readyState == 4) {
                        response = mnmxmlhttp.responseText;
                        EL(target_id).style.display='none';
                        new Effect.toggle(target_id,'blind', {queue: 'end'});
                        EL(target_id).innerHTML= response;
                                                                            
                }
            
            }    
          }    
          
    
}
New file relatedlink_request.php is a php file which implements functions of html1.php which are necessary. This file displays smarty file related_link.tpl.
New file related_link.tpl is smarty file for related links. You should edit this file to change text if no related link is found.
Attached Images
  
Attached Files
File Type: tpl related_link.tpl (667 Bytes, 139 views)
File Type: php relatedlink_request.php (1.7 KB, 152 views)
Reply With Quote
  #2 (permalink)  
Old 05-27-2008, 05:08 PM
graphicsguru's Avatar
Pligg Donor
Pligg Version: 9.9.5
 
Join Date: Aug 2006
Location: USA
Posts: 399
This is fantastic great mod thank you very much

not sure what to do yet
mine is not 100% its works great on all my old categories on old post
maybe the same on your site ?

i.e. if I go to your last page last story and click Související

I get 10 related stories

VĹ*Elink / SchválenĂ© záloĹľky

on your site when I click I see this not sure what it says
K této záložce neexistují žádné související linky

can you translate this to English K této záložce neexistují žádné související linky
Reply With Quote
  #3 (permalink)  
Old 05-27-2008, 06:06 PM
AnAlienHolakres3's Avatar
Pligg Donor/Coder
 
Join Date: Jul 2007
Location: Prague
Posts: 116
Send a message via ICQ to AnAlienHolakres3
Quote:
Originally Posted by graphicsguru View Post
can you translate this to English K této záložce neexistují žádné související linky

Of course I must forgot to translate it in English - it means "For this link there are no related links"
Reply With Quote
  #4 (permalink)  
Old 05-27-2008, 07:10 PM
graphicsguru's Avatar
Pligg Donor
Pligg Version: 9.9.5
 
Join Date: Aug 2006
Location: USA
Posts: 399
OK thank you my friend
Reply With Quote
  #5 (permalink)  
Old 05-28-2008, 12:01 PM
Banned
Pligg Version: 9.9.5
 
Join Date: Oct 2007
Location: Canada
Posts: 804
wow this is amazing, PROPS to you for helping our free open source community!

I will try and install this tonight!
Reply With Quote
  #6 (permalink)  
Old 06-06-2008, 10:34 AM
New Pligger
Pligg Version: 9.9
Pligg Template: Custom
 
Join Date: Dec 2007
Posts: 16
sweet to this work on version 9.9.0????? el try it anyways props for the contribution.
Reply With Quote
  #7 (permalink)  
Old 06-07-2008, 01:55 AM
davemackey's Avatar
Pligg Donor
Pligg Version: 9.9.
Pligg Template: siChunkBlue
 
Join Date: Aug 2007
Location: Langhorne, PA
Posts: 226
Great mod. Looking forward to implementing. Thanks!
David.
Reply With Quote
  #8 (permalink)  
Old 06-07-2008, 06:14 AM
Casual Pligger
 
Join Date: Apr 2008
Posts: 48
Very great mod, thanks!
Reply With Quote
  #9 (permalink)  
Old 08-21-2008, 10:28 AM
New Pligger
 
Join Date: Apr 2008
Posts: 7
Have you noticed the URLs for the related stories ?

I have something like this http://www.domain.com/story/title/bl...la-story-title when it should be http://www.domain.com/category/bla-bla-bla-story-title

This is a big problem, do you have a fix for it ?
Reply With Quote
  #10 (permalink)  
Old 08-24-2008, 02:29 AM
New Pligger
Pligg Version: 9.9.5
 
Join Date: Aug 2008
Location: India
Posts: 3
I get forums.pligg login page when I click related links.
I am using Asynchronous solution implementation (ajax) method
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
related links not showing up jaf7 Questions and Comments 7 05-09-2009 08:50 PM
Related links that lead directly to original URL gnalkit Questions and Comments 0 05-01-2009 08:45 AM
Related links module bobbymoore Questions and Comments 0 04-14-2009 11:34 AM
Include Summary in Related links xerxesx1 Questions and Comments 0 03-27-2009 11:54 AM
ShakeBox Related Links tommy818 Questions and Comments 2 05-14-2008 12:40 PM


Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Make a donation to support Pligg CMS development