The hSearch.php helper in Osclass is designed to facilitate all aspects of search functionality on your classifieds website. It provides functions to retrieve the search object, obtain search criteria (such as selected region, city, price range, and category), generate dynamic search URLs with updated parameters, and manage the presentation of search results. In addition, the helper offers functions for listing locations on the sidebar and for handling the latest searches performed by users.
osc_search() – Gets the search object.
osc_list_orders() – Retrieves the available search orders.
osc_search_page() – Gets the current search page number.
osc_search_total_pages() – Gets the total number of pages for the current search.
osc_search_has_pic() – Returns true if the “has pic” option is enabled in the search; otherwise, false.
osc_search_order() – Gets the current search order.
osc_search_order_type() – Gets the current search order type.
osc_search_pattern() – Gets the current search pattern.
osc_search_region() – Gets the current search region.
osc_search_city() – Gets the current search city.
osc_search_price_max() – Gets the current search maximum price.
osc_search_price_min() – Gets the current search minimum price.
osc_search_total_items() – Gets the total number of items matching the current search criteria.
osc_search_show_as() – Gets the current “show as” setting for search results (e.g., list or gallery view).
osc_search_start() – Gets the starting record number for the current search results.
osc_search_end() – Gets the ending record number for the current search results.
osc_search_category() – Gets the current search category.
osc_search_category_id() – Gets the current search category ID.
osc_update_search_url($params, $delimiter = '&') – Updates the search URL with new options.
osc_alert_form() – Loads the form for alert subscription.
osc_search_alert() – Retrieves the alert for the current search.
osc_search_show_all_url() – Gets the URL for a default search (all categories, with no additional options).
osc_search_url($params = null) – Generates a search URL based on the provided parameters.
osc_list_country() – Gets the list of countries with items.
osc_list_region() – Gets the list of regions with items.
osc_list_city() – Gets the list of cities with items.
osc_has_list_countries() – Retrieves the next country from the list of countries.
osc_has_list_regions($country = '%%%%') – Retrieves the next region from the list of regions for a given country.
osc_has_list_cities($region = '%%%%') – Retrieves the next city from the list of cities for a given region.
osc_count_list_countries() – Gets the total number of countries in the list.
osc_count_list_regions($country = '%%%%') – Gets the total number of regions for the given country.
osc_count_list_cities($region = '%%%%') – Gets the total number of cities for the given region.
osc_list_region_name() – Gets the name of the current list region.
osc_list_region_items() – Gets the number of items in the current list region.
osc_list_city_name() – Gets the name of the current list city.
osc_list_city_items() – Gets the number of items in the current list city.
osc_list_country_url() – Gets the URL for the current list country.
osc_list_region_url() – Gets the URL for the current list region.
osc_list_city_url() – Gets the URL for the current list city.
osc_get_latest_searches($limit = 20) – Retrieves the latest searches performed on the website.
osc_count_latest_searches() – Gets the total number of latest searches performed on the website.
osc_has_latest_searches() – Retrieves the next latest search; returns null if there are no more.
osc_latest_search() – Gets the current latest search.
osc_latest_search_text() – Gets the search pattern of the current latest search.
osc_latest_search_date() – Gets the date of the current latest search.
osc_latest_search_total() – Gets the total number of results for the current latest search.
The hSearch.php helper in Osclass provides a rich set of functions to manage and customize search operations on your classifieds website. This document offers a detailed explanation of each function, including its parameters and return values, along with usage examples.
osc_search() – Gets the search object.
This function checks if a search object exists in the view. If it does, it returns that object; otherwise, it creates a new instance of the Search class, exports it to the view, and returns the new object.
osc_list_orders() – Retrieves available search orders.
Depending on whether the price option is enabled for items, it returns an array of search orders. When prices are enabled, the options include "Newly listed", "Lower price first", and "Higher price first". Otherwise, it returns only "Newly listed".
sOrder and iOrderType).osc_search_alert_subscribed() – Checks if the search alert is subscribed.
osc_search_page() – Gets the current search page number.
osc_search_total_pages() – Gets the total number of pages for the current search results.
osc_search_has_pic() – Checks if the "has pic" option is enabled in the search.
osc_search_only_premium() – Checks if the search is limited to premium items.
osc_search_order() – Retrieves the current search order field.
dt_pub_date or i_price).osc_search_order_type() – Retrieves the current search order type.
asc or desc).osc_search_pattern() – Retrieves the search pattern input by the user.
osc_search_country() – Retrieves the search country parameter.
osc_search_region() – Retrieves the search region parameter.
osc_search_city() – Retrieves the search city parameter.
osc_search_user() – Retrieves an array of users involved in the search criteria.
osc_search_price_max() – Retrieves the maximum price filter from the search criteria.
osc_search_price_min() – Retrieves the minimum price filter from the search criteria.
osc_search_total_items() – Retrieves the total number of items matching the search criteria.
osc_search_show_as() – Retrieves the display mode for search results (e.g., list or gallery).
osc_search_start() – Retrieves the starting index for search results on the current page.
osc_search_end() – Retrieves the ending index for search results on the current page.
osc_search_category() – Retrieves the current search category or categories.
osc_search_category_id() – Retrieves the ID(s) of the current search category.
osc_update_search_url($params, $forced = false) – Updates the search URL by merging new parameters with the current request.
sCategory, sRegion, sCity, iPage, etc.).osc_alert_form() – Loads the alert subscription form.
osc_search_alert() – Retrieves the alert message for the current search.
osc_search_show_all_url($params = array()) – Generates a URL for a default search (all categories, no extra options).
osc_search_url($params = null) – Generates the search URL based on the provided parameters.
The hSearch.php helper is a critical component for building and customizing search functionality in Osclass. It enables you to:
osc_search().osc_list_orders(), which adjusts based on whether pricing is enabled.osc_search_page() and osc_search_total_pages().osc_search_has_pic()), premium status (osc_search_only_premium()), and search keywords (osc_search_pattern()).osc_search_country(), osc_search_region(), and osc_search_city().osc_update_search_url() and osc_search_url().osc_alert_form() and osc_search_alert().Parameter Options:
sCategory – Category slug or ID.sRegion – Region identifier.sCity – City identifier.iPage – Page number for pagination.sPattern – Search keyword or pattern.sCountry, sUser, etc.sCategory or sCountry) may be automatically removed or adjusted.osc_search() returns a Search object, while osc_list_orders() returns an array of order options.By leveraging the hSearch.php helper, you can create a robust, customizable search experience that enhances both usability and SEO for your classifieds website.