Advertisement:

Author Topic: SOLVED -Need to show parent category in listing  (Read 751 times)

MGD4me

  • Newbie
  • *
  • Posts: 15
SOLVED -Need to show parent category in listing
« on: April 22, 2018, 09:18:20 pm »
First off, great program. Easy to set up, and has a 'ton' of features!

I am using the Bender theme. My application for Classified Ads only has 2 main (parent) categories: 'For Sale' and 'Looking to Buy'. Each of these two main categories has a number of sub-categories. All this works fine, so far.

The 'problem' (for me) is that all listings look very similar to the viewer, and it can be difficult to tell whether a product Ad is 'For Sale' or if someone is 'Looking to Buy' that item, unless the advertiser specifically mentions this fact in the description. At the top of the individual item page, the sub-categories are correctly displayed, but the parent category is not indicated.

What I would like to do, is to automatically include the parent directory as part of the item description. I believe that the extra code should be palced in 'item.php'.  I can succesfully place extra text as part of the description, but I cannot find a way to provide the parent category of the item being listed. For example, if I add this:

$parentCategory = osc_get_category('id', $aCategory['fk_i_parent_id']);  ...  the displayed result is 'ARRAY'.

If instead I use:  $cat= (osc_category_name()) ;  it  always prints 'For Sale' (category 1) whether the item parent category is 'For Sale' or 'Looking to Buy'.

Any help would definitely be appreciated.

Thanks
« Last Edit: April 25, 2018, 09:28:01 am by MGD4me »

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Need to show parent category in listing
« Reply #1 on: April 22, 2018, 10:13:16 pm »
Search in google marius ciclistu ft min word len and you will find how to filter item title and descriptuon before sending it to db.

MGD4me

  • Newbie
  • *
  • Posts: 15
Re: Need to show parent category in listing
« Reply #2 on: April 23, 2018, 03:21:30 am »
Search in google marius ciclistu ft min word len and you will find how to filter item title and descriptuon before sending it to db.

From what I can determine from this solution, is a way to get around the inability of the Search function to find words which are 3 characters or less.

What I need, is a way to display the main, or parent category, of individual items which are already posted.

Thanks

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Need to show parent category in listing
« Reply #3 on: April 23, 2018, 08:08:15 am »
That filter can be used to insert category name into description on item add and item edit.

(I impose users to use in item's title:
I sell and I seek or Selling /seeking.)

You could do a query for the whole db to be updated or in item.php print the main category of that item.

https://doc.osclass.org/HItems.php

https://doc.osclass.org/HCategories.php


« Last Edit: April 23, 2018, 08:12:07 am by marius-ciclistu »

MGD4me

  • Newbie
  • *
  • Posts: 15
Re: Need to show parent category in listing
« Reply #4 on: April 23, 2018, 09:33:59 am »
Quote
I impose users to use in item's title

Ha! I wish I could be so lucky! That would make life so much easier.

I will re-read the two references above to see if I can figure out how to extract the parent category, which was my main objective.

Thanks again!

Resta

  • Sr. Member
  • ****
  • Posts: 345
Re: Need to show parent category in listing
« Reply #5 on: April 25, 2018, 05:13:19 am »
Try this and say thanks to Teseo (I think).

<?php $aCategories = Category::newInstance()->hierarchy( osc_item_category_id() );
               echo '<a href="' . osc_search_url(array('sCategory' => $aCategories[0]['pk_i_id'])). '">' . $aCategories[0]['s_name'] . '</a> - ';
            ?>

MGD4me

  • Newbie
  • *
  • Posts: 15
Re: Need to show parent category in listing
« Reply #6 on: April 25, 2018, 09:18:41 am »
@Resta...

A big Thanks !!!  That wasn't quite it, as is resulted in the sub-category being display. I was wanting the Main Category.

But, with the clue you provided, I was able to change it slightly, so that it works the way I needed:

    $aCategories = Category::newInstance()->hierarchy( osc_item_category_id() );
    $cat = '<a href="' . osc_search_url(array('sCategory' => $aCategories[0]['fk_i_parent_id'])). '">' . $aCategories[1]['s_name'] . '</a> : ';