Jump to content

Category links


Guest

Recommended Posts

Hi new to Cube Cart (using 3.0.1), and using it in a current project.

The store will have multiple categories, and multiple levels of categories. What I'm wanting to do is when a user is looking at a product or category page, where currently we have

(Product page shows Location: instead of the Products In:)

Products in: >Top Level Category>Sub-Category

with 'Top Level Category' as a link but 'Sub-Category' isn't - would like to have 'Sub-Category' also as a link.

This would be especially useful on a product page, as it would allow the user to go back to the listing of all products in the same category as the product currently being viewed.

[site can be viewed at www.webpres-linux.co.uk/store - just working on gettin it fully functional before skinning thye site.]

Any help would fully appreciated.

Link to comment
Share on other sites

Me -> :^^: doh!! *slaps head*

My apologies.

All you need to do:-

  • in the file functions.inc.php (in the 'includes' dircectory) go to the 'Get Category Directory' section
  • find the following line : $dirArray[0] = $config['dirSymbol'].$catName
  • and change it something similar to this : $dirArray[0] = $config['dirSymbol']." <a href='".$GLOBALS['rootRel']."index.php?ccUser=".$sessId."&amp;catId=".$catId."&amp;act=viewCat' class='txtLocation'>".$catName."</a> ";

Doing that got the desired affect, that I was after.

I'll get back to you on having a link to the homepage, as *the* top-level link, as I havent sorted this yet.

But it should be easy enough, just by adding an a suitable value in the $lang['front']['viewCat'] and $lang['front']['viewProd'] arrays (may be able to get by with just adding a new array to hold the link - probably a better idea) in language/en/lang.in.php

Then in both viewCat.inc.php and viewProd.inc.php adding a line similar to:

$view_cat->assign("TXT_LINK_HOME",array_identifier);

After which it should just be a case of edting the viewCat.tpl and viewProd.tpl files (in skins/your-skin/styleTemplates/content/) to show the link.

Link to comment
Share on other sites

For the site home link: (i.e. Site Home > Top Level Category > Sub-Category)

1. in language/en/lang.inc.php, create a new array to store the clickable text of the link

$lang['front']['showLinks'] = array(

'home' => "Store Home",

);

2. in includes/content/viewCat.inc.php change

$view_cat->assign("LANG_CURRENT_DIR",$lang['front']['viewCat']['products_in']);

to

$view_cat->assign("TXT_LINK_HOME",$lang['front']['showLinks']['home']);

and in includes/content/viewProd.inc.php change

$view_prod->assign("LANG_DIR_LOC",$lang['front']['viewProd']['location']);

to

$view_prod->assign("TXT_LINK_HOME",$lang['front']['showLinks']['home']);

All that remains now is to display the link on the site. This is done by editing the viewCat.tpl and viewProd.tpl files. These are found under the skins directory for whichever skin you are currently using.

E.g. if you were using the Classic skin, the two files would be found under skins/Classic/styleTemplates/content/

3. in viewCat.tpl change <div><strong>{LANG_CURRENT_DIR}</strong> {CURRENT_DIR}</div>

to <div><a href="index.php" class="txtDefault">{TXT_LINK_HOME}</a> {CURRENT_DIR}</div>

and in viewProd.tpl change <strong>{LANG_DIR_LOC}</strong> {CURRENT_DIR}

to <a href="index.php" class="txtDefault">{TXT_LINK_HOME}</a> {CURRENT_DIR}

Hope this is useful to folks.

Link to comment
Share on other sites

  • 2 months later...

This was very helpful and is working perfectly - thanks!

I do have a question though: when a category (category/) is filled with ONLY sub-categories (category/subcategory) but no products within the first category (category/product) the breadcrumb disappears.

I've seen other sites that have breadcrumbs show in all pages regardless...

Your guidance is greatly appreciated, thanks in advance.

Link to comment
Share on other sites

This was very helpful and is working perfectly - thanks!

I do have a question though: when a category (category/) is filled with ONLY sub-categories (category/subcategory) but no products within the first category (category/product) the breadcrumb disappears.

I've seen other sites that have breadcrumbs show in all pages regardless...

Your guidance is greatly appreciated, thanks in advance.

This is something I have started to notice as well, not entirely sure why this is happening.

I will be looking into this in the next day or two, and I'll get back to as soon as I have worked out why this should happen (hopefully with a fix as well !!)

Link to comment
Share on other sites

  • 3 weeks later...

Right,

To sort the problem of no breadcrumb navigation showing on categories which have no product ....

in viewCat.inc.php look for the 'repeated region' section

look for the following statement

} elseif(isset($_GET['searchStr'])) {




there should be 'else' statement nearby



insert the following code, after the closing brace }




$view_cat->assign("TXT_LINK_HOME",$lang['front']['showLinks']['home']);

	$view_cat->assign("CURRENT_DIR",getCatDir($currentCat[0]['cat_name'],$currentCat[0]['cat_father_id'], $currentCat[0]['cat_id'], $link=TRUE));




this should be sitting above the 'no products' code, i.e.




$view_cat->assign("TXT_NO_PRODUCTS",$lang['front']['viewCat']['no_prods_in_cat']);

	$view_cat->parse("view_cat.noProducts");

I just now need to sort something similar for a search results page (viewCat.inc.php again).

Anyway hope this helps for now. I'm off to try and wrap my head around how to have a copy of the shopping cart box on a brochure site linked to a Cube Cart store. Having nightmarish problems with sessions. (Mainly because the brochure site is content managed with its own session, and the shopping cart box needs a session so that it will correctly display the basket contents.) :whistle:

Link to comment
Share on other sites

Hi webpresentations

Thanks ! nice usefull trick, looking forward for search results page too.

Your Test Store don't have these modifications, or do you have someother example site to look at it ? it will be helpfull to see the working solution in your testsite (if you don't mind) :w00t:

Regards

Yunus

Link to comment
Share on other sites

Guest overdrive

Hey Webpresentations, nice designs. I have a question, on the freetime1 store, how did you change the thumbnails for the subCats to replace the little blue folder icons? Was it easy?

Any info much appreciated.

TC

Link to comment
Share on other sites

I'm not Web Pres, but I'd say easy enough with a little javascript . . .

Script in header:

<script language="JavaScript" type="text/JavaScript">

	<!--

  function MM_swapImgRestore() { //v3.0

 	 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

  }

 	 

  function MM_preloadImages() { //v3.0

 	 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

  }

 	 

  function MM_findObj(n, d) { //v4.01

 	 var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

 	 if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

 	 for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

 	 if(!x && d.getElementById) x=d.getElementById(n); return x;

  }

 	 

  function MM_swapImage() { //v3.0

 	 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

  }

	//-->

</script>




Links in body:




   	 <table cellspacing="0" cellpadding="0" border="0">

      <tr>

     	 <td><a href="index.php?act=viewCat&amp;catId=2" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image1','','skins/Freetime/styleImages/buttons/quicklink1_hover.jpg',1)"><img src="skins/Freetime/styleImages/buttons/quicklink1.jpg" alt="Camping &amp; Backpacking" width="105" height="50" name="Image1" longdesc="http://www.outdoor-spirit.co.uk/store/index.php?act=viewCat&amp;catId=2" border="0" /></a></td>

     	 <td><a href="index.php?act=viewCat&amp;catId=4" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image2','','skins/Freetime/styleImages/buttons/quicklink2_hover.jpg',1)"><img src="skins/Freetime/styleImages/buttons/quicklink2.jpg" alt="Climbing &amp; Mountaineering" width="105" height="50" name="Image2" longdesc="http://www.outdoor-spirit.co.uk/store/index.php?act=viewCat&amp;catId=4" border="0" /></a></td>

     	 <td><a href="index.php?act=viewCat&amp;catId=5" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image3','','skins/Freetime/styleImages/buttons/quicklink3_hover.jpg',1)"><img src="skins/Freetime/styleImages/buttons/quicklink3.jpg" alt="Skiiing &amp; Snowsports" width="105" height="50" name="Image3" longdesc="http://www.outdoor-spirit.co.uk/store/index.php?act=viewCat&amp;catId=5" border="0" /></a></td>

     	 <td><a href="index.php?act=viewCat&amp;catId=6" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image4','','skins/Freetime/styleImages/buttons/quicklink4_hover.jpg',1)"><img src="skins/Freetime/styleImages/buttons/quicklink4.jpg" alt="Walking &amp; Rambling" width="105" height="50" name="Image4" longdesc="http://www.outdoor-spirit.co.uk/store/index.php?act=viewCat&amp;catId=6" border="0" /></a></td>

     	 <td><a href="index.php?act=viewCat&amp;catId=7" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image5','','skins/Freetime/styleImages/buttons/quicklink5_hover.jpg',1)"><img src="skins/Freetime/styleImages/buttons/quicklink5.jpg" alt="Lightweight Trekking" width="105" height="50" name="Image5" longdesc="http://www.outdoor-spirit.co.uk/store/index.php?act=viewCat&amp;catId=7" border="0" /></a></td>

     	 <td><a href="index.php?act=viewCat&amp;catId=8" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image6','','skins/Freetime/styleImages/buttons/quicklink6_hover.jpg',1)"><img src="skins/Freetime/styleImages/buttons/quicklink6.jpg" alt="Outdoor Accessories" width="105" height="50" name="Image6" longdesc="http://www.outdoor-spirit.co.uk/store/index.php?act=viewCat&amp;catId=8" border="0" /></a></td>

      </tr>

   	 </table>

Link to comment
Share on other sites

Guest overdrive

Thank you markscarts for that.

Though it's not the rollover nav links at the top of the page that I was asking about but the subCat boxes near the bottom of the pages which in the stock templates are represented by a blue folder icon.

How are the images made individual in each category?

Ta

Link to comment
Share on other sites

On A Slight adaption to this post has anyone found a way to have a cat image (for Cat Headers) and a cat image (for the sub cat image) as two diffrent images i noticed in the second website shown the background/header image changed was this just because you had made all the cat immages stay as the blue folder or have you acctualy found away around...

Link to comment
Share on other sites

  • 3 weeks later...

My apologies for the lateness of the reply, I have been busy with various sites recently.

The banner images on outdoor-spirit, are seperate from the category images. Outdoor spirit currently doesnt have any category images, hence the blue folder icons for the sub cats.

To achieve a similar effect to Outdoor Spirit, create a series of banner images (one for each of the main categories, and also a generic 'store' banner image)

in skins/your_template_name/styleTemplates/content/index.tpl

just below the following code (at the very top of the file)

<!-- BEGIN: index -->




insert the following code




<!-- BEGIN: banner_left -->

<div style="height:198px; background-image:url({VAL_FILE_LINK}); background-repeat:no-repeat;" class="boxContent"></div>

<!-- END: banner_left -->




changing height:198px to the height of your banner image.



you will also need the following code in includes/content/index.inc.php (insert above the 'Build Main Categories' section)




$index->assign("VAL_FILE_LINK",$GLOBALS['rootRel']."skins/".$config['skinDir']."/styleImages/banners/brochure_store_left.jpg");

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




To deal with the category-specific banner images, in skins/your_template_name/styleTemplates/content/viewCat.tpl



just below the first line of code, insert the following (again change the height value to the height of your banner image)




<!-- BEGIN: banner_left -->

<div style="height:198px; background-image:url({VAL_FILE_LINK}); background-repeat:no-repeat;" class="boxContent"></div>

<!-- END: banner_left -->




and then in includes/contentviewCat.php, above the 'Build Sub-Categories' section insert the following code:








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

// BANNER IMAGE

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



switch($_GET['catId']){

  case 7:

  case 8:

  case 9:

  case 10:

  case 11:

  case 12:

  case 13:

  case 41:

  case 59:

  case 60:

 	 $imgLeft = 'category_footwear_left.jpg';

 	 break;

  case 15:

  case 16:

  case 17:

  case 18:

  case 19:

  case 20:

  case 55:

 	 $imgLeft = 'category_clothing_left.jpg';

 	 break;

  case 21:

  case 22:

  case 23:

  case 24:

 	 $imgLeft = 'category_camping_left.jpg';

 	 break;

  case 25:

  case 26:

  case 27:

  case 28:

  case 29:

  case 30:

  case 50:

 	 $imgLeft = 'category_accessories_left.jpg';

 	 break;

  case 31:

  case 32:

  case 33:

  case 34:

  case 35:

  case 36:

 	 $imgLeft = 'category_fishing_left.jpg';

 	 break;

  case 37:

  case 38:

  case 39:

  case 42:

  case 56:

  case 57:

 	 $imgLeft = 'category_country_clothing_left.jpg';

 	 break;

  case 43:

 	 $imgLeft = 'category_skiing_left.jpg';

 	 break;

  case 44:

 	 $imgLeft = 'category_walking_left.jpg';

 	 break;

  default:

 	 $imgLeft = 'brochure_store_left.jpg';

 	 break;

}



$view_cat->assign("VAL_FILE_LINK",$GLOBALS['rootRel']."skins/".$config['skinDir']."/styleImages/banners/".$imgLeft);

$view_cat->parse("view_cat.banner_left");

There we have it banner images across the categories, with a generic store as the default.

**Note

All the numbers in the switch statement relate to the category id for each of the categories in the store. This is found in the url for the category pages of the store, thus:- index.php?act=viewCat&catId=25.

You will notice that some images have more than number (category id) listed against them, this is to deal with sub-catgeories. (I.E. if you have a main category of 'Footwear', which is further split down into say 'Mens', 'Womens' and 'Childrens' - with this setup, the 'Footwear' banner image will also appear on the pages for 'Mens' Womens' and 'Childrens')

If you have a lot of categories you may end up with a huge select statement, one way to get around this (rightly pointed out Sir William in this post

http://www.cubecart.com/site/forums/index....topic=12364&hl=) would be to set up an array containing the image file name, and category id.

Link to comment
Share on other sites

  • 2 months later...

I notice on the Freetime site listed in this topic, there is text information on the actual Category pages. How is this done?

ie: on http://www.freetime1.co.uk/store/index.php...d=8&act=viewCat

This is something that would help me immensely.

I used the Category Description mod, available here and here. (There is also a similar one on cubecart.org - costs $9.95)

I'm not sure how different the pay for mod is from the other two. The free one I used on Freetime basically just adds a new field to the categories table, and an editor window to the add/edit admin screen for categories.

In my opinion, this is a very useful mod.

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...