Advertisement:

Author Topic: SOLVED - How to show categories list under item owner profile on item page  (Read 599 times)

muratbora

  • Sr. Member
  • ****
  • Posts: 261
How to show categories list ( only parent ) under item owner profile on item page? item-sidebar.php?
« Last Edit: September 16, 2019, 10:03:17 am by muratbora »

vivekshan

  • Full Member
  • ***
  • Posts: 113
Re: How to show categories list under item owner profile on item page
« Reply #1 on: September 01, 2019, 10:08:12 pm »
<?php
 $aCategory = osc_get_category('id', osc_item_category_id());
            $parentCategory = osc_get_category('id', $aCategory['fk_i_parent_id']);
           

            View::newInstance()->_erase('categories');
            View::newInstance()->_erase('subcategories');
            View::newInstance()->_exportVariableToView('category', $parentCategory);
$cat = osc_category_name();
            echo $cat;
                   
?>


mark this thread as solved.

muratbora

  • Sr. Member
  • ****
  • Posts: 261
Re: How to show categories list under item owner profile on item page
« Reply #2 on: September 10, 2019, 09:27:37 pm »
It shows only 1 category name ( related of item). not whole parent categories of sites.
Also it is not clickable, Just plain text

I tried to use this;
<?php _e('Refine category', 'bender_black') ; ?></h3>
            <?php bender_black_sidebar_category_search($category['pk_i_id']); ?>

but it is also indicating single category name ( category of item), but at least it is clickable!

vivekshan

  • Full Member
  • ***
  • Posts: 113
Re: How to show categories list under item owner profile on item page
« Reply #3 on: September 11, 2019, 09:17:46 pm »
sorry dear i thought you were asking to print parent category name

So now your solution is

Here you GO............!

<?php
         //cell_3
        $total_categories   = osc_count_categories();
        $col1_max_cat       = ceil($total_categories/3);
         osc_goto_first_category();
         $i      = 0;
         while ( osc_has_categories() ) {
         ?><?php
                    $_slug      = osc_category_slug();
                    $_url       = osc_search_category_url();
                    $_name      = osc_category_name();
                    $_total_items = osc_category_total_items();
                    if ( osc_count_subcategories() > 0 ) { ?>
                    <span class="collapse resp-toggle"><i class="fa fa-caret-right fa-lg"></i></span>
                    <?php } ?>
                    <?php if($_total_items > 0) { ?>
                    <a class="category <?php echo $_slug; ?>" href="<?php echo $_url; ?>"><?php echo $_name ; ?></a> <span>(<?php echo $_total_items ; ?>)</span>
                    <?php } else { ?>
                    <a class="category <?php echo $_slug; ?>" href="<?php echo $_url; ?>"><?php echo $_name ; ?></a> <span>(<?php echo $_total_items ; ?>)</span>
                    <?php } ?> 
<?php } ?>

vivekshan

  • Full Member
  • ***
  • Posts: 113
Re: How to show categories list under item owner profile on item page
« Reply #4 on: September 11, 2019, 09:21:10 pm »
if you dont want to show items count then its the code
<?php
         //cell_3
        $total_categories   = osc_count_categories();
        $col1_max_cat       = ceil($total_categories/3);
         osc_goto_first_category();
         $i      = 0;
         while ( osc_has_categories() ) {
         ?><?php
                    $_slug      = osc_category_slug();
                    $_url       = osc_search_category_url();
                    $_name      = osc_category_name();
                    $_total_items = osc_category_total_items();
                    if ( osc_count_subcategories() > 0 ) { ?>
                    <span class="collapse resp-toggle"><i class="fa fa-caret-right fa-lg"></i></span>
                    <?php } ?>
                    <?php if($_total_items > 0) { ?>
                    <a class="category <?php echo $_slug; ?>" href="<?php echo $_url; ?>"><?php echo $_name ; ?></a>
                    <?php } else { ?>
                    <a class="category <?php echo $_slug; ?>" href="<?php echo $_url; ?>"><?php echo $_name ; ?></a>
                    <?php } ?>  <?php } ?>


If this code helps you then Mark this thread as SOLVED

muratbora

  • Sr. Member
  • ****
  • Posts: 261
Re: How to show categories list under item owner profile on item page
« Reply #5 on: September 12, 2019, 08:38:16 pm »
Yes I just wanted to print parent ( main ) category names on item-sidebar.php,
This may help to SEO for spiders ( internal link building )

But your code shows only 1 category name and repeating several times.

See secreenshoot

vivekshan

  • Full Member
  • ***
  • Posts: 113
Re: How to show categories list under item owner profile on item page
« Reply #6 on: September 12, 2019, 11:05:26 pm »
Oops

now use this corrected code

Here you GO.......!


<div class="resp-wrapper">
         <?php
         //cell_3
        $total_categories   = osc_count_categories();
        $col1_max_cat       = ceil($total_categories/3);
        osc_goto_first_category();
         $i      = 0;
         while ( osc_has_categories() ) {
         ?>
        <?php
            if($i%$col1_max_cat == 0){
                if($i > 0) { echo ''; }
                if($i == 0) {
                   echo '';
                } else {
                    echo '';
                }
            }
        ?><?php
                    $_slug      = osc_category_slug();
                    $_url       = osc_search_category_url();
                    $_name      = osc_category_name();
                    $_total_items = osc_category_total_items();
                    if ( osc_count_subcategories() > 0 ) { ?>
                    <p><li><span class="collapse resp-toogle"><i class="fa fa-caret-right fa-lg"></i></span>
                    <?php } ?>
                    <?php if($_total_items > 0) { ?>
                    <a class="category <?php echo $_slug; ?>" href="<?php echo $_url; ?>"><?php echo $_name ; ?></a> <span>(<?php echo $_total_items ; ?>)</span></li></p>
                    <?php } else { ?>
                    <a class="category <?php echo $_slug; ?>" href="<?php echo $_url; ?>"><?php echo $_name ; ?></a> <span>(<?php echo $_total_items ; ?>)</span></li></p>
                    <?php } ?><?php if ( osc_count_subcategories() > 0 ) { ?>
                         <?php while ( osc_has_subcategories() ) { ?>
                         <?php } ?><?php } ?>
        <?php
                $i++;
            }
            echo '</div>';
        ?>

Use this code and let me know.

muratbora

  • Sr. Member
  • ****
  • Posts: 261
Re: How to show categories list under item owner profile on item page
« Reply #7 on: September 13, 2019, 12:46:24 am »
Yes now ok, thank you so much!

vivekshan

  • Full Member
  • ***
  • Posts: 113
Re: How to show categories list under item owner profile on item page
« Reply #8 on: September 13, 2019, 11:23:11 am »
Mark this thread as SOLVED

elizabeth

  • Jr. Member
  • **
  • Posts: 80
Re: How to show categories list under item owner profile on item page
« Reply #9 on: September 14, 2019, 11:42:12 pm »
Oops

now use this corrected code

Here you GO.......!


<div class="resp-wrapper">
         <?php
         //cell_3
        $total_categories   = osc_count_categories();
        $col1_max_cat       = ceil($total_categories/3);
        osc_goto_first_category();
         $i      = 0;
         while ( osc_has_categories() ) {
         ?>
        <?php
            if($i%$col1_max_cat == 0){
                if($i > 0) { echo ''; }
                if($i == 0) {
                   echo '';
                } else {
                    echo '';
                }
            }
        ?><?php
                    $_slug      = osc_category_slug();
                    $_url       = osc_search_category_url();
                    $_name      = osc_category_name();
                    $_total_items = osc_category_total_items();
                    if ( osc_count_subcategories() > 0 ) { ?>
                    <p><li><span class="collapse resp-toogle"><i class="fa fa-caret-right fa-lg"></i></span>
                    <?php } ?>
                    <?php if($_total_items > 0) { ?>
                    <a class="category <?php echo $_slug; ?>" href="<?php echo $_url; ?>"><?php echo $_name ; ?></a> <span>(<?php echo $_total_items ; ?>)</span></li></p>
                    <?php } else { ?>
                    <a class="category <?php echo $_slug; ?>" href="<?php echo $_url; ?>"><?php echo $_name ; ?></a> <span>(<?php echo $_total_items ; ?>)</span></li></p>
                    <?php } ?><?php if ( osc_count_subcategories() > 0 ) { ?>
                         <?php while ( osc_has_subcategories() ) { ?>
                         <?php } ?><?php } ?>
        <?php
                $i++;
            }
            echo '</div>';
        ?>

Use this code and let me know.

@vivekshan how can i use your code so it will return only subcategories (not parent categories), that contain listings ONLY from this owner ?
Thanks for your help in advance.
« Last Edit: September 14, 2019, 11:56:28 pm by elizabeth »

vivekshan

  • Full Member
  • ***
  • Posts: 113
Re: How to show categories list under item owner profile on item page
« Reply #10 on: September 15, 2019, 10:53:37 am »
Where you want to print this function ?

muratbora

  • Sr. Member
  • ****
  • Posts: 261
Re: How to show categories list under item owner profile on item page
« Reply #11 on: September 15, 2019, 08:26:45 pm »
I used this code for item-sidebar.php was aiming to build internal link

Here url I used and it show only parent categories ; https://www.turkeycarrentalcompany.com/tr/havalimani-arac-kiralama/zonguldak-kiralik-arac-oto-araba-ilani-verme-sitesi-ucretsiz-kiralama_i364

vivekshan

  • Full Member
  • ***
  • Posts: 113
Re: How to show categories list under item owner profile on item page
« Reply #12 on: September 15, 2019, 10:05:21 pm »
I used this code for item-sidebar.php was aiming to build internal link

Here url I used and it show only parent categories ; https://www.turkeycarrentalcompany.com/tr/havalimani-arac-kiralama/zonguldak-kiralik-arac-oto-araba-ilani-verme-sitesi-ucretsiz-kiralama_i364
its look great site but your website (every page of your website) must have below 100 links

google hates links counts more than 100 on a page

i know many functions of osclass and even created my own function but all functions i can't apply

it can make google unhappy

see my website

http://locantou.com/

and Mark this thread as SOLVED (edit your first post)
« Last Edit: September 15, 2019, 10:18:39 pm by vivekshan »

muratbora

  • Sr. Member
  • ****
  • Posts: 261
Re: SOLVED - How to show categories list under item owner profile on item page
« Reply #13 on: September 16, 2019, 10:09:07 am »
More than 100 links is not % 100 negative affect of your site. it is a just small percentage (1%) within more than 300 SEO criterias...

Yes it is not good but another side on osclass item page showing categories / cities is helping more views of pages. Also help to easy crawling for spiders.

From this point (++++) has more than (-----),


moinuddin

  • Full Member
  • ***
  • Posts: 190
Re: SOLVED - How to show categories list under item owner profile on item page
« Reply #14 on: September 16, 2019, 05:17:41 pm »
The code is working ...but subcategories not shown only main categories and on click on main categories it opens all products listed under main categories (actually products are listed under subcategories inside main categories)...hence all products are shown instead of subcategory dropdown....can any one help?