Forums / Templates, Stylesheets, Page Layout / Parent Categories Separated In 3 sideboxes

Parent Categories Separated In 3 sideboxes

Locked

Views: 18,939

Results 21 to 40 of 70
This thread is locked. New replies are disabled.
9 Apr 2007, 3:41 PM
#21
enchantedlingerie avatar

enchantedlingerie

Zen Follower

Join Date:
Nov 2005
Posts:
101
Plugin Contributions:
0

Parent Categories Separated In 3 sideboxes

i got it working....Yay....it was my bad i was playing around with the document type trying to clone it for duplicating the sideboxes and i set the category to restrict to only the document box.
it works perfectly, it will be time consuming adding all categories this way, as i have hundreds of them but i don't care it worksL

thank you so much for all your help, its more appreciated then you will ever know. im so excited this is working:smile:

9 Apr 2007, 4:34 PM
#22
enchantedlingerie avatar

enchantedlingerie

Zen Follower

Join Date:
Nov 2005
Posts:
101
Plugin Contributions:
0

Re: Parent Categories Separated In 3 sideboxes

ok so once again i jumped the gun, it works perfectly in the original categories sidebox but it wont work in the cloned sideboxes. it shows the sidebox but its empty. i named the other categories sidexboxes
tpl_categories2.php,tpl_categories3.php and tpl_categories4.php

im thinking maybe i need to change file name or something like this, im just not sure what

im going to work on it and see what i can do but if you or anyone has a clue i would love to hear it.
here is the site incase you need to see it.

i named the original categoreis box to adult the one that is not working is pets which is tpl_categories2.php

http://www.gothenaturalway.com

9 Apr 2007, 5:14 PM
#23
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Parent Categories Separated In 3 sideboxes

As you probably already found and corrected, this code ```php
$cPTest = $box_categories_array[$i]['path'];
if (($cPTest == 'cPath=3') or ($cPTest == 'cPath=7') or($cPTest == 'cPath=7_25')) }


I'm afraid I can't help with the cloned files, as far as any changes that have to be made. I can only give one speculation or question: does the first executed box reset some info so it is not available to others? or does the last one overwrite what previous ones have done? 
Good luck, and I'll be watching for developments.
9 Apr 2007, 5:35 PM
#24
enchantedlingerie avatar

enchantedlingerie

Zen Follower

Join Date:
Nov 2005
Posts:
101
Plugin Contributions:
0

Re: Parent Categories Separated In 3 sideboxes

yes i did catch the type, thanks alot.

yeah i dont even know how to go about finding out if the first executed box resets some info so it is not available to others or if the last one overwrites what previous ones have done. i know its a cloning issue, as far as i know i have cloned right i have done this many times before, but there is something stopping the changes in all the other category sideboxes. if anyone has a clue i would love to hear it.

Glenn thanks so much for all your help.

10 Apr 2007, 1:47 AM
#25
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Parent Categories Separated In 3 sideboxes

Working on a similar project, I just realized that I had neglected to check my syntax against the example in tpl_main_page.php when I knew the same method was used there. ```php
if(in_array(str_replace("cPath=","",$box_categories_array[$i]['path']), explode(",",'3,21,21_57'))) {

That should make your selection statements easier to write and read.
10 Apr 2007, 3:38 PM
#26
enchantedlingerie avatar

enchantedlingerie

Zen Follower

Join Date:
Nov 2005
Posts:
101
Plugin Contributions:
0

Re: Parent Categories Separated In 3 sideboxes

Ohhhhhhh i could just kiss you

thank you thank you thank you. That not only makes adding the cats so much easier it also fixed the problem with the cloned sideboxes, it must have been the syntax that was off making the clones not work.

i cant thank you enough for all your help, it was very nice of you to waste so much time helping me.:smile:

29 Aug 2007, 2:40 AM
#27
incredibody_com avatar

incredibody_com

New Zenner

Join Date:
May 2007
Posts:
42
Plugin Contributions:
0

Re: Parent Categories Separated In 3 sideboxes

I followed these instructions and I can get it to work if I am linking to a top category, but if I am linking to a subcategory (example 141_145) it doesn't seem to work. Has anyone been able to get this to work for linking to subcategories?

29 Aug 2007, 7:17 PM
#28
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Parent Categories Separated In 3 sideboxes

I'm not sure at first glance why this wouldn't be working for you, but I do have two comments:

(off topic) From view source, you are missing a closing > in this img tag on your home page:

<a href="http://www.fatvanish.com" target="_blank"><img src="images/frontpagefatvanish.gif" width="220" height="276" alt="Learn How to Lose Weight (Fat) at www.FatVanish.com"</a></center>

The way you have your multiple category boxes arranged and styled, you could achieve the exact same effect with Categories Dressing using non-linked headings, and much less coding.

For the multiple boxes:
Can you post the line where you test for cPaths to display? I presume you are using a version of this```php
if(in_array(str_replace("cPath=","",$box_categories_array[$i]['path']), explode(",",'3,21,21_57'))) {

30 Aug 2007, 4:47 PM
#29
incredibody_com avatar

incredibody_com

New Zenner

Join Date:
May 2007
Posts:
42
Plugin Contributions:
0

Re: Parent Categories Separated In 3 sideboxes

gjh42:

I'm not sure at first glance why this wouldn't be working for you, but I do have two comments:

(off topic) From view source, you are missing a closing > in this img tag on your home page:

<a href="http://www.fatvanish.com" target="_blank"><img src="images/frontpagefatvanish.gif" width="220" height="276" alt="Learn How to Lose Weight (Fat) at www.FatVanish.com"</a></center>

 
Thanks for that info. I have now fixed that.
 
> **gjh42:**
>
> The way you have your multiple category boxes arranged and styled, you could achieve the exact same effect with Categories Dressing using non-linked headings, and much less coding.
 
I never even looked into this. I just found this post and it looked like it would accomplish what I was looking for, so that's what I did. Out of curiousity, would there be a way using either the methods discussed in this thread, or with the categories dressing mod to have a category link directly to a different website? Underneath our Diet & Exercise Routines heading, I would like to have a category called "Muscle Building Program" that links to MuscleNOW.com (opening in a new window), and "Weight Loss Program" that links to FatVanish.com (also opening in a new window) instead of linking to a page within Zencart. Is there a way I could do this considering I'm pretty limited in PHP knowledge?
 
> **gjh42:**
>
> For the multiple boxes:
> Can you post the line where you test for cPaths to display? I presume you are using a version of this```php
     if(in_array(str_replace("cPath=","",$box_categories_array[$i]['path']), explode(",",'3,21,21_57'))) { 

Below is that code:

if(in_array(str_replace("cPath=","",$box_categories_array[$i]['path']), explode(",",'81,69,156,66'))) {
30 Aug 2007, 4:58 PM
#30
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Parent Categories Separated In 3 sideboxes

The select part is simple - you are not asking for the subcategories to be displayed:

explode(",",'81,69,156,66')

This will display top categories 81, 69, 156 and 66, but you also need to specify all of their subcategories individually.

explode(",",'81,81_199,81_200,81_203,69,69_177,69_178,156,156_235,156_236,66,66_212,66_213')

The code could be reworked to do this automatically, but I didn't get into that at the time since the original code worked.

30 Aug 2007, 5:12 PM
#31
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Parent Categories Separated In 3 sideboxes

This will strip off the subcategory numbers (if any) before testing for categories to display. You will only need to list the top categories, and all of their subs will be included.

     if (in_array(str_replace(strstr($box_categories_array[$i]['path'],"_"),"",str_replace("cPath=","",$box_categories_array[$i]['path'])), explode(",",'3,21,27'))) {  
30 Aug 2007, 5:34 PM
#32
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Parent Categories Separated In 3 sideboxes

With either multiple category boxes or Categories Dressing, you could add code to the appropriate copy of tpl_categories.php to say "if category equals ##, $content = '<a href=your_external_link etc.>' ". Simple, though of course the statement has to be written just right and put in the right location.

You would have "dummy" categories for each of these, which nobody would ever actually be visiting, as their links would go offsite instead.

31 Aug 2007, 6:26 PM
#33
incredibody_com avatar

incredibody_com

New Zenner

Join Date:
May 2007
Posts:
42
Plugin Contributions:
0

Re: Parent Categories Separated In 3 sideboxes

gjh42:

With either multiple category boxes or Categories Dressing, you could add code to the appropriate copy of tpl_categories.php to say "if category equals ##, $content = '<a href=your_external_link etc.>' ". Simple, though of course the statement has to be written just right and put in the right location.

You would have "dummy" categories for each of these, which nobody would ever actually be visiting, as their links would go offsite instead.

That makes sense, I just have no idea how to write it. I'm not sure how complicated it would be, but if you (or anyone) get a chance to help me out, I would appreciate it.

31 Aug 2007, 7:08 PM
#34
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Parent Categories Separated In 3 sideboxes

In /includes/templates/your_template/sideboxes/tpl_categories.php, around line 31 find```php
if (zen_get_product_types_to_category($box_categories_array[$i]['path']) == 3 or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1)) {
// skip if this is for the document box (==3)

  } else {
  $content .= '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';

and add elseif sections to get thisphp
if (zen_get_product_types_to_category($box_categories_array[$i]['path']) == 3 or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1)) {
// skip if this is for the document box (==3)

  } elseif ($box_categories_array[$i]['path'] == 'cPath=23') {
  $content .= '<a class="exLink" href="your_MuscleNOW.com_url" target="_blank">Muscle Building Program</a><br />' . "\n";
  } elseif ($box_categories_array[$i]['path'] == 'cPath=24') {
  $content .= '<a class="exLink" href="your_FatVanish.com_url" target="_blank">Weight Loss Program</a><br />' . "\n";

  } else {
  $content .= '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';
 
your_MuscleNOW.com_url

with the actual URL.

I haven't tested this, so if anything needs tweaking, let me know.
You may want to style
.exLink { }
in your stylesheet.
4 Nov 2007, 6:42 PM
#35
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Parent Categories Separated In 3 sideboxes

You could use a variant of this code to display ez-page links at desired points in the list.

Create a dummy category for each block of links you want, and give it a sort order to put it in the proper place in the list. Then use the elseif snippets to display the links:```php
if (zen_get_product_types_to_category($box_categories_array[$i]['path']) == 3 or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1)) {
// skip if this is for the document box (==3)

  } elseif ($box_categories_array[$i]['path'] == 'cPath=23') {
  $content .= '<a class="ezpLink" href="' . zen_ez_pages_link(6) . '" target="_blank">EZ-Page Number 6</a><br />' . "\n";
  $content .= '<a class="ezpLink" href="' . zen_ez_pages_link(7) . '" target="_blank">EZ-Page Number 7</a><br />' . "\n";
  } elseif ($box_categories_array[$i]['path'] == 'cPath=24') {
  $content .= '<a class="ezpLink" href="' . zen_ez_pages_link(9) . '" target="_blank">EZ-Page Number 9</a><br />' . "\n";

  } else {
  $content .= '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';  
21 Feb 2008, 9:41 PM
#36
samad64 avatar

samad64

Totally Zenned

Join Date:
May 2006
Location:
Texas
Posts:
554
Plugin Contributions:
2

Re: Parent Categories Separated In 3 sideboxes

webomat:

Hi,

I'm coming late to this discussion, but there's a pretty simple way to my mind... something similar to what I've done with a site that had special needs re displaying the categories. Simply modify a function/query in the \includes\classes\category_tree.php to select based on the top level category.

Here's an overview....

  1. Set up an Adult Category that contains all the categories of adult clothing; set up one for Teens and one for Children.

  2. Write down the Category ID # for each of them.

  3. In \includes\classes\category_tree.php you need to duplicate the entire "function zen_category_tree" section, renaming the function... for instance, "function zen_adult_tree".

  4. Find this section and add the text in red, replacing the # with your number from Step 2 above:

if ($product_type == 'all') { // added c.categories_id specific here bpeters
  $categories_query = "select c.categories_id, cd.categories_name, c.parent_id, c.categories_image
                         from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
                         where c.parent_id = 0
                         [B]and c.categories_id = #[/B]
                         and c.categories_id = cd.categories_id
                         and cd.language_id='" . (int)$_SESSION['languages_id'] . "'
                         and c.categories_status= 1
                         order by sort_order, cd.categories_name";
} else
> 
> 5.  Duplicate the Categories Sidebox, title it Adult or whatever... change the function call to call the newly defined "tree" in \includes\modules\sideboxes\[your template]\categories.php as shown in red text:
> ```
// don't build a tree when no categories
    $check_categories = $db->Execute("select categories_id from " . TABLE_CATEGORIES . " where categories_status=1 limit 1");
    if ($check_categories->RecordCount() > 0) {
      $box_categories_array = $main_category_tree->[B]zen_adult_tree();[/B]
    }

Of course changing adult to whatever you need for each box.

  1. I don't know if you'll need to change anything if you're using the Site Map contrib or not, so you might want to check if that applies to your site.

  2. Be aware that the categories may not be expanded in the sidebox to display the subcategories all the time, and the boxes would have one link to "Adult Clothing" and not show anything else until you click on the category link itself. I can't remember what the upshot of this was, because I made additional changes beyond this for that site to meet their specific needs. But that sticks in my mind for some reason.

** Be advised that the mod to the class file will be overwritten during an upgrade, so be sure to save a copy of that file elsewhere -- there is no override in that section. And modifying core code is not always best, but this works and is easy. "-)

I got this from digging around in the forum, found an old post by Ajeh I think that mentioned this method of doing something similar. Anyway, just an idea in case you don't get the other thing working.

Just my two cents!

Cheers,

Becky

I know its close to a year after you posted this, but THANK YOU! I modified the category tree function (after cloning it) so that I don't have to make more than one copy of it. Basically, I pass in a parameter along with the "zen_custom_tree" function.. and it auto fills the part of the query for me.

Also, if you want it to show all the sub categories instead of the top level only, change the following code:

 $categories_query = "select c.categories_id, cd.categories_name, c.parent_id, c.categories_image
                             from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
                             [B]where c.parent_id = #[/B]
                             and c.categories_id = cd.categories_id
21 Feb 2008, 10:24 PM
#37
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Parent Categories Separated In 3 sideboxes

Or you can use simple category tree, which allows you to build just any branch of the category tree you want, given the category id. That way you can divide the tree and put in in multiple blocks.

On my site i put the parent cat on the header, and the sub-cats on the left column.

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

3 Apr 2008, 1:45 AM
#38
candylea avatar

candylea

New Zenner

Join Date:
Jun 2007
Posts:
54
Plugin Contributions:
0

Re: Parent Categories Separated In 3 sideboxes

Anybody that know how to get this fuction working would love the Help, I have 3 cats and would like subs showing in each cat. But All I can get to show is one cat in the first cat but the others are blank. Even tried making my subs as top cats and call them in but the code only seems to call in the cpath and nothing after it. But nothing in my following 2 cat boxes

my code from tpl_catergories_rock_roll.php
$cPTest = $box_categories_array[$i]['path'];
if (in_array(str_replace(strstr($box_categories_array[$i]['path'],"_"),"",str_replace("cPath=","",$box_categories_array[$i]['path'])), explode(",",'111,112,75'))) {

Any ideas thanks who can spare some time for me :frusty:

4 Apr 2008, 5:49 AM
#39
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Parent Categories Separated In 3 sideboxes

Coming from your other thread (3 catergories in different sideboxes - Help), my first comment would be that if you want the boxes all in one column as your site shows now, you could have done it much easier by tweaking Categories Dressing than by cloning the sideboxes. Since you have done that work, it will now be easier to complete the category sorting in your new sideboxes.

To recap the basic sorting code, since there are so many incomplete or inaccurate versions in previous posts, this will execute the code if the category being evaluated is in the list of cPaths in the explode function.

$cPTest = str_replace("cPath=","",$box_categories_array[$i]['path']);
if(in_array($cPTest, explode(",",'3,7,7_25'))) {
  // code to be executed
}
```Note that the numbers are in one string, separated by commas and no spaces, and surrounded by one pair of quotes ' '.

I will address your case next.
4 Apr 2008, 6:09 AM
#40
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Parent Categories Separated In 3 sideboxes

Since your setup has one top category per box, and you won't want to display that as a category, only the subcategories below it, you will need to use an expanded categories mod. One that has proven reliable for situations like yours is fragfutter's Uncollapsed Categories Tree, hosted on his own site.

Another possibility is to use yellow1912's Simple Category Tree mod (see his sig above). This would also include the ability to directly control the categories being displayed in each box.

For either of these you will need to get help from their creators or people who have used them, as I have not used either of them myself. Once you have worked this out, come back and I will have some display code for your situation.

A third option, since you presumably will not be displaying the top categories themselves but only their subs, would be to move the subs to become top categories themselves, keeping the current tops only as names on the boxes. Then you can display all of the first level of categories with no further coding required.