
Making the panel:
I used the sub categories feature found in categoryheading.php to get this thing going after many failed attempts at other methods.

In /includes/display/ create a file called: HomeCategories.php and inside of it paste this:
Code: Select all
<?php
CLASS ISC_HOMECATEGORIES_PANEL extends PANEL
{
public function SetPanelSettings()
{
$GLOBALS['ISC_CLASS_CATEGORY'] = GetClass('ISC_CATEGORY');
if ($GLOBALS['EnableSEOUrls'] == 1) {
$baseLink = sprintf("%s/categories", $GLOBALS['ShopPath']);
} else {
$baseLink = sprintf("%s/categories.php?category=", $GLOBALS['ShopPath']);
}
// Output Top-level Categories
$GLOBALS['SNIPPETS']['HomeCategories'] = "";
$query = sprintf("select * from [|PREFIX|]categories where catparentid='0' and catvisible=1 order by catsort asc, catname asc", $GLOBALS['ISC_CLASS_DB']->Quote($GLOBALS['CatId']));
$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
if($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) {
// Check to see if we need to add in place holder images or if we are just displaying text
if (!($rtn = $GLOBALS['ISC_CLASS_DB']->Fetch($GLOBALS['ISC_CLASS_DB']->Query("SELECT COUNT(*) AS Total FROM [|PREFIX|]categories WHERE catimagefile != ''"))) || !$rtn['Total']) {
$useImages = false;
} else {
$useImages = true;
if (GetConfig('CategoryDefaultImage') !== '') {
$defaultImage = GetConfig('ShopPath') . '/' . GetConfig('CategoryDefaultImage');
} else {
$defaultImage = $GLOBALS['IMG_PATH'].'/CategoryDefault.gif';
}
}
$i = 0;
while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
$i++;
if (!CustomerGroupHasAccessToCategory($row['categoryid'])) {
continue;
}
$GLOBALS['HomeCatName'] = isc_html_escape($row['catname']);
$GLOBALS['HomeCatLink'] = CatLink($row['categoryid'], $row['catname']);
if ($useImages) {
if ($row['catimagefile'] !== '') {
$GLOBALS['CatImage'] = GetConfig('ShopPath') . '/' . GetConfig('ImageDirectory') . '/' . $row['catimagefile'];
} else {
$GLOBALS['CatImage'] = $defaultImage;
}
$GLOBALS['ISC_CLASS_TEMPLATE']->assign('width', getConfig('CategoryImageWidth'));
$GLOBALS['ISC_CLASS_TEMPLATE']->assign('height', getConfig('CategoryImageHeight') + 50);
$GLOBALS['SNIPPETS']['HomeCategories'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CatItemImage");
if ($i % GetConfig('CategoryPerRow') == 0) {
$GLOBALS['SNIPPETS']['HomeCategories'] .= '<li class="RowDivider" style="float:none; clear:both;"></li>';
}
} else {
$GLOBALS['SNIPPETS']['HomeCategories'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CatItem");
}
}
if ($useImages) {
if ($i % GetConfig('CategoryPerRow') > 0) {
$GLOBALS['SNIPPETS']['HomeCategories'] .= '<li style="float: none; clear: both;"/>';
}
$output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("HomeCategoriesGrid");
} else {
$output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("HomeCategories");
}
$output = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output, $GLOBALS['SNIPPETS']);
$GLOBALS['SNIPPETS']['HomeCategories'] = $output;
}
}
}
Code: Select all
<div class="Block Moveable Panel" id="CategoryHeading">
<div class="BlockContent">
%%SNIPPET_HomeCategories%%
</div>
</div>
Code: Select all
<li><a href="%%GLOBAL_HomeCatLink%%">%%GLOBAL_HomeCatName%%</a></li>
Code: Select all
<li style="width: %%GLOBAL_width%%px; height: %%GLOBAL_height%%px;">
<a href="%%GLOBAL_HomeCatLink%%" style="text-decoration: none;"><img src="%%GLOBAL_CatImage%%" border="0" /></a><br /><a href="%%GLOBAL_HomeCatLink%%">%%GLOBAL_HomeCatName%%</a>
</li>
Code: Select all
<div class="SubCategoryListGrid">
<ul>
%%SNIPPET_HomeCategories%%
</ul>
</div>
Code: Select all
<div class="SubCategoryList">
<ul>
%%SNIPPET_HomeCategories%%
</ul>
</div>
Code: Select all
%%Panel.HomeCategories%%
Tricking the script to get the images:
This part was quite infuriating. If only sucker punches could be sent via mail.

In admin/includes/classes/class.category.php locate the following code and delete it.
Code: Select all
// Also forcefully delete the image if it is a root category
if ($catData['category'] == "0") {
$this->DelCategoryImage($this->categoryAPI->catimagefile);
$catImage = '';
}
Code: Select all
public function RemoveRootImages()
{
$result = $GLOBALS['ISC_CLASS_DB']->Query("SELECT * FROM [|PREFIX|]categories WHERE catparentid='0' AND catimagefile != ''");
while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
$this->DelCategoryImage($row['categoryid']);
$GLOBALS['ISC_CLASS_DB']->UpdateQuery('categories', array('catimagefile' => ''), "categoryid='" . (int)$row['categoryid'] . "'");
}
}
Code: Select all
// Also make sure that all the root categories do NOT have any images assoiated with them
$GLOBALS['ISC_CLASS_ADMIN_CATEGORY'] = GetClass('ISC_ADMIN_CATEGORY');
$GLOBALS['ISC_CLASS_ADMIN_CATEGORY']->RemoveRootImages();
You're on your own from here and you'll have to style your new panel and make tweaks however you like. Cheers! Sharing is caring!
