Jump to content

HOW TO!!! show catagories on homepage.


Guest aikdo

Recommended Posts

This mod will display the Top-Level Cats On the home page....

OPEN includes/content/index.inc.php

Find

$index->parse("index.latest_prods");

}

AFTER ADD :-

///////////////////////

//// CATAGORIES

// build query

$query = "SELECT * FROM ".$glob['dbprefix']."CubeCart_category WHERE cat_father_id = ".$db->mySQLSafe(0)." ORDER BY cat_name ASC";

// get category array in foreign innit

$resultsForeign = $db->select("SELECT cat_master_id as cat_id, cat_name FROM ".$glob['dbprefix']."CubeCart_cats_lang WHERE cat_lang = '".$lang_folder."'");

// query database

$subCategories = "";

$subCategories = $db->select($query);

// loop results

for ($i=0; $i<count($subCategories); $i++){

 

  if(is_array($resultsForeign)){

    for ($k=0; $k<count($resultsForeign); $k++){

    if($resultsForeign[$k]['cat_id'] == $subCategories[$i]['cat_id']){

   

      $subCategories[$i]['cat_name'] = $resultsForeign[$k]['cat_name'];

   

    }

   

    }

 

  }

  if(empty($subCategories[$i]['cat_image'])){

    $index->assign("IMG_CATEGORY",$GLOBALS['rootRel']."skins/".$config['skinDir']."/styleImages/catnophoto.gif");

  } else {

    $index->assign("IMG_CATEGORY",$GLOBALS['rootRel']."images/uploads/".$subCategories[$i]['cat_image']);

  }

 

  $index->assign("TXT_LINK_CATID",$subCategories[$i]['cat_id']);

  $index->assign("TXT_CATEGORY", validHTML($subCategories[$i]['cat_name']));

 

  $index->assign("NO_PRODUCTS", $subCategories[$i]['noProducts']);

 

  $index->parse("index.sub_cats.sub_cats_loop");

} // end loop results

$index->parse("index.sub_cats");

// end $subCategories

CLOSE includes/content/index.inc.php

OPEN skins/{your_skin}/skinTemplates/content/index.tpl

FIND

<!-- BEGIN: latest_prods -->

BEFORE ADD

<!-- BEGIN: sub_cats -->

<div class="boxContent">

<span class="txtContentTitle"></span>

  <div>

<!-- BEGIN: sub_cats_loop -->

<div style="float: left; text-align: center; possition:relative; margin:5px;">

    <a href="index.php?act=viewCat&amp;catId={TXT_LINK_CATID}" class="txtDefault"><img src="{IMG_CATEGORY}" alt="{TXT_CATEGORY}" border="0" title="{TXT_CATEGORY}" /></a><br />

  <a href="index.php?act=viewCat&amp;catId={TXT_LINK_CATID}" class="txtDefault">{TXT_CATEGORY}</a>

  </div>

  <!-- END: sub_cats_loop -->

  <br clear="all" />

  </div>

  <br clear="all" />

  </div>

<!-- END: sub_cats -->

Thats it it now works perfectly just the same as the Subcats work :D

You can see this in action at http://www.roxydiamonds.com/index.php and http://www.wood-b-treasures.com/

Link to comment
Share on other sites

Yea i have seen many people try this none sucessful and with a simple brainwave that i could just use the subcarts code and tell it to find father_id 0 << ie all top-level catagories... then it was easy to create and i think you will agree impliment also...

Link to comment
Share on other sites

Im already working on writing it up as mod instructions, at the time it was quicker to make a post here. I will however be updating it so that they can be turned ff from the admin...

^^ same as lattest products ^^

i wil upload this as v1 tonight though... But i do have Alot of work to do...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...