Home Forums Themeqx Advanced PhP Laravel Classified ads cms Error when placing category search on all pages

  • #367

    mobius1980
    Participant

    871

    Error when placing category search on all pages

    Hi there, I am trying to insert (copying from original) a search box using the input field and the category lines on all pages, this works fine on listing page but throws errors every time I use it on any other page. Just wondering if there are any tricks for getting the categories in other pages?

Viewing 5 replies - 1 through 5 (of 5 total)
  • #373

    Hi

    Please provide your URL here. we will check.

    Best regards

    #384

    mobius1980
    Participant

    Hello, sorry I only have it as a local installation at present. I simply copied the search form from the index.blade and pasted it in my header.balde which then throws errors on every single page.

    It seems I am missing an important piece of information to make this work

    #394

    Ok, then you need to pass this category variable to all of the pages, though we’ve used some global variable to access them from all of the view pages.

    This is the code $top_categories = Category::whereCategoryId(0)->orderBy('category_name', 'asc')->get(); look at controller. you need make it for global accessible.

    If you are a developer, then you will understand. I’m giving you a piece of code.

    At file root/app/Providers/AppServiceProvider.php

    Delete below code from line 53 to 63

    view()->composer('*', function ($view) {
                    $header_menu_pages = Post::whereStatus('1')->where('show_in_header_menu', '1')->get();
                    $show_in_footer_menu = Post::whereStatus('1')->where('show_in_footer_menu', '1')->get();
    
                    $enable_monetize = get_option('enable_monetize');
                    $loggedUser = null;
                    if (Auth::check()) {
                        $loggedUser = Auth::user();
                    }
                    $view->with(['lUser' => $loggedUser, 'enable_monetize' => $enable_monetize, 'header_menu_pages' => $header_menu_pages, 'show_in_footer_menu' => $show_in_footer_menu]);
                });

    Add below code right that place

    view()->composer('*', function ($view) {
                    $header_menu_pages = Post::whereStatus('1')->where('show_in_header_menu', '1')->get();
                    $show_in_footer_menu = Post::whereStatus('1')->where('show_in_footer_menu', '1')->get();
            $top_categories = Category::whereCategoryId(0)->orderBy('category_name', 'asc')->get();
    
                    $enable_monetize = get_option('enable_monetize');
                    $loggedUser = null;
                    if (Auth::check()) {
                        $loggedUser = Auth::user();
                    }
                    $view->with(['lUser' => $loggedUser, 'enable_monetize' => $enable_monetize, 'top_categories' => $top_categories, 'header_menu_pages' => $header_menu_pages, 'show_in_footer_menu' => $show_in_footer_menu]);
                });

    That’s it, this should now work

    Best regards

    #441

    mobius1980
    Participant
    This reply has been marked as private and you are not authorised to see.
    #454

    Hi

    I’ve placed a customized code only for you, you can now call categories to any pages without getting any errors 🙂

    To support us, please place a 5-star rating to our product (if you have time) https://codecanyon.net/item/getfund-a-professional-laravel-crowdfunding-platform/19769953

    We will be very glad if you place a good review. You can do that from https://codecanyon.net/downloads

    Best regards

Viewing 5 replies - 1 through 5 (of 5 total)

Purchase for access

Buy a copy of Themeqx Advanced PhP Laravel Classified ads cms for access to our member center.

Buy