Support Forums

Parent category

This is a discussion on Parent category within the Technical Support forums, part of the Technical Support Forums category; v4.1.3 Developer Custom - Fluid All I am having a problem resolving the parent category in Showlistings. We have set ...


Go Back   68 Classifieds Forums > Technical Support Forums > Technical Support

This topic is resolved.

If you have a similar issue that this thread does not address, open a new related support topic.

 
Thread Tools Display Modes
Old 12-07-2009, 08:58 AM   #1
Member
 
Join Date: Jun 2009
Location: Oxford, UK
Posts: 45
Rep Power: 3
mark is on a distinguished road
Default Parent category

v4.1.3 Developer


Custom - Fluid


All

I am having a problem resolving the parent category in Showlistings.
We have set up 45 parent categories that relate to UK Counties. Then in each parent category there are 160 sub categories which relate to where a user can place an ad. All seems to be working OK with this type of set up.

In Showlistings.tpl, I have turned off the display for users county as this regularly does not relate to which county the listing has been placed. I do, however, want to display the parent category for the listing; which in our case relates to the county that the listing has been placed. By placing a small mod in the Listings.php I can retrieve the sub category name that the listing is placed and also the parent_id for that sub category.

Is there any way that I can resolve the parent_id within showlistings.tpl? I have tried using {getcats} but this returns nothing.

Thanks in advance

Mark
__________________
V4.1.5 Developer
mark is offline  
Old 12-07-2009, 09:10 AM   #2
Coder
 
Join Date: Mar 2006
Posts: 4,813
Rep Power: 118
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

If the category name variable isnt available in DEBUG, then you will have to do another query to the catagory table using the category ID and look up the category name for it to be displayed.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Old 12-07-2009, 09:31 AM   #3
Member
 
Join Date: Jun 2009
Location: Oxford, UK
Posts: 45
Rep Power: 3
mark is on a distinguished road
Default

Hi Larry

Thanks again for the rapid response.

Not too sure where i should make this call, from within Listings.php or can it be done from within showlistings.tpl?

Mark
__________________
V4.1.5 Developer
mark is offline  
Old 12-07-2009, 09:38 AM   #4
Coder
 
Join Date: Mar 2006
Posts: 4,813
Rep Power: 118
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Quote:
Originally Posted by mark
Hi Larry

Thanks again for the rapid response.

Not too sure where i should make this call, from within Listings.php or can it be done from within showlistings.tpl?

Mark
You could do it right in listings.php but I am not a big fan of editing core code files because it makes future upgrades a pain. I would probably create a plugin and place it in the loop that displays the ads. The plugin should be able to take the variable for the category id at the template level and use that in the query.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Old 12-07-2009, 10:01 AM   #5
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 1,932
Rep Power: 47
seymourjames has a spectacular aura about
Default

If you upgrade to 4.1.6 then I believe the variable you want (category ID) becomes available to you. Otherwise you need to edit core files which basically amounts to the same thing.
__________________
TemplateCodes.com for 68 Classifieds - Magento for Online Stores
seymourjames is offline  
Old 12-07-2009, 10:05 AM   #6
Coder
 
Join Date: Mar 2006
Posts: 4,813
Rep Power: 118
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Quote:
Originally Posted by seymourjames
If you upgrade to 4.1.6 then I believe the variable you want (category ID) becomes available to you. Otherwise you need to edit core files which basically amounts to the same thing.
In v4.1.5 the {results} array has the variable "section" in it which should be the category the ad is placed in if I am not mistaken.

So if you are working within the loop

{foreach from=$results item="entry"}

{entry.section} will hold the section number and you should be able to pass that along to the plugin.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Old 12-07-2009, 10:08 AM   #7
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 1,932
Rep Power: 47
seymourjames has a spectacular aura about
Default

OK - I knew it was recent that this was added. Thought it was 4.1.6 . Mark is quoting 4.1.3
__________________
TemplateCodes.com for 68 Classifieds - Magento for Online Stores
seymourjames is offline  
Old 12-07-2009, 10:14 AM   #8
Coder
 
Join Date: Mar 2006
Posts: 4,813
Rep Power: 118
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

4.1.3 has the section in the {$results} array as well.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Old 12-07-2009, 10:33 AM   #9
Member
 
Join Date: Jun 2009
Location: Oxford, UK
Posts: 45
Rep Power: 3
mark is on a distinguished road
Default

Thanks again Larry

Must admit, we are always going to have a bit of an issue with upgrading. I have to check each of the altered files given in the documentation for each upgrade.

Still being a bit green in PHP etc, I managed to do the call from withing Listings.php. As I get more experience I'll try to create a few modules. At the moment, I would not know where to start creating these.

Cheers

Mark
__________________
V4.1.5 Developer
mark is offline  
Old 12-07-2009, 10:46 AM   #10
Coder
 
Join Date: Mar 2006
Posts: 4,813
Rep Power: 118
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Quote:
Originally Posted by mark
Thanks again Larry

Must admit, we are always going to have a bit of an issue with upgrading. I have to check each of the altered files given in the documentation for each upgrade.

Still being a bit green in PHP etc, I managed to do the call from withing Listings.php. As I get more experience I'll try to create a few modules. At the moment, I would not know where to start creating these.

Cheers

Mark
Modules can be a bit tricky and are a lot more work than just hacking a core file but they are more transportable and sit outside the code.

What I suggested was a plugin actually. These dont get installed via the 68C admin at all, they are basically just php scripts that sit in the /plugins folder and are called by using their name in curly brackets from within a template. Just like the featured listing plugin.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
v4.0.x feature listings see in parent category hel68c Modules / Plugins / Modifications 8 10-28-2009 01:26 PM
Display sub-listings in parent category? wabugi Pre Sales Questions 2 03-14-2009 03:59 PM
how to get parent category name j890432m Technical Support 4 06-20-2008 05:30 PM
Parent Child Help Unregistered Pre Sales Questions 1 02-06-2008 04:07 PM
See subcatory listing in parent category ($ will pay $) Gear v3.1 Modules & Modifications 2 05-29-2007 09:29 PM


All times are GMT -4. The time now is 07:22 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0