PDA

View Full Version : Suggest Link only showing categories


Cristiano Diaz
12-03-2006, 10:06 PM
I have upgraded to version 2.0 and installed the 2.01 patch as well, and I am having a weird problem that I hope is easy to resolve. Previously, when someone would suggest a link, the drop down would show the categories and subcategories. If you went into Suggest Link while in a subcategory, that subcategory would be automatically selected. However, in version 2.0, the dropdown only shows categories. How can I get back the ability to show subcategories too? To see what I mean, go to www.searchsl.com and click on Suggest Link.

Also, as a side note, is it possible to change [ROOT] to something else, such as [CHOOSE] or [HOME]?

Thank you for your help.
Cristiano

Holger Veith
12-03-2006, 11:51 PM
Need this feature too, also in the "suggest categorie"
Is this seo friendly?

John Turner
12-04-2006, 11:10 AM
Hello Cristiano Diaz and welcome.

I offer you to check your suggest-link.tpl file.
by default if you choose subdirectory, page should be reloaded and dropdown must be re-built with subcategories of category which you have chosen prevoisly.

If you want to rename ROOT in the dropdown categories list for suggest-link page you should open your '../suggest-link.php'
***find following code

if($_GET['id_category'] > -1) {
if($_GET['id_category'] != 0) {
$id_parent = $gDirDb->getFirstParent($_GET['id_category'],1);
$temp_category =& $gDirDb->getCategoryById($id_parent);
$s = "<option value=\"{$id_parent}\" {$sel}>[{$temp_category['title']}]</option>";
}
$temp_category =& $gDirDb->getCategoryById($_GET['id_category']);
$s.= "<option value=\"{$_GET['id_category']}\" selected=\"selected\">[{$temp_category['title']}]</option>";
$tree=$s.$tree;
}

*** and replace it with

if($_GET['id_category'] > -1) {
if($_GET['id_category'] != 0) {
$id_parent = $gDirDb->getFirstParent($_GET['id_category'],1);
$temp_category =& $gDirDb->getCategoryById($id_parent);
$temp_category['title'] = ($temp_category['title'] == 'ROOT') ? "HOME" : $temp_category['title'];
$s = "<option value=\"{$id_parent}\" {$sel}>[{$temp_category['title']}]</option>";
}
$temp_category =& $gDirDb->getCategoryById($_GET['id_category']);
$temp_category['title'] = ($temp_category['title'] == 'ROOT') ? "HOME" : $temp_category['title'];
$s.= "<option value=\"{$_GET['id_category']}\" selected=\"selected\">[{$temp_category['title']}]</option>";
$tree=$s.$tree;
}


*** save and close it. you may change HOME to anything like [choose]

Do the same with '../suggest-category.php'.

It might help you.

Cristiano Diaz
12-06-2006, 01:01 PM
Hello Cristiano Diaz and welcome.

I offer you to check your suggest-link.tpl file.
by default if you choose subdirectory, page should be reloaded and dropdown must be re-built with subcategories of category which you have chosen prevoisly.


John,

Please refer to http://www.sluniverse.com/php/search/suggest-link.php?id=7 - this is the suggest link page for the subcategory Fashion of the category Blogs. Note that it does not even select the category, it stays at ROOT, and selecting the category does not refresh with a selection for the subcategory. Is there any way to get back the previous behavior in the last version, which showed a simple tree view of all categories and subcategories, and selected the correct one if you were in that subcategory already when you clicked on Suggest Link? The new version is unusable for me because of this problem.

Cristiano

Sergey Ten
12-06-2006, 03:31 PM
Hello Cristiano,

Please send me your FTP details and I will try to help you.

sten@esyndicat.com

Sergey Ten
12-08-2006, 02:27 PM
Hi, Cristiano!

OK, please follow directives:

*** Open your util.php ***
*** Find this code ***


/**
* Prints dropdown list with categories
*
* @param int $aCategory category id
* @param str $tree html source
* @param int $iter iteration number
*
*/
function print_categories_combo($aCategory, &$tree, &$iter)
{
global $gDirDb;
global $gDirConfig;

$categories = $gDirDb->getCategoriesByParent($aCategory, TRUE);

foreach($categories as $key => $category)
{
$subcategories = $gDirDb->getCategoriesByParent($category['id'], TRUE);

$selected = (($category['id'] == $_POST['id_category']) || ($category['id'] == $_GET['id']))? ' selected="selected"' : '';
$tree .= "<option value=\"{$category['id']}\"{$selected}>";
if ($category['level'] >= 1)
{
//$div = '&#x251C;';
//&#x2514;
$div = ($iter == $gDirDb->getNumCategories('active')) ? '' : $div;

for($j=0;$j<$category['level'];$j++)
{
$div .= '&ndash;';
}
}
else
{
$div = $iter ? '&#x251C;' : '&#x250C;';
$div = ($iter == $gDirDb->getNumCategories() - 1) ? '&#x2514;' : $div;
}

if ($subcategories)
{
$tree .= $div.$category['title'];
}
else
{
$tree .= $div.$category['title'];
}
$tree .= "</option>";

$iter++;

if($subcategories)
{
print_categories_combo($category['id'], $tree, $iter);
}
}
}


*** Replace with ***


/**
* Prints dropdown list with categories
*
* @param int $aCategory category id
* @param str $tree html source
* @param int $iter iteration number
*
*/
function print_categories_combo($aCategory, &$tree, &$iter)
{
global $gDirDb;
global $gDirConfig;

$categories = $gDirDb->getCategoriesByParent($aCategory, TRUE);

foreach($categories as $key => $category)
{
$subcategories = $gDirDb->getCategoriesByParent($category['id'], TRUE);

$selected = (($category['id'] == $_POST['id_category']) || ($category['id'] == $_GET['id']))? ' selected="selected"' : '';
$style = (1 == $category['level']) ? ' style="background-color: #EEE;"' : '';
$tree .= "<option value=\"{$category['id']}\"{$selected}{$style}>";
if ($category['level'] >= 1)
{
$div = '&#x251C;';
$div = ($iter == $gDirDb->getNumCategories('active')) ? '&#x2514;' : $div;

for($j=0;$j<$category['level'];$j++)
{
$div .= '&#x2500;';
}
}
else
{
$div = $iter ? '&#x251C;' : '&#x250C;';
$div = ($iter == $gDirDb->getNumCategories() - 1) ? '&#x2514;' : $div;
}

if ($subcategories)
{
$tree .= $div.$category['title'];
}
else
{
$tree .= $div.$category['title'];
}
$tree .= "</option>";

$iter++;

if($subcategories)
{
print_categories_combo($category['id'], $tree, $iter);
}
}
}


*** Save change ***

Greg
12-08-2006, 09:16 PM
Hi, Cristiano!

OK, please follow directives:

*** Open your util.php ***
*** Find this code ***


/**
* Prints dropdown list with categories
*
* @param int $aCategory category id
* @param str $tree html source
* @param int $iter iteration number
*
*/
function print_categories_combo($aCategory, &$tree, &$iter)
{
global $gDirDb;
global $gDirConfig;

$categories = $gDirDb->getCategoriesByParent($aCategory, TRUE);

foreach($categories as $key => $category)
{
$subcategories = $gDirDb->getCategoriesByParent($category['id'], TRUE);

$selected = (($category['id'] == $_POST['id_category']) || ($category['id'] == $_GET['id']))? ' selected="selected"' : '';
$tree .= "<option value=\"{$category['id']}\"{$selected}>";
if ($category['level'] >= 1)
{
//$div = '&#x251C;';
//&#x2514;
$div = ($iter == $gDirDb->getNumCategories('active')) ? '' : $div;

for($j=0;$j<$category['level'];$j++)
{
$div .= '&ndash;';
}
}
else
{
$div = $iter ? '&#x251C;' : '&#x250C;';
$div = ($iter == $gDirDb->getNumCategories() - 1) ? '&#x2514;' : $div;
}

if ($subcategories)
{
$tree .= $div.$category['title'];
}
else
{
$tree .= $div.$category['title'];
}
$tree .= "</option>";

$iter++;

if($subcategories)
{
print_categories_combo($category['id'], $tree, $iter);
}
}
}


*** Replace with ***


/**
* Prints dropdown list with categories
*
* @param int $aCategory category id
* @param str $tree html source
* @param int $iter iteration number
*
*/
function print_categories_combo($aCategory, &$tree, &$iter)
{
global $gDirDb;
global $gDirConfig;

$categories = $gDirDb->getCategoriesByParent($aCategory, TRUE);

foreach($categories as $key => $category)
{
$subcategories = $gDirDb->getCategoriesByParent($category['id'], TRUE);

$selected = (($category['id'] == $_POST['id_category']) || ($category['id'] == $_GET['id']))? ' selected="selected"' : '';
$style = (1 == $category['level']) ? ' style="background-color: #EEE;"' : '';
$tree .= "<option value=\"{$category['id']}\"{$selected}{$style}>";
if ($category['level'] >= 1)
{
$div = '&#x251C;';
$div = ($iter == $gDirDb->getNumCategories('active')) ? '&#x2514;' : $div;

for($j=0;$j<$category['level'];$j++)
{
$div .= '&#x2500;';
}
}
else
{
$div = $iter ? '&#x251C;' : '&#x250C;';
$div = ($iter == $gDirDb->getNumCategories() - 1) ? '&#x2514;' : $div;
}

if ($subcategories)
{
$tree .= $div.$category['title'];
}
else
{
$tree .= $div.$category['title'];
}
$tree .= "</option>";

$iter++;

if($subcategories)
{
print_categories_combo($category['id'], $tree, $iter);
}
}
}


*** Save change ***

Hi Sergey

This didn't work for me.:wallbash: Could you please add an Attachment of the util.php with this fix added? I'm on my localhost doing testing. Sub cats still aren't showing.

Thanks

Sergey Ten
12-08-2006, 09:31 PM
Hi, Greg!

But on my local server work is fine.

Greg
12-08-2006, 11:06 PM
Thanks Sergey

Still didn't work for me. Just shows the main categories. Maybe it's my local that's the problem? If any one else has this working on a live version please post a link to your site. :)

Thanks

Sergey Ten
12-10-2006, 03:02 PM
Hi, Greg!

It is on my local server.(Attached)

pauldm
02-03-2007, 02:08 PM
Hi,

I have tried this and it has no effect. Has anyone managed to do this?

Thanks

pauldm
02-04-2007, 08:41 PM
Anyone out there that has managed this??

Sergey Ten
02-05-2007, 08:08 PM
Hello pauldm!

Please send me your FTP and CPanel details via PM. And also don't forget include the description of the problem.

Thanks.