Whole Search Bar on another page.

Home Forums Calendar Products Events Calendar PRO Whole Search Bar on another page.

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #839962
    calumjamesgreen
    Participant

    Hi creating a new ticket as I posted this off the back of someone else but I am looking for the entire search bar that is used in the events pro to be able to be used on another page. Basically I want the bar to be put on my home page and then from there users could use it , hit search and they will be taken to the same place as if it was being used on the calendar page.

    Thanks for any help.
    ————————

    I’ll go ahead and close this ticket. When opening another ticket, it’ll be helpful to clarify exactly what you would like to display on your homepage. For example, are you wanting this entire bar to display on your homepage or was it something simpler you were looking for?

    #840023
    jordan0286
    Participant

    Hi, i’m looking for exactly the same thing.
    TY for help

    #841020
    Geoff
    Member

    Hi there, Calum! Nice to see you again and hope all is well. πŸ™‚

    That’s an interesting question! The search bar is broken into its own module (/the-events-calendar/views/modules/bar.php), so you could grab the code from there, or PHP include it in the theme file(s) where you want it to be used.

    That will pull the code in, but will leave out the other scripts and styles needed for it to display and function properly. You can overcome this by enqueuing those scripts in your functions.php file.

    Here’s what that might look like:
    https://gist.github.com/geoffgraham/510e158ae56a77ed9e76

    Of course, you may need to customize this to suit your specific needs and theme, and also you likely will not need the opening and closing PHP tags. Though this is the sort of customization we’ll leave in your hands, it should point you in the right direction.

    Does that make sense? Will that work for you? Please let me know. πŸ™‚

    Cheers!
    Geoff

    #841279
    calumjamesgreen
    Participant

    Hi Geoff,

    Thanks for getting back to me that is really helpful, I was already using the script inside the bar.php but the code kept throwing an error when using the [insert_php] plugin. I have added your script that you have sent through and tried it in both the functions.php and using the [insert_php] plugin however it keep throwing an error

    in the script I get this error:
    Fatal error: Call to undefined function add_action() in /wp-includes/functions.php on line 4665

    and in the plugin

    Fatal error: Cannot redeclare tribehome_enqueue_front_page_scripts() (previously declared in /wp-content/plugins/insert-php/insert_php.php(48) : eval()’d code:4) in /wp-content/plugins/insert-php/insert_php.php(48) : eval()’d code on line 32

    Any Idea’s

    Thanks πŸ™‚ Calum

    #842049
    Geoff
    Member

    Hi there, Calum! Thanks for following up.

    Honestly, I unfamiliar with the Insert PHP plugin, but I would suggest adding the bar.php code and snippet to your files manually. I have a feeling that the plugin may not be inserting the code properly.

    Are you able to give that a shot? Please let me know.

    Cheers!
    Geoff

    #842090
    jordan0286
    Participant

    Hi everyone.

    Doesn’t works even if i paste the php code into a php file (like search template) and add the code in functions.php

    When I paste the code into the search template I get some search inputs but useless and without design.
    When I paste the code into the functions.php I get a blank page.

    To resume, we’d like to add the search bar on antoher page than the calendar one (on a header of a homepage for exemple), and when we’ll search on it, it will bring us to the calendar page with the good search results.

    Best regards

    #845049
    calumjamesgreen
    Participant

    Hi Geoff,

    As with Jordan I am having no luck with this. :/ Really bugging me now I know my php isn’t top notch but theoretically it should be simple haha. πŸ™‚

    Any more input πŸ˜›
    Thanks for all your help
    Calum

    #845075
    jordan0286
    Participant

    Calum I trie something but it doesn’t works very well.
    Here is what I did :

    In my theme, I have a template page called Search Page that make appears a search box. In appearance then editor I search the Search Page template (page-search.php), and I remplace the original input type with this one :

    <input type=”hidden” value=”tribe_events” name=”post_type” id=”post_type” />

    Just the value is modified here.

    Now I have a search box in the search page that goes to the calendar page when I search something. It works but it only search on the current month (for exemple if I had an event in november, it says “sorry, try the same search word in another month”, think like that). Also, it doesn’t takes the tags in the search results. Not really what I wanted… I would like the same bar search as in calendar page.

    Maybe someone who passes here will be able to help us. The problem seems simple, but it doesn’t work.

    Sorry for my english langage, I’m french.

    #846748
    Geoff
    Member

     

    Hey there, Calum! Thanks for following up. πŸ™‚

    A similar approach to the one I shared is detailed a little more thoroughly in this post:
    http://gregorypearcey.com/blog/add-tribe-events-search-bar-home-page/

    It focuses on placing the bar only on the homepage, but it gives you an idea of how it could work on any other page as well.

    jordan0296, it looks like the original approach I outlined was actually working for you as well, but you may not have correctly added the snippet to your functions.php file. Note that you may need to remove the opening and closing PHP brackets in the snippet when you place it in there. A blank screen implies a PHP formatting issue rather than the snippet not working. πŸ™‚

    It’s that snippet that will add the design elements you said were missing.

    I’m going to continuing answer Calum’s questions in this thread since she originally opened it. Anyone else is certainly welcome to follow along but, if you are experiencing your own issue, I suggest opening up a new thread so we can concentrate on one question at a time. πŸ™‚

    Cheers!
    Geoff

    #846908
    calumjamesgreen
    Participant

    Thanks for getting back Geoff, I appreciate this is probably outside of support that is meant to be offered and I appreciate it.

    I have it almost working using the [insert_php] but the formatting is still fuzzy so I have tried creating a page template to be applied to the home page and have this error. Am I missing something clear?

    [Error] ReferenceError: Can’t find variable: tribe_ev
    global code (tribe-events-bar.js, line 334)

    Thanks Again

    #846927
    Geoff
    Member

    No worries, Calum! I’m happy to answer your questions and will always do my best to point you in the right direction. πŸ™‚

    Are you able to follow the steps in the link I sent over without relying on the [insert_php] plugin? I think that’s becoming a stumbling point to getting this to work properly. I realize it requires touching some code and templates that might be a little outside your comfort zone, but the effort will pay off for sure. Otherwise, it may be something worth reaching out to a developer for.

    Cheers!
    Geoff

    #846941
    calumjamesgreen
    Participant

    Yeah I have created a plugin for
    function tribehome_enqueue_front_page_scripts()
    and activated it.

    I have then created a new page template and added the script for
    <div id=”tribe-events-bar”>

    I think it might be this part I am missing Next I had to enqueue the styles for the search bar as well as the scripts for the date picker as is suggested on the Tribe Forum.?

    #846983
    Geoff
    Member

    Yeah, the plugin you created is what should be enqueuing those styles for you. Alternatively, you can disable that plugin and paste this snippet into your functions.php file instead. It also enqueues those styles.

    The thing to note about the snippet is that it specifically targets the homepage. You will want to modify the snippet to target your specific template or pages.

    I hope this helps!

    Geoff

    #846994
    calumjamesgreen
    Participant

    Yeah I think that the theme I’m using might be playing with the homepage so although it is targeting the homepage its not recognising it as the homepage, I will see if I can amend it to target that specific page template and see if I have any luck.

    Ill let you know πŸ™‚

    #847655
    Geoff
    Member

    Awesome, please keep me posted. πŸ™‚

Viewing 15 posts - 1 through 15 (of 18 total)
  • The topic ‘Whole Search Bar on another page.’ is closed to new replies.