January 4th, 2008phpLD Better Display URL

Most phpLD templates show the url of the listing along with the title and description. In the default template it looks like this:

rakCha Directory - http://www.rakcha.com/
rakCha premium directory. - [Read more]

This is fine when the url is the domain name. However listings may link to internal pages and the url can be very long and it is no longer convenient to show the whole url. Example:

Painting Directory - http://www.enquira.com/arts-humanities/painting/
enQuira paintings links and resources. - [Read more]

Sometimes the internal link is even longer than this and can include many parameters and can break the template. The proposed solution is to always display only the main url in the display url field, like this:

Painting Directory - http://www.enquira.com
enQuira paintings links and resources. - [Read more]

To implement this you should replace

<span class="url">- {$link.URL|escape|trim}

BY

<span class="url">- 
{assign var="parsed_url" value=$link.URL|escape|trim|parse_url}
 {$parsed_url.host}

in link.tpl

Make sure NOT to replace the instance of {$link.URL|escape|trim} in the actual URL (href=”{$link.URL|escape|trim}”)

Also, in some templates the featured links are implemented in a separate file (like flink.tpl), you should do the same thing in that file.

With this MOD, your article pages urls will contain the title of the article for better search engine optimization.

1 in .htaccess
FIND

##Article Page Rewrite
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-l
   RewriteRule (.*)articles/article-(.*)\.htm[l]?$ article.php [QSA,NC]

REPLACE BY

##Article Page Rewrite
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-l
   RewriteRule (.*)articles/(.*)\.html$ article.php [NC,QSA,L]

If you have installed the mod for seo friendly details pages, please place this code above the rewrite rules for the details pages which begin with

##Details Link Page Rewrite

2. in /article.php
FIND

preg_match ('#(.*)article(_|-)(\d+)\.htm[l]?$#i', request_uri(), $matches);

REPLACE BY

preg_match('#articles/(.*)(_|-)(\d+)\.htm[l]?$#i',request_uri(),$matches);

in /templates/your_template/articlelink.tpl
FIND

article-{$article.ID}.html

REPLACE BY

{$article.TITLE|replace:" ":"-"}-{$article.ID}.html

August 23rd, 2007phpLD Custom Category Titles

If you want to customize the titles of the categories pages and not limit it to the name of the category you can use the following modification.
Example:
Category: Internet
Custom Title: Web resources.

Category: Employment
Custom Title: Find you next job

1.

In phpMyadmin, run the following mysql query:

ALTER TABLE `PLD_CATEGORY` ADD `CUSTOM_NAME` TEXT NULL ;

2.

OPEN /templates/Code/admin/dir_categs_edit.tpl

FIND:

{if $symbolic ne 1}
      <tr>

BEFORE THAT, ADD:

<tr>
<td class="label"><label for="CUSTOM_NAME">
Custom Name:</label></td>
<td class="smallDesc">
<input type="text" id="CUSTOM_NAME" name="CUSTOM_NAME" 
 value="{$CUSTOM_NAME|escape|trim}" class="text" />      
</td>
</tr>

3.

OPEN /admin/dir_categs.php

FIND

//Determine columns
$columns = array ('TITLE' => _L('Title'), 'TITLE_URL' => _L('URL Title'),
'DESCRIPTION' => _L('Description'), 'PARENT' => _L('Parent'),
'SYMBOLIC' => _L('Type'), 'STATUS' => _L('Status'),
'HITS' => _L('Hits'), 'DATE_ADDED' => _L('Date Added'));

REPLACE BY

//Determine columns
$columns = array ('TITLE' => _L('Title'), 'TITLE_URL' => _L('URL Title'),
'CUSTOM_NAME' => _L('Custom Name'), 'DESCRIPTION' => _L('Description'),
'PARENT' => _L('Parent'), 'SYMBOLIC' => _L('Type'), 'STATUS' => _L('Status'),
 'HITS' => _L('Hits'), 'DATE_ADDED' => _L('Date Added'));

4.
To add the custom category name in the page title or the body of the page, ADD {$category.CUSTOM_NAME|escape|trim}
to the appropriate template file (header.tpl, top_bar.tpl, main.tpl, …)

With this mod you can add two new payment plans, 1 featured we will call Featured+ and one regular, we call Regular+. You can adapt this tutorial to add as many payment plans as you would like to.

1. In this step you should add two rows in the PLD_CONFIG. You can use one of the following two methods.

Method 1: run the following Mysql query in phpMyadmin:

INSERT INTO `PLD_CONFIG` (`ID`, `VALUE`) VALUES
 ('PAY_NORMAL_ADV', '20'), ('PAY_FEATURED_ADV', '50');

Here 20 and 50 are the prices of the different plans, either change them before running the query or can just edit them in the admin panel when you are done adding the MOD.

Method 2:
in include/tables.php
FIND:

array ('ID' => 'PAY_NORMAL', 'VALUE' => '0'),
array ('ID' => 'PAY_FEATURED', 'VALUE' => '0'),
array ('ID' => 'PAY_RECPR', 'VALUE' => '0'),

REPLACE BY:

array ('ID' => 'PAY_NORMAL', 'VALUE' => '0'),
array ('ID' => 'PAY_FEATURED', 'VALUE' => '0'),
array ('ID' => 'PAY_NORMAL_ADV', 'VALUE' => '0'),
array ('ID' => 'PAY_FEATURED_ADV', 'VALUE' => '0'),
array ('ID' => 'PAY_RECPR', 'VALUE' => '0'),

Now rerun the installer by pointing the browser to /install/index.php. You might have to put that file back if you removed it or renamed it. You should also set the writing permissions of /include/config.php.
Now that the new fields are added to the database, remove the install script.

2. in admin/conf_options.php

FIND:

array ('ID'            => 'PAY_NORMAL',
         'NAME'          => _L('Regular price'),
         'DESCRIPTION'   => _L('Unit price for regular links...'),
         'CONFIG_GROUP'  => '9',
         'TYPE'          => 'NUM',
         'REQUIRED'      => '1'),
array ('ID'            => 'PAY_FEATURED',
         'NAME'          => _L('Featured price'),
         'DESCRIPTION'   => _L('Unit price for featured links...'),
          'CONFIG_GROUP'  => '9',
          'TYPE'          => 'NUM',
          'REQUIRED'      => '1'),

REPLACE BY:

array ('ID'            => 'PAY_NORMAL_ADV',
         'NAME'          => _L('Regular price +'),
         'DESCRIPTION'   => _L('Unit price for regular links+ ...'),
         'CONFIG_GROUP'  => '9',
         'TYPE'          => 'NUM',
         'REQUIRED'      => '1'),
array ('ID'            => 'PAY_FEATURED_ADV',
         'NAME'          => _L('Featured price +'),
         'DESCRIPTION'   => _L('Unit price for featured links+ ...'),
         'CONFIG_GROUP'  => '9',
         'TYPE'          => 'NUM',
         'REQUIRED'      => '1'),
array ('ID'            => 'PAY_NORMAL',
         'NAME'          => _L('Regular price'),
         'DESCRIPTION'   => _L('Unit price for regular links...'),
         'CONFIG_GROUP'  => '9',
         'TYPE'          => 'NUM',
         'REQUIRED'      => '1'),
array ('ID'            => 'PAY_FEATURED',
         'NAME'          => _L('Featured price'),
         'DESCRIPTION'   => _L('Unit price for featured links...'),
         'CONFIG_GROUP'  => '9',
         'TYPE'          => 'NUM',
         'REQUIRED'      => '1'),

3. in submit.php

FIND:

if (FTR_ENABLE == 1 && PAY_FEATURED > 0)
      $price['featured'] = PAY_FEATURED;
   if (PAY_NORMAL > 0)
   {
      $price['normal'] = PAY_NORMAL;
      if (PAY_ENABLE_FREE)
         $price['free'] = 0;
   }

REPLACE BY:

if (FTR_ENABLE == 1 && PAY_FEATURED > 0)
      $price['featured'] = PAY_FEATURED;
  
   if (FTR_ENABLE == 1 && PAY_FEATURED_ADV > 0)
      $price['featured_adv'] = PAY_FEATURED_ADV;

   if (PAY_NORMAL > 0)
   {
      $price['normal'] = PAY_NORMAL;
      if (PAY_ENABLE_FREE)
         $price['free'] = 0;
   }
      if (PAY_NORMAL_ADV > 0)
   {
      $price['normal_adv'] = PAY_NORMAL_ADV;
   }

FIND:

switch (strtolower ($link_type))
      {
         case 'free' :
            $data['NOFOLLOW'] = 1;
            break;
         case 'featured' :
            $data['FEATURED'] = 1;
            break;
         default :
            break;
      }

REPLACE BY:

switch (strtolower ($link_type))
      {
         case 'free' :
            $data['NOFOLLOW'] = 1;
            break;
         case 'featured' :
            $data['FEATURED'] = 1;
            break;
         case 'featured_adv' :
            $data['FEATURED'] = 1;
            break;			
         default :
            break;
      }

4. in payment.php

FIND:

if (FTR_ENABLE == '1' && PAY_FEATURED > 0)
   $price[$link_type_int['featured']] = PAY_FEATURED;

if (PAY_NORMAL > 0)
{
   $price[$link_type_int['normal']] = PAY_NORMAL;
   if (PAY_ENABLE_FREE)
      $price[$link_type_int['free']] = 0;
}

REPLACE BY:

if (FTR_ENABLE == '1' && PAY_FEATURED > 0)
   $price[$link_type_int['featured']] = PAY_FEATURED;

if (FTR_ENABLE == '1' && PAY_FEATURED_ADV > 0)
   $price[$link_type_int['featured_adv']] = PAY_FEATURED_ADV;   

if (PAY_NORMAL > 0)
{
   $price[$link_type_int['normal']] = PAY_NORMAL;
   if (PAY_ENABLE_FREE)
      $price[$link_type_int['free']] = 0;
}

if (PAY_NORMAL_ADV > 0)
{
   $price[$link_type_int['normal_adv']] = PAY_NORMAL_ADV;
}

5. in include/constants.php
FIND:

$link_type_int   = array ( 'none' => 0, 'free' => 1, 'normal' => 2,
                        'reciprocal' => 3, 'featured' => 4);
$link_type_str=array ( 0 => _L('None'), 1 => _L('Free'), 2 => _L('Normal'),
                     3 => _L('Reciprocal'), 4 => _L('Featured'));

REPLACE BY:

$link_type_int   = array ( 'none' => 0, 'free' => 1, 'normal' => 2,
              'reciprocal' => 3, 'featured' => 4, 'normal_adv' => 5,
              'featured_adv' => 6);
$link_type_str   = array ( 0 => _L('None'), 1 => _L('Free'),
                  2 => _L('Normal'), 3 => _L('Reciprocal'),
                  4 => _L('Featured'), 5 => _L('Normal+'),
                  6 => _L('Featured+'));

6. in include/functions.php
FIND:

function determine_link_type($type = 0)
{
   if (!preg_match ('`^[\d]+$`', $type))
      return false;

   $type = ($type < 0 || $type > 6 ? 0 : intval ($type));

   switch ($type) {
      case 4  :
         $return = 'featured';
         break;
      case 3  :
         $return = 'reciprocal';
         break;
      case 2  :
         $return = 'normal';
         break;
      case 1  :
         $return = 'free';
         break;
      case 0  :
      default :
         $return = 'none';
         break;
   }

   return (!empty ($return) ? $return : false);
}

REPLACE BY

function determine_link_type($type = 0)
{
   if (!preg_match ('`^[\d]+$`', $type))
      return false;

   $type = ($type < 0 || $type > 6 ? 0 : intval ($type));

   switch ($type) {
      case 6  :
         $return = 'featured_adv';
         break;
      case 5  :
         $return = 'normal_adv';
         break;
      case 4  :
         $return = 'featured';
         break;
      case 3  :
         $return = 'reciprocal';
         break;
      case 2  :
         $return = 'normal';
         break;
      case 1  :
         $return = 'free';
         break;
      case 0  :
      default :
         $return = 'none';
         break;
   }

   return (!empty ($return) ? $return : false);
}

We are almost done, we only need to modify the submit form to show the additional payment plans.

in submit.tpl
FIND

{if $price.featured}

ABOVE that, ADD:

{if $price.featured_adv}
<tr><td>
<input type="radio" name="LINK_TYPE" value="featured_adv"
            {if $LINK_TYPE eq 'featured_adv'}checked="true"{/if}>
            {l}Featured links +{/l}
</td><td>
{$smarty.const.HTML_CURRENCY_CODE}{$price.featured_adv}
</td>
</tr>
{/if}

FIND

{if $price.normal gt 0}

ABOVE that, ADD:

{if $price.normal_adv gt 0}
<tr>
   <td><input type="radio" name="LINK_TYPE" value="normal_adv"
         {if $LINK_TYPE eq 'normal_adv'}checked="true"{/if}>
         {l}Regular links +{/l}
   </td>
   <td>{$smarty.const.HTML_CURRENCY_CODE}{$price.normal_adv}
   </td>
</tr>
{/if}

You are done! If you are combining this with the deep links mod, you should place onclick="regular();";, onclick="featured();";, onclick="no_deeplinks();"; in the appropriate radio buttons.
Below is the javascript needed

{literal}
<script language="JavaScript">
function setVisibility(id, visibility) {
document.getElementById(id).style.display = visibility;
}
function featured(){
setVisibility('field1_title', '');
setVisibility('field1_url', '');
setVisibility('field2_title', '');
setVisibility('field2_url', '');
setVisibility('field3_title', '');
setVisibility('field3_url', '');
setVisibility('field4_title', '');
setVisibility('field4_url', '');
setVisibility('field5_title', '');
setVisibility('field5_url', '');
}
function regular(){
setVisibility('field1_title', '');
setVisibility('field1_url', '');
setVisibility('field2_title', '');
setVisibility('field2_url', '');
setVisibility('field3_title', '');
setVisibility('field3_url', '');
setVisibility('field4_title', 'none');
setVisibility('field4_url', 'none');
setVisibility('field5_title', 'none');
setVisibility('field5_url', 'none');
}
function no_deeplinks(){
setVisibility('field1_title', 'none');
setVisibility('field1_url', 'none');
setVisibility('field2_title', 'none');
setVisibility('field2_url', 'none');
setVisibility('field3_title', 'none');
setVisibility('field3_url', 'none');
setVisibility('field4_title', 'none');
setVisibility('field4_url', 'none');
setVisibility('field5_title', 'none');
setVisibility('field5_url', 'none');
}
</script> 
{/literal}

Please refer to the deep links mod for more details on this. fieldX_title and fieldX_url are the ids of the rows corresponding the deep links fields, as explained in the deeplinks mod.

After installing the contextual deep links mod, we will now modify few admin template files to allow the preview/editing of contextual links from the admin panel.

Files to edit:
admin/dir_approve_links.php,
templates/Core/admin/link_details.tpl,
templates/Core/admin/dir_links_edit.tpl.

First in admin/dir_approve_links.php
FIND:

$columns = array ('TITLE' => _L('Title'),
'URL' => _L('URL'),
'DESCRIPTION' => _L('Description'),
'CATEGORY' => _L('Category'),
'RECPR_URL' => _L('Recpr. Link URL'),
'PAGERANK' => _L('Pagerank'),
'DATE_ADDED' => _L('Date Added'));

REPLACE BY:

$columns = array ('TITLE' => _L('Title') ,
'URL' => _L('URL'), 'TITLE1' => _L('Title1'),
'URL1' => _L('URL1') , 'TITLE2' => _L('Title2'),
'URL2' => _L('URL2') , 'TITLE3' => _L('Title3'),
'URL3' => _L('URL3') ,
'DESCRIPTION1' => _L('DESCRIPTION1'),
'DESCRIPTION2' => _L('DESCRIPTION2') ,
'DESCRIPTION3' => _L('DESCRIPTION3'),
'DESCRIPTION4' => _L('DESCRIPTION4'),
'DESCRIPTION' => _L('Description'),
'CATEGORY' => _L('Category'),
'RECPR_URL' => _L('Recpr. Link URL'),
'PAGERANK' => _L('Pagerank'),
'DATE_ADDED' => _L('Date Added'));

Second, in templates/admin/link_details.tpl
FIND, around line 34:

<tr class="{cycle values="odd,even"}">
<td class="label">Description:</td>
<td class="smallDesc">{$linkInfo.DESCRIPTION|escape|trim}</td>
</tr>

BELOW it, ADD:

<tr class="{cycle values="odd,even"}">
<td class="label">Title1:</td>
<td class="smallDesc">{$linkInfo.TITLE1|escape|trim}
</td>
</tr>

<tr class="{cycle values="odd,even"}">
<td class="label">URL1:</td>
<td class="smallDesc">{$linkInfo.URL1|escape|trim}
</td>
</tr>

<tr class="{cycle values="odd,even"}">
<td class="label">Title2:</td>
<td class="smallDesc">{$linkInfo.TITLE2|escape|trim}
</td>
</tr>

<tr class="{cycle values="odd,even"}">
<td class="label">URL2:</td>
<td class="smallDesc">{$linkInfo.URL2|escape|trim}
</td>
</tr>

<tr class="{cycle values="odd,even"}">
<td class="label">Title3:</td>
<td class="smallDesc">{$linkInfo.TITLE3|escape|trim}
</td>
</tr>

<tr class="{cycle values="odd,even"}">
<td class="label">URL3:</td>
<td class="smallDesc">{$linkInfo.URL3|escape|trim}
</td>
</tr>

<tr class="{cycle values="odd,even"}">
<td class="label">Description 1:</td>
<td class="smallDesc">{$linkInfo.DESCRIPTION1|escape|trim}
</td>
</tr>

<tr class="{cycle values="odd,even"}">
<td class="label">Description 2:</td>
<td class="smallDesc">{$linkInfo.DESCRIPTION2|escape|trim}
</td>
</tr>

<tr class="{cycle values="odd,even"}">
<td class="label">Description 3:</td>
<td class="smallDesc">{$linkInfo.DESCRIPTION3|escape|trim}
</td>
</tr>

<tr class="{cycle values="odd,even"}">
<td class="label">Description 4:</td>
<td class="smallDesc">{$linkInfo.DESCRIPTION4|escape|trim}
</td>
</tr>

FINALLY in templates/admin/dir_links_edit.tpl
FIND, around line 74

$smarty.const.DESCRIPTION_MAX_LENGTH}
         </td>
      </tr>

BELOW it , ADD

<tr>
<td class="label"><label for="TITLE1">
Title1:</label></td>
<td class="smallDesc">
<input type="text" id="TITLE1" name="TITLE1"
 value="{$TITLE1|escape|trim}" class="text" />           
</td>
</tr>
<tr>
<td class="label"><label for="URL1">
URL1:</label></td>
<td class="smallDesc">
<input type="text" id="URL1" name="URL1"
 value="{$URL1|escape|trim}" class="text"/>
</td>
</tr>
      
<tr>
<td class="label"><label for="TITLE2">
Title2:</label></td>
<td class="smallDesc">
<input type="text" id="TITLE2" name="TITLE2"
 value="{$TITLE2|escape|trim}" class="text" />           
</td>
</tr>
<tr>
<td class="label"><label for="URL2">
URL2:</label></td>
<td class="smallDesc">
<input type="text" id="URL2" name="URL2"
 value="{$URL2|escape|trim}" class="text"/>
</td>
</tr>
      
<tr>
<td class="label"><label for="TITLE3">
Title3:</label></td>
<td class="smallDesc">
<input type="text" id="TITLE3" name="TITLE3"
 value="{$TITLE3|escape|trim}" class="text" />           
</td>
</tr>
<tr>
<td class="label"><label for="URL">
URL3:</label></td>
<td class="smallDesc">
<input type="text" id="URL3" name="URL3"
 value="{$URL3|escape|trim}" class="text"/>
</td>
</tr>
      
<tr>
<td class="label"><label for="DESCRIPTION1">
Description 1:</label></td>
<td class="smallDesc">
<input type="text" id="DESCRIPTION1" name="DESCRIPTION1"
 value="{$DESCRIPTION1|escape|trim}" class="text" />           
</td>
</tr>
<tr>
<td class="label"><label for="DESCRIPTION2">
Description 2:</label></td>
<td class="smallDesc">
<input type="text" id="DESCRIPTION2" name="DESCRIPTION2"
 value="{$DESCRIPTION2|escape|trim}" class="text"/>
</td>
</tr>
      
<tr>
<td class="label"><label for="DESCRIPTION3">
Description 3:</label></td>
<td class="smallDesc">
<input type="text" id="DESCRIPTION3" name="DESCRIPTION3"
 value="{$DESCRIPTION3|escape|trim}" class="text" />           
</td>
</tr>
<tr>
<td class="label"><label for="DESCRIPTION4">
Description 4:</label></td>
<td class="smallDesc">
<input type="text" id="DESCRIPTION4" name="DESCRIPTION4"
 value="{$DESCRIPTION4|escape|trim}" class="text"/>
</td>
</tr>

You are done!
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

In this step, we will display the keyword rich description in the details page.

1. in detail.tpl
FIND: around line 36

<tr>
<td class="label">{l}Description{/l}:</td>
</tr>
<td class="smallDesc" align="left">{$DESCRIPTION|escape|trim}</td>

AFTER it, ADD

<tr>
<td  class="label"><strong>Additional Information:</strong></td>
<td class="smallDesc" align="left">
{if $DESCRIPTION1}{$DESCRIPTION1}&nbsp;
{/if}

{if  $TITLE1 && $TITLE1 neq 'http://'}
<a href="{$URL1}" target="_blank" class="title">{$TITLE1}</a>&nbsp; 
{/if}

{ if $DESCRIPTION2}
{$DESCRIPTION2}&nbsp;
{/if}

{if $TITLE2 && $TITLE2 neq 'http://'}
<a href="{$URL2}" target="_blank" class="title">{$TITLE2}</a>&nbsp;  
{/if}

{ if $DESCRIPTION3}
{$DESCRIPTION3}&nbsp;
{/if} 

{ if $TITLE3 && $TITLE3 neq 'http://'}
<a href="{$URL3}" target="_blank" class="title">{$TITLE3}</a>&nbsp;
{/if}

{ if $DESCRIPTION4}&nbsp;
{$DESCRIPTION4}.
{/if}  

</td>
</tr>

2. in /detail.php
FIND:

$data['META_DESCRIPTION'] = $rdata['META_DESCRIPTION'];

BELOW it, ADD:

$data['TITLE1']    = $rdata['TITLE1']; 
$data['URL1']    = $rdata['URL1']; 
$data['TITLE2']    = $rdata['TITLE2']; 
$data['URL2']    = $rdata['URL2']; 
$data['TITLE3']    = $rdata['TITLE3']; 
$data['URL3']    = $rdata['URL3']; 
$data['DESCRIPTION1']    = $rdata['DESCRIPTION1']; 
$data['DESCRIPTION2']    = $rdata['DESCRIPTION2']; 
$data['DESCRIPTION3']    = $rdata['DESCRIPTION3']; 
$data['DESCRIPTION4']    = $rdata['DESCRIPTION4'];

By Step 3, your directory is set to accept contextual deep links and display them in a keyword rich paragraph in the details page. The last step, we will modify the admin template files to allow preview/editing of the contextual deep links from the admin panel.

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

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!

This allows you to add an additional field associated with a phpld link. This can be used, for instance, to add a field called “PHONE” when the submitters input his phone number. This was used in the deeplinks mod.

1. ADD the additional field (FIELD1) to the database:
The easiest way to do this is by running the sql query below in phpmyadmin

ALTER TABLE `PLD_LINK` ADD `FIELD1` TEXT NULL ;

2. The second step is to modify the submit form to add an input field with the same name “FIELD1″:

<tr>
  <td class="label">FIELD 1</td>
  <td class="field"><input type="text" name="FIELD1"
  value="{$FIELD1|escape|trim}"
 size="40" maxlength="255" class="text"/></td>
</tr>

Now the additional field is available in the database and can be filled from the submit form. Until now, the additional field is not visible from the admin panel. To make it accessible to the admin so it can be viewed or edited you will have to modify the following:

First, in admin/dir_approve_links.php

$columns = array ('TITLE' => _L('Title'),
'URL' => _L('URL'),
'DESCRIPTION' => _L('Description'),
'CATEGORY' => _L('Category'),
'RECPR_URL' => _L('Recpr. Link URL'),
'PAGERANK' => _L('Pagerank'),
'DATE_ADDED' => _L('Date Added'));

Replace by:

$columns = array ('TITLE' => _L('Title'),
'URL' => _L('URL'),
'DESCRIPTION' => _L('Description'),
'CATEGORY' => _L('Category'),
'RECPR_URL' => _L('Recpr. Link URL'),
'PAGERANK' => _L('Pagerank'),
'FIELD1' => _L('FIELD1'),
'DATE_ADDED' => _L('Date Added'));

Note that we have added the line 'FIELD1' => _L('FIELD1'),

Second, add the code below in templates/admin/link_details.tpl where you want the field to show

<tr class="{cycle values="odd,even"}">
<td class="label">FIELD 1:</td>
<td class="smallDesc">{$linkInfo.FIELD1|escape|trim}
</td>
</tr>

Finally, in templates/admin/dir_links_edit.tpl add the code below where you want to field to show when editing the listing in the admin panel.

<tr>
  <td class="label"><label for="FIELD1">
 FIELD 1:</label></td>
  <td class="smallDesc">
   <input type="text" id="FIELD1" name="FIELD1"
    value="{$FIELD1|escape|trim}" class="text" />           
  </td>
</tr>

Now the additional field can be viewed and edited from the admin panel. However it is not displayed yet to the directory visitor. Usually it will be displayed in the details page of each listing. This is done as follows:

1. in detail.php
Find:

$data['META_DESCRIPTION'] = $rdata['META_DESCRIPTION'];

Below it, add:

$data['FIELD1']    = $rdata['FIELD1'];

2. in detail.tpl, add the code below where you want the additional field to appear:

{$FIELD1|escape|trim}

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