phpWordPress Article Manager Support Forums Home | Features | Online Demo | Live Tour | Order Now  

Go Back   phpWordPress Article Manager Support Forums > Code Customizations & Templates
User Name
Password

Code Customizations & Templates Various code hacks and customizations. Template repository and all related template customization discussions.

Reply
 
Thread Tools Search this Thread Display Modes
Old 03-19-2006, 11:09 AM   #1
boccio
Product Line Manager
 
boccio's Avatar
 
Join Date: Sep 2004
Posts: 170
Rep Power: 10boccio has disabled reputation
Default Mod: Display subcategories on Category page

Here is a little hack to display subcategories in main category view. If you have a lot of subcategories, you probably won't display them in main navigation to keep the nav clear, so this can come very useful.

1. category_Main.tpl
Place the {SHOW_SUBCATEGORIES} tag somewhere inside the template, where you want subcategories shown. Preferebly at the top of the file, above or below the {CATEGORY_NAME} tag. Format the output at will.
Code:
<tr> <td colspan="2"><br />{SHOW_SUBCATEGORIES}</td> </tr>

2. index.php:
Place the call to function that parses the new tag in template. Preferably somewhere around line 286:
Code:
$show_subcategories_HTML = HTML_show_subcategories($cid);
Also, around line 792, (at the bottom of the section after ''/{SITEMAP_LINK}/'') place this line:
Code:
'/{SHOW_SUBCATEGORIES}/',
and after line 836 (exactly after $sitemap_link,):
Code:
$show_subcategories_HTML,

3. HTML_function.php:
After line 161 (approx.) place the function to manage the display:
Code:
function HTML_show_subcategories($cid, $prf='') { global $url, $tpl_folder,$lang, $connection, $category; $query = "SELECT id FROM tblCategories WHERE parent_cat=$cid ORDER BY order_num"; $result2 = mysql_query($query) or sql_error ($query, "show_subcategories"); $sub_category_menu = ""; while($row2=mysql_fetch_array($result2)) { $sub_category = new Category(); $sub_category->LoadFromDatebase($connection,$row2['id']); $sub_category_menu.= "<div class=\"category_link_depth2\"><a href=\"".HTML_show_friendly_cat($sub_category->Id)."\">"; $sub_category_menu.= $prf.$sub_category->Category_name."</a></div>"; $cid = $sub_category->Id; $sub_category_menu.= HTML_show_subcategories($cid, $prf.'- '); } return $sub_category_menu; }
__________________
phpWordPress Dev. Team

Last edited by boccio : 05-01-2006 at 11:43 AM.
boccio is offline   Reply With Quote
Old 05-25-2006, 03:29 PM   #2
Frankc2
New Member
 
Join Date: May 2006
Posts: 5
Rep Power: 0Frankc2 is on a distinguished road
Default

Is this instructions current?

I can't find the appropriate lines or places in index.php.

Quote:
Also, around line 792, (at the bottom of the section after ''/{SITEMAP_LINK}/'') place this line:
Frankc2 is offline   Reply With Quote
Old 05-25-2006, 03:43 PM   #3
Alex
Moderator
 
Alex's Avatar
 
Join Date: May 2005
Posts: 109
Rep Power: 2Alex is on a distinguished road
Default

This refers to version 3.1, we need to update these hacks for release 3.2... Probably all the things are more or less the same, only line numbers in scripts differ.
__________________
phpWordPress Dev. Team
Alex is offline   Reply With Quote
Old 05-27-2006, 08:55 AM   #4
Frankc2
New Member
 
Join Date: May 2006
Posts: 5
Rep Power: 0Frankc2 is on a distinguished road
Default

Thank you

Would appreciate it if you can let me know once done because I tried over and over again but am unable to accomplanish this.
Frankc2 is offline   Reply With Quote
Old 06-10-2006, 10:42 AM   #5
Frankc
New Member
 
Join Date: May 2006
Posts: 22
Rep Power: 0Frankc is on a distinguished road
Default

Any further developments in this regard please?
Frankc is offline   Reply With Quote
Old 06-12-2006, 09:18 AM   #6
Alex
Moderator
 
Alex's Avatar
 
Join Date: May 2005
Posts: 109
Rep Power: 2Alex is on a distinguished road
Default

This is the 3.2 version of this mod:

1. category_Main.tpl
Place the {SHOW_SUBCATEGORIES} tag somewhere inside the template, where you want the subcategories to show. Preferably at the top of the file, somewhere around the {CATEGORY_NAME} tag. Example:
HTML Code:
<tr> <td colspan="2"><br />{SHOW_SUBCATEGORIES}</td> </tr>

2. index.php
Place the call to the function that parses the new tag in template, at line 260:
PHP Code:
$show_subcategories_HTML HTML_show_subcategories($cid); 

3. template_scripts/default.php
Right after the line 33, insert the following snippet:
PHP Code:
$template_manager->assign($show_subcategories_HTML,'/{SHOW_SUBCATEGORIES}/'); 

4. HTML_function.php
After line 205 place this function to manage the display of subs:
PHP Code:
function HTML_show_subcategories($cid$prf=''

            global 
$url$tpl_folder,$lang$connection$category

            
$query "SELECT id FROM tblCategories WHERE parent_cat=$cid ORDER BY order_num"
            
$result2 mysql_query($query) or sql_error ($query"show_subcategories"); 

            
$sub_category_menu ""

            while(
$row2=mysql_fetch_array($result2)) 
            { 
                        
$sub_category = new Category(); 
                   
$sub_category->LoadFromDatebase($connection,$row2['id']); 
                        
$sub_category_menu.= "<div class=\"category_link_depth2\"><a href=\"".HTML_show_friendly_cat($sub_category->Id)."\">"
                        
$sub_category_menu.= $prf.$sub_category->Category_name."</a></div>"
                        
$cid $sub_category->Id
                        
$sub_category_menu.= HTML_show_subcategories($cid$prf.'- '); 
            } 

            return 
$sub_category_menu

__________________
phpWordPress Dev. Team
Alex is offline   Reply With Quote
Old 06-13-2006, 12:46 PM   #7
Elton
Member
 
Join Date: Dec 2005
Posts: 83
Rep Power: 1Elton is on a distinguished road
Default

Is there an example of this working to view online?
Elton is offline   Reply With Quote
Old 06-14-2006, 02:08 PM   #8
boccio
Product Line Manager
 
boccio's Avatar
 
Join Date: Sep 2004
Posts: 170
Rep Power: 10boccio has disabled reputation
Default

We don't have one. Suppose someone who applied this mod can show live example?
__________________
phpWordPress Dev. Team
boccio is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:37 AM.

Order now:

Order your copy of phpWordPress now and get:
  • Six months free upgrades
  • Free support
  • Full source code
  • Immediate download
  • Starting from only $159.00
Order now

HelpDesk:

Having troubles with your licensed copy of phpWordPress?
You can also submit a trouble ticket in the support area using your forum username and password.

Contact us:

Business hours
Mon-Fri 7:00AM - 3:00PM
(Eastern Standard Time)

Telephone Sales
(381) 11 218-2051

Email inquiries
office@word-press.net
(General inquiries)
sales@word-press.net
(Sales inquiries)
support@word-press.net
(Support inquiries)

Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2006, Jelsoft Enterprises Ltd.