In this step we will modify the submit form to accept additional contextual links for featured listings.
1. create a contextual.js file in the javascript folder (under the directory root) with the following content:

function setVisibility(id, visibility) {
document.getElementById(id).style.display = visibility;
}
function setValue(id, value) {
document.getElementById(id).value = value;
}
function regular(){
setVisibility('contextuallinkspreview', 'none');
setVisibility('contextuallink1', 'none');
setVisibility('contextuallink2', 'none');
setVisibility('contextuallink3', 'none');
setVisibility('contextualtitle1', 'none');
setVisibility('contextualtitle2', 'none');
setVisibility('contextualtitle3', 'none');
setVisibility('contextualdescription1', 'none');
setVisibility('contextualdescription2', 'none');
setVisibility('contextualdescription3', 'none');
setVisibility('contextualdescription4', 'none');

setValue('URL1', '');
setValue('URL2', '');
setValue('URL3', '');
setValue('TITLE1', '');
setValue('TITLE2', '');
setValue('TITLE3', '');
setValue('DESCRIPTION1', '');
setValue('DESCRIPTION2', '');
setValue('DESCRIPTION3', '');
setValue('DESCRIPTION4', '');
setValue('contextual-description', '');
}
function featured(){
setVisibility('contextuallinkspreview', '');
setVisibility('contextuallink1', '');
setVisibility('contextuallink2', '');
setVisibility('contextuallink3', '');
setVisibility('contextualtitle1', '');
setVisibility('contextualtitle2', '');
setVisibility('contextualtitle3', '');
setVisibility('contextualdescription1', '');
setVisibility('contextualdescription2', '');
setVisibility('contextualdescription3', '');
setVisibility('contextualdescription4', '');
}
function reciprocal(){
setVisibility('contextuallinkspreview', 'none');
setVisibility('contextuallink1', 'none');
setVisibility('contextuallink2', 'none');
setVisibility('contextuallink3', 'none');
setVisibility('contextualtitle1', 'none');
setVisibility('contextualtitle2', 'none');
setVisibility('contextualtitle3', 'none');
setVisibility('contextualdescription1', 'none');
setVisibility('contextualdescription2', 'none');
setVisibility('contextualdescription3', 'none');
setVisibility('contextualdescription4', 'none');

setValue('URL1', 'none');
setValue('URL2', 'none');
setValue('URL3', 'none');
setValue('TITLE1', 'none');
setValue('TITLE2', 'none');
setValue('TITLE3', 'none');
setValue('DESCRIPTION1', 'none');
setValue('DESCRIPTION2', 'none');
setValue('DESCRIPTION3', 'none');
setValue('DESCRIPTION4', 'none');
setValue('contextual-description', '');
}


function $(id) {
    return document.getElementById(id) ;
}
function updatePreview() {
    var result = "";

	var part1 = "";
	if ($('DESCRIPTION1').value.length > 0) {
        part1 = $('DESCRIPTION1').value;
    }
	
    var part2 = "";
    if ($('TITLE1').value.length > 0) {
        part2 = " <a href=\"" + $('URL1').value +
       "\" target=\"_blank\">" + $('TITLE1').value + "</a> ";
    }
	
    var part3 = "";
   if ($('DESCRIPTION2').value.length > 0) {
        part3 = $('DESCRIPTION2').value;
    }	

    var part4 = "";
    if ($('TITLE2').value.length > 0) {
        part4 = " <a href=\"" + $('URL2').value +
       "\" target=\"_blank\">" + $('TITLE2').value + "</a> ";
    }

	var part5 = "";
	if ($('DESCRIPTION3').value.length > 0) {
        part5 = $('DESCRIPTION3').value;
    }

    var part6 = "";
    if ($('TITLE3').value.length > 0) {
        part6 = " <a href=\"" + $('URL3').value +
        "\" target=\"_blank\">" + $('TITLE3').value + "</a> ";
    }
	
   var part7 = "";
        if ($('DESCRIPTION4').value.length > 0) {
        part7 = $('DESCRIPTION4').value;
    }	
	
    part8 = "";
   if (part1.length > 0 || part2.length > 0 || 
       part3.length > 0 || part4.length > 0 || 
       part5.length > 0 || part6.length > 0 || 
       part7.length > 0) {
  	part8 = ".";
   }


   result =  part1 + part2 + part3 + part4 +
               part5 + part6 + part7 + part8;

    $('contextual-description').innerHTML = result;
}



function updateField(fieldName, onKeyUp) {
    var elem = $(fieldName) ;
    elem.onkeyup = onKeyUp ;
    elem.onclick = onKeyUp ;
}

function updateContextualPreview() {

    var triggerUpdate = 
          function()  { updatePreview();  } ;

    for(var i=1;i<4;i++) {
        updateField("URL"+i, triggerUpdate) ;
        updateField("TITLE"+i, triggerUpdate) ;
        updateField("DESCRIPTION"+i, triggerUpdate) ;
    }
    updateField("DESCRIPTION"+4, triggerUpdate) ;
}

2. right before in header.tpl, ADD

{* Contextual Deep Links *}
<script type="text/javascript" 
src="{$smarty.const.DOC_ROOT}/javascripts/contextual.js"></script>

3. in submit.tpl
FIND, around line 113:

{l}Limit{/l}: 
<input type="text" name="DESCRIPTION_limit" size="4" 
class="limit_field" readonly="readonly" value="{$DescriptionLimit|trim}" />
</td>
</tr>

AFTER it, ADD

<tr id="contextuallinkspreview"  style="display:none">
<td class="label">Preview<br></td>
<td class="field">
<div class="contextual_preview" style="width:300px;"><br />
<span id="contextual-description"></span><br /><br />
</div>
</td>
</tr>

<tr id="contextualdescription1"  style="display:none">
<td class="label"><strong>Description Part 1:</strong></td>
<td class="field">
<textarea id="DESCRIPTION1" name="DESCRIPTION1" cols="30" rows="2">
</textarea>
</td>
</tr>
				  
<tr id="contextualtitle1"  style="display:none">
<td class="label"><strong>Keyword 1:</strong></td>
<td class="field">
<input type="text" name="TITLE1" value="" size="30" id="TITLE1" />
</td>
</tr>						
									
<tr id="contextuallink1"  style="display:none">
<td class="label"><strong>URL 1:</strong></td>
<td class="field">
<input type="text" name="URL1" value="" size="30" id="URL1" />
</td>
</tr>						
	
<tr id="contextualdescription2"  style="display:none">
<td class="label"><strong>Description Part 2:</strong></td>
<td class="field">
<textarea id="DESCRIPTION2" name="DESCRIPTION2" cols="30" rows="2">
</textarea>
</td>
</tr>							
					
<tr id="contextualtitle2"  style="display:none">
<td class="label"><strong>Keyword 2:</strong></td>
<td class="field">
<input type="text" name="TITLE2" value="" size="30" id="TITLE2" />
</td>
</tr>						

<tr id="contextuallink2"  style="display:none">
<td class="label"><strong>URL 2:</strong></td>
<td class="field">
<input type="text" name="URL2" value="" size="30" id="URL2" />
</td>
</tr>	
		 					
<tr id="contextualdescription3"  style="display:none">
<td class="label"><strong>Description Part 3:</strong></td>
<td class="field">
<textarea id="DESCRIPTION3" name="DESCRIPTION3" cols="30" rows="2">
</textarea>
</td>
</tr>				
		
<tr id="contextualtitle3"  style="display:none">
<td class="label"><strong>Keyword 3:</strong></td>
<td class="field">
<input type="text" name="TITLE3" value="" size="30" id="TITLE3" />
</td>
</tr>						
	
<tr id="contextuallink3"  style="display:none">
<td class="label"><strong>URL 3:</strong></td>
<td class="field">
<input type="text" name="URL3" value="" size="30" id="URL3" />
</td>
</tr>		
		
<tr id="contextualdescription4"  style="display:none">
<td class="label"><strong>Description Part 4:</strong>
</td>
<td class="field">
<textarea id="DESCRIPTION4" name="DESCRIPTION4" cols="30" rows="2">
</textarea>
</td>
</tr>
{literal}
<script type="text/javascript">
<!-- 
updateContextualPreview() ;
-->
</script>
{/literal}

4. Still in submit.tpl,
FIND:

<input type="radio" name="LINK_TYPE" value="featured"
 {if $LINK_TYPE eq 'featured'}checked="true"{/if}>

REPLACE BY:

<input type="radio" name="LINK_TYPE" value="featured"
 {if $LINK_TYPE eq 'featured'}checked="true"{/if}
  onclick="featured();"; >

FIND:

<input type="radio" name="LINK_TYPE" value="normal"
 {if $LINK_TYPE eq 'normal'}checked="true"{/if}>

REPLACE BY:

<input type="radio" name="LINK_TYPE" value="normal"
 {if $LINK_TYPE eq 'normal'}checked="true"{/if}
 onclick="regular();"; >

There are 2 Instances of this, for free and paid regular links.

FIND:

<input type="radio" name="LINK_TYPE" value="reciprocal"
 {if $LINK_TYPE eq reciprocal}checked="true"{/if}>

REPLACE BY:

<input type="radio" name="LINK_TYPE" value="reciprocal"
 {if $LINK_TYPE eq reciprocal}checked="true"{/if}
 onclick="reciprocal();"; >

There are 3 Instances of this, for different types of reciprocal links.

Please continue to step 3.

If you liked this MOD, and want to show your appreciation, you can link back to
rakCha : http://www.rakcha.com
or
enQuira : http://www.enquira.com

This step adds the required fields to the database. In this tutorial we assume that we provide 3 contextual deep links. As a result we will need to divide the paragraph that will contain the deep links into 4 parts.

The fields can be added using one of the following methods:
Method 1:
1. Open include/tables.php
FIND:

'RECPR_EXPIRED' => 'L NOTNULL DEFAULT 0'

REPLACE BY:

'RECPR_EXPIRED' => 'L NOTNULL DEFAULT 0' ,
'TITLE1' => 'C(255) NULL' ,
'URL1' => 'C(255) NULL' ,
'TITLE2' => 'C(255) NULL' ,
'URL2' => 'C(255) NULL' ,
'TITLE3' => 'C(255) NULL' ,
'URL3' => 'C(255) NULL' ,
'DESCRIPTION1'        => 'X2 NULL'  ,
'DESCRIPTION2'        => 'X2 NULL'  ,
'DESCRIPTION3'        => 'X2 NULL'  ,
'DESCRIPTION4'        => 'X2 NULL'

2. Rerun the installer by pointing to install/index.php. You will have to put that file back in the server since you most probably have deleted it or renamed it. You will also have to set writing permissions to include/config.php temporarily. this installer will update the table structure and add the new fields.

3. Remove the file install/index.php and the writing permissions on config.php

Method 2:
You can import the additional fields to the database in phpMyadmin. Create a text file fields.sql with the following content:

ALTER TABLE `PLD_LINK` ADD `TITLE1` TEXT NULL ;
ALTER TABLE `PLD_LINK` ADD `TITLE2` TEXT NULL ;
ALTER TABLE `PLD_LINK` ADD `TITLE3` TEXT NULL ;
ALTER TABLE `PLD_LINK` ADD `URL1` TEXT NULL ;
ALTER TABLE `PLD_LINK` ADD `URL2` TEXT NULL ;
ALTER TABLE `PLD_LINK` ADD `URL3` TEXT NULL ;
ALTER TABLE `PLD_LINK` ADD `DESCRIPTION1` LONGTEXT NULL ;
ALTER TABLE `PLD_LINK` ADD `DESCRIPTION2` LONGTEXT NULL ;
ALTER TABLE `PLD_LINK` ADD `DESCRIPTION3` LONGTEXT NULL ;
ALTER TABLE `PLD_LINK` ADD `DESCRIPTION4` LONGTEXT NULL ;

And import it in phpMyadmin.

Please continue to step 2.

If you liked this MOD, and want to show your appreciation, you can link back to
rakCha : http://www.rakcha.com
or
enQuira : http://www.enquira.com

June 7th, 2007phpld - Sort by Date

This adds another sorting option for directory listings. Using this simple modification you can sort listings by date.
Just 2 files need to be modified: main.tpl and /admin/conf_options.php

in main.tpl,
Locate

After that, ADD

{if $sort eq 'D'} | <span class="sort">{l}Date{/l}</span>{else} | 
<a href="?s=D{if not $smarty.const.ENABLE_REWRITE}&amp;c={$category.ID}
{/if}{if $search}&amp;search={$search}{/if}{if $uid}&amp;uid={$uid}{/if}
{if !empty($p)}&amp;p={$p}{/if}">{l}Date{/mgУ6FS

in conf_options.php
FIND

'OPTIONS'  => array(
                 'P' => _L('PageRank')    ,
                 'H' => _L('Hits')        ,
                 'A' => _L('Alphabetical')
                 ),

REPLACE BY

'OPTIONS'  => array(
                 'D' => _L('Date')    ,
                 'P' => _L('PageRank')    ,
                 'H' => _L('Hits')        ,
                 'A' => _L('Alphabetical')
                 ),

You are done!


© 2007 rakCha resources | Powered by Wordpress | rakCha web directory