*

webcity

  • ****
  • 243 posts
Use category description in category search results
« on: June 14, 2022, 12:13:30 PM »
Hi,

I would like to use the settings/categories/description information at the bottom of the first page of the category search results.

This is to help with SEO, a lot of popular classified sites show a description of the category which really helps with SEO.

Can anyone suggest the code to use to show the description text in the search.php file?

You can see an example at the bottom of this page: https://www.locanto.co.uk/Men-s-Clothes/425/

Many thanks
« Last Edit: June 14, 2022, 12:15:30 PM by webcity »

*

MB Themes

Re: Use category description in category search results
« Reply #1 on: June 14, 2022, 03:33:03 PM »
@webcity
Function osc_search_category() could return currently selected category object, that could contain also description.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

webcity

  • ****
  • 243 posts
Re: Use category description in category search results
« Reply #2 on: June 14, 2022, 05:31:04 PM »
Thanks for the reply and help.

Could you please suggest the php code to just show the category details just on the first search results page for the category, not on page 2+ ?

Many thanks

*

MB Themes

Re: Use category description in category search results
« Reply #3 on: June 15, 2022, 07:54:03 AM »
@webcity
I do not know how osc_search_category(), but try to check this, it seems same issue has been solved here:
https://forums.osclasspoint.com/starter-osclass-premium-theme/category-description-4739/msg22089/#msg22089
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

webcity

  • ****
  • 243 posts
Re: Use category description in category search results
« Reply #4 on: June 15, 2022, 08:52:09 AM »
Thanks for your help.

The code:
Code: [Select]
$cat = Category::newInstance()->findByPrimaryKey($search_cat_id);
echo @$cat['s_description']

The code works great!

I would like to just show the description text on just the first page of search results, not on the second or more pages.
Can anyone suggest the additional code to use?

Also, what would be good is if I could use a location tag in the description text to help with SEO.

For example text:
This is a description of my category in <location> .

Would show:
This is a description of my category in London.

Can anyone suggest a solution?

Many thanks


*

MB Themes

Re: Use category description in category search results
« Reply #5 on: June 16, 2022, 05:55:17 PM »
@webcity
This could work:
Code: [Select]
if(Params::getParam('iPage') <= 1) {
  $cat = Category::newInstance()->findByPrimaryKey($search_cat_id);
  echo @$cat['s_description']
}
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

webcity

  • ****
  • 243 posts
Re: Use category description in category search results
« Reply #6 on: June 18, 2022, 05:37:05 AM »
Thanks!

That works great :-)

*

bemtele

  • ***
  • 97 posts
Re: Use category description in category search results
« Reply #7 on: June 19, 2022, 07:10:45 PM »
Thanks!

That works great :-)

Please can you share the code you added? I don't seem to understand it. Like the HTML tag and the PHP. Did you only add the PHP or what?

*

webcity

  • ****
  • 243 posts
Re: Use category description in category search results
« Reply #8 on: June 20, 2022, 03:47:45 PM »
Hi,

I inserted the code just after the navigation buttons  code at the search.php theme file.

Here is the code snippet including the existing code on the page:

   
Code: [Select]
      <div class="paginate"><?php echo eps_fix_arrow(osc_search_pagination()); ?></div>
    </div>
<br>  
   
<?php
  
  if(Params::getParam('iPage') <= 1) {
  $cat Category::newInstance()->findByPrimaryKey($search_cat_id);
echo 
"<h3>";   
echo 
osc_esc_html(meta_title());
echo 
"</h3> <br>";   
echo @
$loc;
echo 
" ";   
echo @
$cat['s_description'];
}
  ?>

 
  </div>
</div>

<?php osc_current_web_theme_path('footer.php') ; ?>

*

bemtele

  • ***
  • 97 posts
Re: Use category description in category search results
« Reply #9 on: June 20, 2022, 05:33:09 PM »
Hi,

I inserted the code just after the navigation buttons  code at the search.php theme file.

Here is the code snippet including the existing code on the page:

   
Code: [Select]
      <div class="paginate"><?php echo eps_fix_arrow(osc_search_pagination()); ?></div>
    </div>
<br>  
   
<?php
  
  if(Params::getParam('iPage') <= 1) {
  $cat Category::newInstance()->findByPrimaryKey($search_cat_id);
echo 
"<h3>";   
echo 
osc_esc_html(meta_title());
echo 
"</h3> <br>";   
echo @
$loc;
echo 
" ";   
echo @
$cat['s_description'];
}
  ?>

 
  </div>
</div>

<?php osc_current_web_theme_path('footer.php') ; ?>


Thank you very much.

*

webcity

  • ****
  • 243 posts
Re: Use category description in category search results
« Reply #10 on: June 24, 2022, 10:26:12 AM »
I'm trying to use the location in the category description text.

For example : This is my description of <location> for sale items.

I've tried:

Code: [Select]
<?php echo @$loc ?>
But this doesn't show any info.

Can anyone suggest what code to use to show the location in the category description text?

Many thanks

*

mwindey

  • *****
  • 477 posts
Re: Use category description in category search results
« Reply #11 on: June 24, 2022, 11:17:06 AM »
@webcity

What you can use is on this page....https://docs.osclasspoint.com/hlocation-php

*

webcity

  • ****
  • 243 posts
Re: Use category description in category search results
« Reply #12 on: June 27, 2022, 10:29:25 AM »
@webcity

What you can use is on this page....https://docs.osclasspoint.com/hlocation-php

Thanks for your help.

I can't seem to get the echo command to output any of the helpers when entering the code into the category description box.

If I navigate to a city, have
Code: [Select]
<?php osc_city() ?> in the description box, it shows a blank.

Any suggestions would be welcome?

*

mwindey

  • *****
  • 477 posts
Re: Use category description in category search results
« Reply #13 on: June 27, 2022, 10:44:41 AM »
@webcity

This could work:
Code: [Select]
<?php echo osc_esc_html($search_location); ?>

*

webcity

  • ****
  • 243 posts
Re: Use category description in category search results
« Reply #14 on: June 27, 2022, 05:21:37 PM »
@webcity

This could work:
Code: [Select]
<?php echo osc_esc_html($search_location); ?>

Thanks for your help mwindey.

I couldn't get that to work either. I think it maybe because I'm calling the information from the category description with:
Code: [Select]
echo @$cat['s_description'];
and then embedding another echo command?

My programming skills are pretty basic, usually based google searches lol.

Any suggestions welcome.