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);
//=============================================
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}
<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}
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>
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:
<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>
Code:
<span id="related_load-{$link_shakebox_index}" style="display:none">
</span>
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 related_link.tpl is smarty file for related links. You should edit this file to change text if no related link is found.






Linear Mode

