MOD Random Links Box - eSyndiCat User Forums
eSyndiCat User Forums esyndicat directory software esyndicat support

Go Back   eSyndiCat User Forums > eSyndiCat Directory Software [PAID] > eSyndicat Pro v1.x > Version Mods, Bugfixes & Patches

Version Mods, Bugfixes & Patches Has just finished programming a cool mod for eSyndiCat Directory Software? Share it with the community here.

 
 
Thread Tools Rate Thread Display Modes
Old 08-16-2006   #1
scanreg
 
Join Date: Oct 2005
Posts: 349
scanreg has disabled reputation
Default MOD Random Links Box

eSyn Pro 1.2

I would love to have a Random Links Sidebox

This would be different from the Featured box or Partners box

The idea is that I'd set some number - like 5 - to display up to 5 randomly selected links from my list. It would change with each page view, and it would be a cool way to bring attention to the listings.

Anyone know how to do this?

Many thanks :-)
scanreg is offline  
Old 08-17-2006   #2
Dave Baker
 
Join Date: Jul 2006
Location: St. Petersburg
Posts: 2,567
Dave Baker is on a distinguished road
Default

Hello scareg,
***Open Header.php and find line of code***
PHP Code:
require_once('util.php'); 
*** Below this line insert following: ***
PHP Code:
$random_links =& $gDirDb->getRandomLinks(5);
$gDirSmarty->assign_by_ref('random_links'$random_links); 
***Save File***
***Open Header.tlp and find following:***
Code:
{if $news && $config.news}
<div class="box">
	<div class="box-caption2-right">
		<div class="box-caption2-left">
			<div class="box-caption2">{$lang.news}</div>
		</div>
*** Before this code insert following code: ***
For GreenLeaves template
Code:
<div class="box">
	<div class="box-caption2-right">
		<div class="box-caption2-left">
			<div class="box-caption2">Yours caption</div>
		</div>
	</div>
		<div class="box-content">
			<div class="links">
{foreach from=$random_links item=link_random}
	<div class="random-link"><a href="{$link_random.url}" class="title" id="l{$link_random.id}" {if $config.new_window}target="_blank"{/if}>{$link_random.title}</a></div>
{/foreach}
			</div>
		</div>
	</div>
For BlueWater template
Code:
<div class="box" style="margin-right: 0;">
    <div class="box-caption">{$lang.Random_Links_Sidebox}</div>
    <div class="box-content">
	<div class="links">
{foreach from=$random_links item=link_random}
	<div class="random-link"><a href="{$link_random.url}" class="title" id="l{$link_random.id}" {if $config.new_window}target="_blank"{/if}>{$link_random.title}</a></div>
{/foreach}
  	</div>
  </div>
</div>
***Save File***

*** Open language file and add ***
Code:
'Random_Links_Sidebox' => 'Random Links Sidebox',
***Save File***

Last edited by Dave Baker; 08-25-2006 at 10:45 AM.
Dave Baker is offline  
Old 08-18-2006   #3
sdawkins
 
sdawkins's Avatar
 
Join Date: Oct 2005
Posts: 608
sdawkins has disabled reputation
Send a message via AIM to sdawkins Send a message via Yahoo to sdawkins
Default

Dave, this works great Thanks!
__________________
Rainbow Bridge
sdawkins is offline  
Old 08-21-2006   #4
Dave Baker
 
Join Date: Jul 2006
Location: St. Petersburg
Posts: 2,567
Dave Baker is on a distinguished road
Default

Always at your services.
Dave Baker is offline  
Old 08-21-2006   #5
scanreg
 
Join Date: Oct 2005
Posts: 349
scanreg has disabled reputation
Default

Thanks, Dave - This is great!
scanreg is offline  
Old 08-22-2006   #6
billybh
 
Join Date: Feb 2006
Posts: 80
billybh has disabled reputation
Default

The random links are grabbing a lot of the banned sites. Where should I look to tweak the sql?
billybh is offline  
Old 08-23-2006   #7
Vincent Wright
 
Join Date: Sep 2005
Posts: 1,421
Vincent Wright is an unknown quantity at this point
Default

This is in classes/Dir.php, function getRandomLinks()

PHP Code:
    function getRandomLinks($aLimit)
    {
        
$sql "SELECT * ";
        
$sql .= "FROM `{$this->mPrefix}links` ";
        
$sql .= "ORDER BY RAND() ";
        
$sql .= "LIMIT 0, {$aLimit}";

        return 
$this->mDb->getAll($sql);
    } 
This is pretty buggy implementation [will be fixed in the new version] since it fetches ALL the links, no matter if they are active, approval, banned, or suspended.

To fetch only active links you have to replace it with this one:

PHP Code:
    function getRandomLinks($aLimit)
    {
        
$sql "SELECT * ";
        
$sql .= "FROM `{$this->mPrefix}links` ";
        
$sql .= "WHERE `status` = 'active' ";
        
$sql .= "ORDER BY RAND() ";
        
$sql .= "LIMIT 0, {$aLimit}";

        return 
$this->mDb->getAll($sql);
    } 
This should do the trick.
Vincent Wright is offline  
Old 08-24-2006   #8
lsb
 
Join Date: Nov 2005
Location: Switzerland
Posts: 306
lsb has disabled reputation
Default

Cool feature!
Do you have a hint for me what to do when I want to integrate it into my fire&ice template?

Greetings, Lars
lsb is offline  
Old 08-24-2006   #9
Greg
Super Moderator
 
Greg's Avatar
 
Join Date: Oct 2005
Location: Phoenix,Arizona (Valley of the Sun)
Posts: 5,358
Greg is a jewel in the roughGreg is a jewel in the roughGreg is a jewel in the roughGreg is a jewel in the rough
Default

Quote:
Originally Posted by lsb
Cool feature!
Do you have a hint for me what to do when I want to integrate it into my fire&ice template?

Greetings, Lars
After you do all the stuff Dave showed, add this to the header.tpl
Code:
<div class="box">
	<div class="box-caption">{$lang.Random_Links_Sidebox}</div>
	<div class="box-content">
		<div class="links">
{foreach from=$random_links item=link}
	<div class="random-link"><a href="{$link.url}" class="title" id="l{$link.id}" {if 

$config.new_window}target="_blank"{/if}>{$link.title}</a></div>
{/foreach}
  	             </div>
	</div>
</div>
Should work not tested though.
__________________
Please don't ask me about script questions or sales issues through "Private Messages". Thanks!
Greg is offline  
Old 08-24-2006   #10
lsb
 
Join Date: Nov 2005
Location: Switzerland
Posts: 306
lsb has disabled reputation
Default

Quote:
Originally Posted by Greg
Should work not tested though.
Great, works, thank you.
The only thing I would like to change now is font style, so it looks like the text in my featured links box: http...
smaller, left-aligned, a bit space between the lines.
Any ideas?

Last edited by lsb; 05-12-2007 at 11:11 PM.
lsb is offline  
 

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 12:56 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Testimonials | Articles | Support | Documentation | Privacy Policy | License | Affiliates | Contact Us