Special Advertising Add-On for banners Tutorial

Register an Account
Pligg Chat Room
Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-31-2007, 08:28 AM
AnAlienHolakres3's Avatar
Pligg Donor/Coder
 
Join Date: Jul 2007
Location: Prague
Posts: 116
Send a message via ICQ to AnAlienHolakres3
Hello folks. This tutorial is designed for everyone who is at least a little interested in advertising on its own site. As you well know advertising banners disturbing your site design, especially on Pligg sites top-banners are not nice solutions.

I decided to do something what does not disturb your design, is very visible and users are willing to click on it. I´ve spent many hours developing this dirty addon, but please keep in mind this is absolutely dirty solution and if you want to do this, you should have at least absolutely basic programming knowledge. One way or another please make backup of files we are going to edit (so no replies of kind "i kill you that thing destroyed my amazing pligg site" will be accepted). However I will try to do my best for explaining every step and i hope you will made it with satisfaction.

The result looks like this:
See attachment

I´m using Google Adsense banner for this, about code and size i will inform you later. I suppose you can also use Yahoo or Microsoft advertising.

Addon Description
  • Your advertising link is displayed when published links are supposed to be shown, you can customize link design via css
  • You can customize how many links at least has to be in selected category (or subcategory or all) to be advertising link displayed, please note that these customization is also limited by page size which can be set in your admin panel.
  • Displaying of advertising link is RANDOM. I suppose no one would be interested in advertising link which is forever at the x position.
  • Advertising link - as you can see in the picture - has no comments, category etc. shown, symbol ":-)" is "clickable", it is refreshing page and changing position of advertising link.

Reguirements
- Some brain - without that its highly risky
- Pligg v.9.7, however i assume you should be able to integrate into older vesions
- Notepad ++ or PHP Designer or PhpEd or combination (my favorite
- Google Adsense Account (or similar) and to know how add banners into page
- PHPMyAdmin or command shell(good luck with it for doing some things in database
- A few hours freetime

Limitations
This tutorial is designed for:
- searching method:3
- default (no star) voting
- default url method

This is my configuration. If your configuration is different, you will probably (ok if you got star voting method its 100%) did some own customizations=>you should something know about php.

Part 2 - Editing

2.1.1 Creating new user
This is optional. Personally I created new with name "Advertiser". This is recommendet for people who like experimenting.

2.1.2 Creating new link
This is absolutely required. Go to your phpMyAdmin (so logg in your database), customize and run this sql:

Code:
INSERT INTO `your_domain_links` (`link_id`, `link_author`) VALUES 
(100, 6);
This code create simply new link.
Why this link id?This value must be changed. As you well know, primary key must be unique so set this number to number you havent.
You will have to change also this number in every file we will edit to your own. In my case I use my link_id=100. For me it is the highest link_id value.I am not sure what auto_icrement value does if you set link_id bigger then it is. To avoid errors you should run this SQL query in your php admin:

Code:
 alter table your_domain_links auto_increment=101;
Make sure that auto_increment value is higher than link_id value you just set.

Why this link_author? This value is supposed to be edited, when I created user "Advertiser" his user_id=6 so set this number to user you want to be owner.

Now,we want to edit this link directly,so click on this link to edit it. You should now be in edit mode,ok? Do following changes:

link_id: no change (100)
link_author: no change (your value from previous step)

link_id: published
link_rankey:7965648 (you can make your own random key,does not matter)
link_votes: no change - will be set automatically
link_reports:no change (0)
link_comments:no change (0)
link_karma:1
link_modified:no change (now() will be set automatically)
link_date:no change,will be set automatically
link_published_date:no change,will be set automatically
link_category:1
link_lang:1
link_url:no change (none)
link_url_title:no change (none)
link_title:no change (none)
link_title_url:no change (none)
link_content:no change (none)
link_summary:your adsense script ,I recommend to give it into <div> and set the same color as is banner border color,personaly i have:

Code:
<div  style="background: #eff5ff; width:468px; height: 70px">
<script type="text/javascript"><!--
google_ad_client = "pub-6458346793444195";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
//2007-08-30: VÅ*Elink / Novinky
google_ad_channel = "3121957991";
google_color_border = "eff5ff";
google_color_bg = "F7F9FD";
google_color_link = "0014d6";
google_color_text = "000000";
google_color_url = "5092FE";
//-->
</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
So the <div> width is the same as banner with and height is 10px longer. It is required you add your adsense generated code. This wont work for you (or definitely wont make money for you.

Save the changes. We dont longer need phpAdmin.

2.1.3 Editing link.php in your ../libs/ directory
So what we have to do. In this file we will decide if link is our special advertising link and if so, we will do some (ok a little more) queries to get neccessary data, we need information about num of links in specific desired category (or without it), for random positioning we need to know:
- min date of links which are supposed to be displayed
- max date
- min votes
- max votes

Why date and votes? Beceause links are sorted by DATE or by number of VOTES (or both. When we have these informations, we can make random date and random count of votes between max date and min date (and between max votes and min votes).

The next information we need to know if our link was shown only one times and it is also necessary to assign smarty value to let know some *.tpl file (details later) that this link is special and design is supposed to be changed. OK, enough theory, there is a code which you have to add to link.php before //for friends section (it is somewhere in the middle about line 400, just press ctrl+f and search for friends):

[End of Post 1 the rest is in next post]
Attached Thumbnails
Special Advertising Add-On for banners Tutorial-advertising_module.png  

Last edited by AnAlienHolakres3; 11-23-2008 at 05:19 AM. Reason: Minor changes
Reply With Quote
  #2 (permalink)  
Old 08-31-2007, 08:53 AM
Casual Pligger
 
Join Date: Aug 2007
Posts: 65
Looks great. I will give it a go tomorrow when I have free time.
Reply With Quote
  #3 (permalink)  
Old 08-31-2007, 09:05 AM
AnAlienHolakres3's Avatar
Pligg Donor/Coder
 
Join Date: Jul 2007
Location: Prague
Posts: 116
Send a message via ICQ to AnAlienHolakres3
So there is the code- copy and paste in file: [Revision 2 from 1st Sept.07]

PHP Code:
//********************************************************************************************************
//  Google Adsense Dirty Addon for Pligg users by AnAlienHolakres3 => http://vselink.org 
//  Supposed to be in link.php before part "For Friends" , about row 400 - 500 in this file
// revision 2, from 01/09/2007
//this condition speed-up the process - if our link is not the desired banner link, just skip the whole add
if ($this->id == 100) {

    
//change $minimalCount value to increase limit of minimal links to add advertising banner
    
$minimalCount 4;

    global 
$db,$page_size;
    
// find the name of the current category
   
                                       

      //if category IS SELECTED   and cadid of category <> 0  beceause when submitting there is a request of category but not for this,simply without it it gives an error
    
if(isset($_REQUEST['category']) && $catid !=0){

        
//get category id
        
$catid $db->get_var("SELECT category_id FROM " table_categories " WHERE `category_safe_name` = '".urlencode(sanitize($_REQUEST['category'], 1))."';");
                                                                                             
        
//count of links in  selected category and subcategory
        
$links_counter $db->get_var("SELECT count(link_id) FROM " table_links " WHERE link_category IN (" .$catid .
        
") OR link_category IN (SELECT category_id FROM " table_categories " WHERE category_parent = "$catid .") AND link_status='PUBLISHED' ;");
    
 
        
//random position when page is loaded. Links are sort BY DATE so we need to set DATE of advertising link between the oldest and newest link
        //1a) select the newest link
        
$newest_link $db->get_var("SELECT max(link_published_date) FROM " table_links " WHERE link_category IN (" $catid 
        
") OR link_category IN (SELECT category_id FROM "  table_categories " WHERE category_parent = " $catid .") AND link_status='PUBLISHED' ;");
    
        
//1b) select the oldest link (the last but one)
        
$oldest_link $db->get_var("SELECT min(link_published_date) FROM " table_links " WHERE link_category IN (" $catid 
        
") OR link_category IN (SELECT category_id FROM "  table_categories " WHERE category_parent = " $catid .") AND link_published_date > 0 AND link_id NOT IN (100) AND link_status='PUBLISHED' ;");
    
        
//random position when page is loaded. Links are sort BY VOTES so we need to set VOTES of advertising link between the most and the lest (but one:)
        //1c) select link with most votes
        
$most_votes $db->get_var("SELECT max(link_votes) FROM " table_links " WHERE link_category IN (" $catid 
        
") OR link_category IN (SELECT category_id FROM "  table_categories " WHERE category_parent = " $catid .");");
        
        
//1d) select the oldest link (the last but one)
        
$less_votes $db->get_var("SELECT min(link_votes) FROM " table_links " WHERE link_category IN (" $catid 
        
") OR link_category IN (SELECT category_id FROM "  table_categories " WHERE category_parent = " $catid .") AND link_votes > 0 AND link_id NOT IN (100) AND link_status='PUBLISHED' ;");
        
        
        }   else {
        
//if category IS NOT selected
        //
        
$links_counter $db->get_var("SELECT count(link_id)  FROM " table_links ." WHERE link_status='PUBLISHED' ;");  
        
        
//2a) select the newest link
        
$newest_link $db->get_var("SELECT max(link_published_date) FROM " table_links ." WHERE link_status='PUBLISHED' ;");
    
        
//2b) select the oldest link
            
$oldest_link $db->get_var("SELECT min(link_published_date) FROM " table_links " WHERE link_published_date > 0 AND link_id NOT IN (100) AND link_status='PUBLISHED' ;" );
            
        
//2c) select link with most votes
        
$most_votes $db->get_var("SELECT max(link_votes) FROM " table_links " WHERE link_status='PUBLISHED' ;");
        
        
//2d) select the oldest link (the last but one)
        
$less_votes $db->get_var("SELECT min(link_votes) FROM " table_links " WHERE link_votes > 0 AND link_id NOT IN (100) AND link_status='PUBLISHED' ;");    
    
        }
    
        
//check if banner template change is not already activated  
        
$active $db->get_var("SELECT link_field1 FROM " table_links " WHERE link_id=".$this->id);
                                                          
        
//check num of links,status and id
        
if (($page_size $minimalCount) && ($links_counter $minimalCount) && ($active ==0) &&($this->id == 100)) {
    
        
// more than 4 links, banner will be shown
        
$advertising true;                                 
        
// echo "if";
    
        //only 1 link as banner is allowed so update database and set 1 
        
$sql "UPDATE " table_links " SET `link_field1` = 1 WHERE link_id=100";
        
$db->query($sql);
    

        
//convert date to unix time:
        
$newest_time strtotime($newest_link);
        
$oldest_time strtotime($oldest_link);
     
       
//3a) create random time between newest and oldest        
         
$new_timemt_rand($oldest_time,$newest_time);
          
$new_time_cr=$new_time-3600;
       
//3b) create random votes beteen the most and the less  
         
$new_votesmt_rand($less_votes,$most_votes);
         
       
//time and votes created so let´s update the advertising link time FROM_UNIXTIME($link_published_date) and also set new random votes
       
$sql "UPDATE " table_links " SET `link_published_date` =FROM_UNIXTIME(" $new_time "), `link_date` =FROM_UNIXTIME(" $new_time_cr "), `link_votes` =" $new_votes " WHERE link_id=100";
       
$db->query($sql);
    
        }else  { 
//  less than 5 links, no advertising
        
$advertising false;                                         
     
//echo "else";
    
}

     
//this is for link_summary.tpl
    
$main_smarty->assign('advertising_banner',$advertising);
      
}    
//adsense addon end
//********************************************************************************************************* 
You can save it, we don longer need it.

2.1.4 Editing link_summary.php in your ../libs/ directory
Maybye you were thinking about how is possible that our special link is (nearly always) shown regardless category is set or not. We will mange it in these file.
From line 68 (or somewhere there) should be code if ($new_search) {. Replace ALL from this code down with:

PHP Code:
        if ($new_search) {
           
allowBanner(); 

            foreach(
$new_search as $link_id) {
                
$link->id=$link_id;
                if (
$link_id != 100)    {
                
$link->read();
                
$link->print_summary('summary');
            }
            }
    } else {
    if (
$links) {
       
allowBanner();
        foreach(
$links as $link_id) {
            
$link->id=$link_id;

            
$link->read();
            
$link->print_summary('summary');
            }
        }
    }
 
//************************************************************************************
 //  Function allowBanner() set value in database to 0 everytime when user request
 // a category or do some search. 
 //************************************************************************************
 
function allowBanner() {
 global 
$db;
    
$qsql "UPDATE " table_links " SET `link_field1` = 0 WHERE link_id=100";
        
$db->query($qsql);

 } 
.

Thats all for this file. Save and close.

2.1.4 Editing search.php in your ../libs/ directory
It is also neccessary edit this file, we need not only show our special advertising link when is category selected (or not), we need it when user search for something also. So Replace original code (ctrl+f to find it): $from_where .= " AND (link_category=$catId " . $child_cat_sql . ")"; with:

PHP Code:
            //======================================================================================adsense
            
            
if(isset($_REQUEST['category'])){
                
$minimalCount 4;
                
//get category id
                
$catid $db->get_var("SELECT category_id FROM " table_categories " WHERE `category_safe_name` = '".urlencode(sanitize($_REQUEST['category'], 1))."';");
        
                
//count of links in  selected category and subcategory
                
$links_counter $db->get_var("SELECT count(link_id) FROM " table_links " WHERE link_category IN (" .$catid .
                
") OR link_category IN (SELECT category_id FROM " table_categories " WHERE category_parent = "$catid .");");
        
            }   else {
                
//if no category is selected
                
$links_counter $db->get_var("SELECT count(link_id)  FROM " table_links );  
                }
                global 
$page_size;
                
                if ((
$page_size $minimalCount) && ($links_counter $minimalCount)) {
                    
$from_where .= " AND (link_category=$catId OR link_id=100 " $child_cat_sql ")";
    }else 
$from_where .= " AND (link_category=$catId " $child_cat_sql ")";
            
            
//======================================================================================adsense 
You can save and close the file.

2.1.5 Editing link_summary.tpl in your ..templates/yget/ directory
Ok guys, this is the high point of the day).We got a smarty from link.php, it is $advertising_banner which will for us very useufull. So whats the point. The point is we need to change design of link when our special link is supposed to be shown. This file says what have "normal links". So we need to do a little mess - add many if like :
Code:
{if $advertising_banner neq 1}...do something to normal link...{/if}
which means that this is NOT our special link (and sometimes we need the otherwise. This is dirty and please be careful, highlited code is new. You can try to copy&paste all but I cant guarantee this will be appliable to your template/customization.

[End of Post 2 Final Part in Final Post]

Last edited by AnAlienHolakres3; 09-01-2007 at 03:44 AM. Reason: update: bug found and solved, check it out
Reply With Quote
  #4 (permalink)  
Old 08-31-2007, 09:30 AM
AnAlienHolakres3's Avatar
Pligg Donor/Coder
 
Join Date: Jul 2007
Location: Prague
Posts: 116
Send a message via ICQ to AnAlienHolakres3
This file is very long. I have to split it into 2 parts so first part is here. It is neccessary to set all conditions corectly (otherwise comments will blow). If you have 5 star voting ,this is the right time for your customization in voting method 2.I know its absolutely dirty,but i know you can make it:

Code:
div class="news-summary" id="xnews-{$link_shakebox_index}"
	{if $link_shakebox_currentuser_reports gt 0}
	    style="opacity:0.3;filter:alpha(opacity = 30)"
	{/if}
	>
								
	{if $Voting_Method eq 1}
		{if $advertising_banner neq 1}	
	
		{if $story_status eq "published"}
			<ul class="news-upcoming">
		{else}
			<ul class="news-upcoming2">
		{/if}
			{/if} {if $advertising_banner eq 1}<ul class="news-upcomingAdsense">{/if}			
		{if $advertising_banner neq 1}
				<span><li class="vote-publish"><a id="xvotes-{$link_shakebox_index}" href="{$story_url}">{$link_shakebox_votes}</a></li></span>{else}
				<span><li class="vote-publish"><a id="xvotes-{$link_shakebox_index}" href="#" onClick="window.location.reload()">:)</a></li></span>{/if}
				
				<li class="vote" id="xvote-{$link_shakebox_index}">
					{if $link_shakebox_currentuser_votes eq 0 && $link_shakebox_currentuser_reports eq 0}
						{if $advertising_banner neq 1}<a href="javascript:{$link_shakebox_javascript_vote}">{#PLIGG_Visual_Vote_For_It#}</a>{else}<span style="font-size:12px;color:#000000">Reklama</span>{/if}
					{else}
{if $advertising_banner neq 1}			{if $link_shakebox_currentuser_reports neq 0}
							<span>{#PLIGG_Visual_Vote_Report#}</span>
						{else}
							{if $pagename eq "user" && $user_logged_in neq $link_submitter}
								<a href="javascript:{$link_shakebox_javascript_unvote}">{if $advertising_banner neq 1}{#PLIGG_Visual_Unvote_For_It#}{/if}</a>
							{else}
								<span>{if $advertising_banner neq 1}{#PLIGG_Visual_Vote_Cast#}{/if}</span>{/if}
							{/if}	
						{/if}
					{/if}
				</li>
			</ul>
	{/if}	

	{if $Voting_Method eq 2}
		<h4 id="ls_title-{$link_shakebox_index}">
			<ul class='star-rating{$star_class}' id="xvotes-{$link_shakebox_index}">
				<li class="current-rating" style="width: {$link_rating_width}px;" id="xvote-{$link_shakebox_index}"></li>
				<span id="mnmc-{$link_shakebox_index}">
					{if $link_shakebox_currentuser_votes eq 0}
						<li><a href="javascript:{$link_shakebox_javascript_vote_1star}" class='one-star'>1</a></li>
						<li><a href="javascript:{$link_shakebox_javascript_vote_2star}" class='two-stars'>2</a></li>
						<li><a href="javascript:{$link_shakebox_javascript_vote_3star}" class='three-stars'>3</a></li>
						<li><a href="javascript:{$link_shakebox_javascript_vote_4star}" class='four-stars'>4</a></li>
						<li><a href="javascript:{$link_shakebox_javascript_vote_5star}" class='five-stars'>5</a></li>
					{else}
						<li class='one-star-noh'>1</li>
						<li class='two-stars-noh'>2</li>
						<li class='three-stars-noh'>3</li>
						<li class='four-stars-noh'>4</li>
						<li class='five-stars-noh'>5</li>
					{/if}
				</span>
			</ul>
		</h4>
	{/if}
		
	<div class="top"> 
	{if $advertising_banner neq 1}
		<div class="toptitle" id="ls_thetitle-{$link_shakebox_index}">
			{if $use_title_as_link eq true}
				{if $url_short neq "http://" && $url_short neq "://"}
					<a href="{$url}" {if $open_in_new_window eq true} target="_blank"{/if}>{$title_short}</a>
				{else}
					<a href="{$story_url}">{$title_short}</a>
				{/if}
		     {else}
				{if $pagename eq "story"}
					<a href="{$url}">{$title_short}</a>
				{else} 
				  <a href="{$story_url}">{$title_short}</a>
				{/if}
			{/if}        
		</div>
				{/if}
		<div class="news-submitted">{if $advertising_banner neq 1}
			{if $use_thumbnails eq true && $pagename eq "story" && $url_short neq "http://" && $url_short neq "://"}
				<b><img src="http://images.websnapr.com/?url={$url_short}&size=T" style="float:right; padding-left:0px;padding-top:0px;border: 1px solid #000000"></b>
			{/if}{  {/if}
			
			<a href="javascript://" onclick="show_hide_user_links(document.getElementById('userlinks-{$link_shakebox_index}'));">		
			{if $UseAvatars neq "0"}{if $advertising_banner neq 1}<span id="ls_avatar-{$link_shakebox_index}"><img src="{$Avatar_ImgSrc}" alt="Avatar"/></span>{/if}{/if}
			</a>
			
		{if $advertising_banner neq 1}{#PLIGG_Visual_LS_Posted_By#}	<span id="ls_posted_by-{$link_shakebox_index}"></span>
				{if $link_submitter neq $user_logged_in}			
					<a href="javascript://" onclick="show_hide_user_links(document.getElementById('userlinks-{$link_shakebox_index}'));">
				{else}
					<a href="{$submitter_profile_url}">
				{/if}
			<span id="ls_link_submitter-{$link_shakebox_index}">{$link_submitter}</span></a>
			
			<span id="ls_timeago-{$link_shakebox_index}">{$link_submit_timeago} {#PLIGG_Visual_Comment_Ago#}			
				{if $Voting_Method eq 2} - <strong>{#PLIGG_Visual_Vote_Average#}: <span id="mnma-{$link_shakebox_index}">{$link_rating}</span> {#PLIGG_Visual_Vote_Average_With#} <span id="mnmb-{$link_shakebox_index}">{$vote_count}</span> {#PLIGG_Visual_Vote_Average_Votes#}</strong>{/if}
			</span>			
			
			<span id="ls_story_link-{$link_shakebox_index}">
				{if $url_short neq "http://" && $url_short neq "://"}
					(<a href="{$url}" {if $open_in_new_window eq true} target="_blank"{/if}>{$url_short}</a>)
				{else}
					({$No_URL_Name})
				{/if}
			</span>
{if $isadmin eq "yes" || $user_logged_in eq $link_submitter}
					<span id="adminlinksbuttom"> | <a href="javascript://" onclick="var replydisplay=document.getElementById('ls_adminlinks-{$link_shakebox_index}').style.display ? '' : 'none';document.getElementById('ls_adminlinks-{$link_shakebox_index}').style.display = replydisplay;">{#PLIGG_Visual_Admin_Links#}</a></span> 			
				{/if}	
			
			<span id="userlinks-{$link_shakebox_index}" style="display:none;">
			<a href = "{$submitter_profile_url}">{#PLIGG_Visual_LS_View_Profile#}</a>  
				{if $FriendMD5 neq ""}
					| 
					{if $Allow_Friends eq 1}
						<a href ="{$user_add_remove}">{$Friend_Text} {#PLIGG_Visual_LS_My_Friends#}</a>
					{/if}
				{/if}
			</span>
			<br/>
		
			{if $link_category neq ""}
				<span id="ls_category-{$link_shakebox_index}"><b><a href="{$category_url}" style='text-decoration:none;'>{#PLIGG_MiscWords_Category#}</a></b>: <a href="{$category_url}">{$link_category}</a></span>
			{else}									
				<br/>								 {/if}
			{/if}
Reply With Quote
  #5 (permalink)  
Old 08-31-2007, 09:47 AM
AnAlienHolakres3's Avatar
Pligg Donor/Coder
 
Join Date: Jul 2007
Location: Prague
Posts: 116
Send a message via ICQ to AnAlienHolakres3
Well, there is the rest of previous link_summary.tpl file. 90% done.

Code:
		
			{if $enable_tags eq 'true'}
				{if $tags ne ''}
					| 
					<span id="ls_tags-{$link_shakebox_index}"><b><a href="{$URL_tagcloud}" title="Tags" style='text-decoration: none;'>{#PLIGG_Visual_Tags_Link_Summary#}</a></b>: 
					{section name=thistag loop=$tag_array}
						<a href="{$tags_url_array[thistag]}" style='text-decoration: none;'>{$tag_array[thistag]}</a>
					{/section}
					</span> 
				{/if}
			{/if}			
			{if $advertising_banner neq 1}	
			<span id="ls_adminlinks-{$link_shakebox_index}" style="display:none">
				{if $isadmin eq "yes"}
					<span id="ls_admin_links-{$link_shakebox_index}">
						<br /><a href="{$story_edit_url}">{#PLIGG_Visual_LS_Admin_Edit#}</a>
						<br /><a href="{$story_admin_url}">{#PLIGG_Visual_LS_Admin_Status#}</a>
					</span>
				{else}
					{if $user_logged_in eq $link_submitter}
						<span id="ls_user_edit_links-{$link_shakebox_index}"><br /><a href="{$story_edit_url}">{#PLIGG_Visual_LS_Admin_Edit#}</a></span>
					{/if}
				{/if}
			</span>		{/if}
			
		</div>

		{if $viewtype neq "short"}
		    <span class="news-body-text">
		  		<span id="ls_contents-{$link_shakebox_index}">
			  		{checkActionsTpl location="tpl_link_summary_pre_story_content"}
					{if $show_content neq 'FALSE'}
						{$story_content}
					{/if}			{if $advertising_banner neq 1}
					{if $Enable_Extra_Field_1 eq 1}{if $link_field1 neq ""}<br/><b>{$Field_1_Title}:</b> {$link_field1}{/if}{/if}
					{if $Enable_Extra_Field_2 eq 1}{if $link_field2 neq ""}<br/><b>{$Field_2_Title}:</b> {$link_field2}{/if}{/if}
					{if $Enable_Extra_Field_3 eq 1}{if $link_field3 neq ""}<br/><b>{$Field_3_Title}:</b> {$link_field3}{/if}{/if}
					{if $Enable_Extra_Field_4 eq 1}{if $link_field4 neq ""}<br/><b>{$Field_4_Title}:</b> {$link_field4}{/if}{/if}
					{if $Enable_Extra_Field_5 eq 1}{if $link_field5 neq ""}<br/><b>{$Field_5_Title}:</b> {$link_field5}{/if}{/if}
					{if $Enable_Extra_Field_6 eq 1}{if $link_field6 neq ""}<br/><b>{$Field_6_Title}:</b> {$link_field6}{/if}{/if}
					{if $Enable_Extra_Field_7 eq 1}{if $link_field7 neq ""}<br/><b>{$Field_7_Title}:</b> {$link_field7}{/if}{/if}
					{if $Enable_Extra_Field_8 eq 1}{if $link_field8 neq ""}<br/><b>{$Field_8_Title}:</b> {$link_field8}{/if}{/if}
					{if $Enable_Extra_Field_9 eq 1}{if $link_field9 neq ""}<br/><b>{$Field_9_Title}:</b> {$link_field9}{/if}{/if}
					{if $Enable_Extra_Field_10 eq 1}{if $link_field10 neq ""}<br/><b>{$Field_10_Title}:</b> {$link_field10}{/if}{/if}
					{if $Enable_Extra_Field_11 eq 1}{if $link_field11 neq ""}<br/><b>{$Field_11_Title}:</b> {$link_field11}{/if}{/if}
					{if $Enable_Extra_Field_12 eq 1}{if $link_field12 neq ""}<br/><b>{$Field_12_Title}:</b> {$link_field12}{/if}{/if}
					{if $Enable_Extra_Field_13 eq 1}{if $link_field13 neq ""}<br/><b>{$Field_13_Title}:</b> {$link_field13}{/if}{/if}
					{if $Enable_Extra_Field_14 eq 1}{if $link_field14 neq ""}<br/><b>{$Field_14_Title}:</b> {$link_field14}{/if}{/if}
					{if $Enable_Extra_Field_15 eq 1}{if $link_field15 neq ""}<br/><b>{$Field_15_Title}:</b> {$link_field15}{/if}{/if} 		  			
					{if $pagename neq "story"} <a href="{$story_url}">{#PLIGG_Visual_Read_More#}</a> &raquo; {/if}<br /> 					{/if}
		  		</span>
		    </span>
	  	{/if}			
	{if $advertising_banner neq 1}
	    <span class="news-details">
	    	<span id="ls_comments_url-{$link_shakebox_index}">
	    		{if $story_comment_count eq 0}
					<img class="commentsAlfa" src="{$my_pligg_base}/templates/{$the_template}/images/comment.png" align="absmiddle"/>
	    			<a href="{$story_url}" class="comments">{#PLIGG_MiscWords_Discuss#}</a> &nbsp;
	    		{/if}
	    		{if $story_comment_count eq 1}
					<img src="{$my_pligg_base}/templates/{$the_template}/images/comment_yellow.gif" align="absmiddle"/>
	    			<a href="{$story_url}" class="comments2">{$story_comment_count} {#PLIGG_MiscWords_Comment#}</a> &nbsp;
	    		{/if}
	    		{if $story_comment_count gt 1}
					<img src="{$my_pligg_base}/templates/{$the_template}/images/comment_yellow.gif" align="absmiddle"/>
	    			<a href="{$story_url}" class="comments2">{$story_comment_count} {#PLIGG_MiscWords_Comments#}</a> &nbsp;
	    		{/if}
	    	</span>  
	    	
			{if $Enable_AddTo eq 1}
				<img src="{$my_pligg_base}/templates/{$the_template}/images/add.gif" align="absmiddle"/>
				<a href="javascript://" onclick="var replydisplay=document.getElementById('addto-{$link_shakebox_index}').style.display ? '' : 'none';document.getElementById('addto-{$link_shakebox_index}').style.display = replydisplay;"> {#PLIGG_Visual_LS_AddThisLinkTo#}</a>&nbsp;
			{/if}
				
			{if $user_logged_in neq ""}
				<iframe height="0px;" width="0px;" frameborder="0" name="add_stories"></iframe>
				{if $link_mine eq 0}
					<span><img src="{$my_pligg_base}/templates/{$the_template}/images/save_link.png" align="absmiddle" /> <a target="add_stories" href="{$user_url_add_links}" onclick="show_hide_user_links(document.getElementById('stories-{$link_shakebox_index}'));">{#PLIGG_MiscWords_Save_Links_Save#}</a>&nbsp;
				{else}
					<span><img src="{$my_pligg_base}/templates/{$the_template}/images/user_disable.png" align="absmiddle" /> <a target="add_stories" href="{$user_url_remove_links}" onclick="show_hide_user_links(document.getElementById('stories-{$link_shakebox_index}'));">{#PLIGG_MiscWords_Save_Links_Remove#}</a>&nbsp;
				{/if}
					</span>
					<span id="stories-{$link_shakebox_index}" style="display:none;"> &raquo; {#PLIGG_MiscWords_Save_Links_Success#} <a href="{$user_url_saved}">{#PLIGG_MiscWords_Save_Links_Go_To_Saved#}</a></span> &nbsp;
			{/if}				
	
			{if $Enable_Recommend eq 1}
				<span id="ls_recommend-{$link_shakebox_index}">
					<img src="{$my_pligg_base}/templates/{$the_template}/images/email.png" align="absmiddle"/> <a href="javascript://" onclick="show_recommend({$link_shakebox_index}, {$link_id}, '{$instpath}');"> {#PLIGG_Visual_Recommend_Link_Text#}</a> &nbsp;
				</span> 
			{/if}		
				
			{if $link_shakebox_currentuser_votes eq 0 && $link_shakebox_currentuser_reports eq 0}
				<span id="xreport-{$link_shakebox_index}"> <img src="{$my_pligg_base}/templates/{$the_template}/images/error.png" align="absmiddle" /> <a href="javascript:{$link_shakebox_javascript_report}">{#PLIGG_Visual_Vote_Bury#}</a></span>
			{/if}
 		
			{if $Enable_AddTo eq 1}
				<span id="addto-{$link_shakebox_index}" style="display:none"><br />{#PLIGG_Visual_LS_AddTo#}
					&nbsp;&nbsp;<a title="submit '{$title_short}' to del.icio.us" href="http://del.icio.us/post" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url={$enc_url}&amp;title={$enc_title_short}', '{#PLIGG_Visual_LS_Delicious#}','toolbar=no,width=700,height=400'); return false;"><img src="{$my_base_url}{$my_pligg_base}/templates/{$the_template}/images/delicious.png" border="0" alt="submit '{$title_short}' to del.icio.us" /></a>
					&nbsp;&nbsp;<a title="submit '{$title_short}' to digg" href="http://digg.com/submit?phase=2&amp;url={$enc_url}&amp;title={$title_short}&amp;bodytext={$story_content}"><img src="{$my_base_url}{$my_pligg_base}/templates/{$the_template}/images/digg.png" border="0" alt="submit '{$title_short}' to digg" /></a>
					&nbsp;&nbsp;<a title="submit '{$title_short}' to reddit" href="http://reddit.com/submit?url={$enc_url}&amp;title={$title_short}"><img src="{$my_base_url}{$my_pligg_base}/templates/{$the_template}/images/reddit.gif" border="0" alt="submit '{$title_short}' to reddit" /></a>
					&nbsp;&nbsp;<a title="submit '{$title_short}' to simpy" href="http://www.simpy.com/simpy/LinkAdd.do?href={$enc_url}&amp;title={$title_short}"><img src="{$my_base_url}{$my_pligg_base}/templates/{$the_template}/images/simpy.png" border="0" alt="submit '{$title_short}' to simpy" /></a>
					&nbsp;&nbsp;<a title="submit '{$title_short}' to yahoo" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u={$enc_url}&amp;title={$title_short}"><img src="{$my_base_url}{$my_pligg_base}/templates/{$the_template}/images/yahoomyweb.png" border="0" alt="submit '{$title_short}' to yahoo" /></a>
					&nbsp;&nbsp;|&nbsp;&nbsp; <a href="javascript:bookmarksite('{$title_url}', '{$enc_url}')">{#PLIGG_Visual_LS_Fav_Book#}</a>&nbsp;&nbsp;
				</span>
			{/if}	
				
			{if $Enable_Recommend eq 1}
				{if $Recommend_Type eq 1}
					<span id="emailto-{$link_shakebox_index}" style="display:none"></span>
				{/if}
			{/if}			
	    </span>		
						{/if} {if $advertising_banner eq 1}<br/>{/if}
	</div>	
</div>
Uff that was really dirty yeah? The good thing is if you make any mistake its not so big problem - you will see it when you reload page (our special advertising ling would have comments or tags or category or edit menu....whatever). The correction is pretty simple.

I hope you have noticed that in this file we created a new css class for designing our special link. Tha name is news-upcomingAdsense. So the last thing to do is edit your main. css file in your templates/yget/ folder. If you want the same design as I have, add this code:
PHP Code:
.news-upcomingAdsense {background:url("../images/vote_adsense.png"no-repeat 0 0;position:absolute;top:3px;left:0px;width:54px;text-align:center;font-size:85%;margin:0;padding:0;list-style:none}
.
news-upcomingAdsense span li:hover{background:url("../images/vote_hoverAdsense.png"no-repeat 0 0width54px;font-weight:normal !important;_margin-top:-8px}
.
news-upcomingAdsense span li {font-weight:normal !important  
Images you have probably own, so just rename it and copy to your images folder. If somebody is interested in my special advertising ling images, so there they are:
.
Reply With Quote
  #6 (permalink)  
Old 08-31-2007, 09:52 AM
AnAlienHolakres3's Avatar
Pligg Donor/Coder
 
Join Date: Jul 2007
Location: Prague
Posts: 116
Send a message via ICQ to AnAlienHolakres3
Feel free to customize them. I hope you made it and it works for you. You should be also able to edit this addon to satisfy your needs. Thats end....emmm..no. I´ve got another advertising improvement but maybye another time. Enjoy this and if you have any questions, comments let me know.

UPDATE
I found a little bug in sidebar stories after implementing this addon - when you select specific category, you probably have in sidebar information about TOP in today or TOP last week etc. Beceause of random votes there can be also our special advertising link. Without any text of course, just icon and count of votes. Thats a problem. Solution:

I would like to say something like ...veery easy, just put {if $advertising_banner neq 1} into link_summary.tpl file and it is done, but unfortunenately this smarty which is defined in link.php is not working (dont know why, probably it is not called in link.php when only sidemodule loaded is). One way or another I found ..of course dirty...solution, i manage to did some another smarty working. Instructions:

1) open link.php in your ../libs/ folder. Press ctrl+f and search for $smarty->assign('link_shakebox_votes', $this->votes);. Enter and on the next line add this code:

PHP Code:
 //==========================================================
      //adsense veery dirty bug solution in sidebar
        
if ($this->id == 100) {
          
$enableFilter true;  
        }else  { 
$enableFilter false; }
        
$smarty->assign('advertising_side',$enableFilter); 
      
//========================================================== 
Save. Now open sidebar_stories.tpl in your ../templates/yget/ folder.
Replace the whole code with:

PHP Code:
{if $advertising_side neq 1}
{if 
$Voting_Method eq 1}
    <
div class="sstories">
        <
span class="count_total"><a href="{$story_url}">{$link_shakebox_votes}</a></span>
    </
div>
{/if}

<
a href="{$story_url}" class="switchurl">{$title_short}</a>
{/if} 
All right, thats it. I hope now it will run smoothly

UPDATE 2 from 02/09/2007
Ok there is the situation: If you have many links to show and user is supposed to click on "2,3..." page you certainly noticed that our special link can be located between page 1-3 (it depends how much pages are needed). And that ´s definitely problem. This situations is beceause position of our link is RANDOM as described before.So i assume we need to change calculation of random link_published data and link_votes to be random only on the first viewed page. I´ve customized some sql queries and everything what you have to do is replace code in link.php in yours /libs/ folder:

1a) Original Code

Code:
        //1b) select the oldest link (the last but one) 
        $oldest_link = $db->get_var("SELECT min(link_published_date) FROM " . table_links . " WHERE link_category IN (" . $catid .  
        ") OR link_category IN (SELECT category_id FROM "  . table_categories . " WHERE category_parent = " . $catid .") AND link_published_date > 0 AND link_id NOT IN (100) AND link_status='PUBLISHED' ;");
replace with:
PHP Code:
 //1b) select the oldest link date on the first loaded page in (sub) category
        
$oldest_link $db->get_var("SELECT min(link_published_date) FROM  (SELECT * FROM " table_links .
        
" ORDER BY link_published_date DESC LIMIT "$page_size .") AS page_highest_links
          WHERE link_category IN (" 
$catid ") OR link_category IN (SELECT category_id FROM "  table_categories 
        
" WHERE category_parent = " $catid .") AND link_published_date > 0 AND link_id NOT IN (100) AND link_status='PUBLISHED' ;"); 
1d) Original code:

Code:
    //1d) select the oldest link (the last but one) 
        $less_votes = $db->get_var("SELECT min(link_votes) FROM " . table_links . " WHERE link_category IN (" . $catid .  
        ") OR link_category IN (SELECT category_id FROM "  . table_categories . " WHERE category_parent = " . $catid .") AND link_votes > 0 AND link_id NOT IN (100) AND link_status='PUBLISHED' ;");
Replace with:

PHP Code:
        //1d) select the less vote link on the first loaded page in (sub) category
        
$less_votes $db->get_var("SELECT min(link_votes) FROM (SELECT * FROM " table_links 
        
" ORDER BY link_votes DESC LIMIT "$page_size .") AS page_highest_links 
          WHERE link_category IN (" 
$catid ") OR link_category IN (SELECT category_id FROM "  table_categories .
        
" WHERE category_parent = " $catid .") AND link_votes > 0 AND link_id NOT IN (100) AND link_status='PUBLISHED' ;"); 
2b) Original code:
Code:
//2b) select the oldest link 
            $oldest_link = $db->get_var("SELECT min(link_published_date) FROM " . table_links . " WHERE link_published_date > 0 AND link_id NOT IN (100) AND link_status='PUBLISHED' ;" );
Replace with:
PHP Code:
//2b) select the oldest link on the first page
            
$oldest_link $db->get_var("SELECT min(link_published_date) FROM (SELECT * FROM " table_links 
            
" ORDER BY link_published_date DESC LIMIT "$page_size .") AS page_highest_links
              WHERE link_published_date > 0 AND link_id NOT IN (100) AND link_status='PUBLISHED' ;" 
); 
And finally 2d)Original code:
Code:
 //2d) select the oldest link (the last but one) 
        $less_votes = $db->get_var("SELECT min(link_votes) FROM " . table_links . " WHERE link_votes > 0 AND link_id NOT IN (100) AND link_status='PUBLISHED' ;");
Replace with:
PHP Code:
 //2d) select link with less votes on the first page
        
$less_votes $db->get_var("SELECT min(link_votes) FROM (SELECT * FROM " table_links 
        
" ORDER BY link_votes DESC LIMIT "$page_size .") AS page_highest_links 
          WHERE link_votes > 0 AND link_id NOT IN (100) AND link_status='PUBLISHED' ;"
); 
That´s all. Now save the file,upload and 2times refresh the page. I hope that this is not the second Microsoft Update

Last edited by AnAlienHolakres3; 09-02-2007 at 07:36 AM. Reason: Bug found
Reply With Quote
  #7 (permalink)  
Old 08-31-2007, 11:59 AM
New Pligger
 
Join Date: Jul 2007
Posts: 19
very awesome. thanks man!
Reply With Quote
  #8 (permalink)  
Old 09-04-2007, 01:43 PM
Casual Pligger
 
Join Date: Jan 2007
Posts: 43
I agree, awesome work! That's what I was looking for. Many tanks!!
Reply With Quote
  #9 (permalink)  
Old 09-04-2007, 03:59 PM
Casual Pligger
Pligg Version: 995
Pligg Template: Yget
 
Join Date: Sep 2006
Posts: 59
Thanks a lot for the inspiration. Based on your concept I implemented my own solution, which did not require any database modification.
Reply With Quote
  #10 (permalink)  
Old 09-20-2007, 12:30 PM
Casual Pligger
 
Join Date: Aug 2007
Posts: 92
Quote:
Originally Posted by Dubai View Post
Thanks a lot for the inspiration. Based on your concept I implemented my own solution, which did not require any database modification.
Please be so kind to show us your own solution!

Thanks.

D.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wistie Column Changes Tutorial Yankidank Questions and Comments 12 11-27-2009 04:12 PM
Pligg 1.0 > RSS Importer > replace special character martinjunker Questions and Comments 0 05-29-2009 09:52 AM
Special Characters error in title url freakblue Questions and Comments 3 09-19-2008 03:50 PM
Special character problems in RSS and mail subject ditto Questions and Comments 8 04-22-2008 04:28 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