Back button linked to categories

Home Forums Calendar Products Events Calendar PRO Back button linked to categories

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #16034
    Robert
    Member

    I am sure this is a subject that could help others with a similar problem. I currently have events on my site all over the US. I have 5 WP Pages for categories for the regions in the US (Midwest, Northeast, Southeast, Southwest and West).

    My problem is when I am in an event in the Southwest category and I go to hit the “back to events” button it takes me back to all of the events (which I have labeled as National) and not the page I just came from which would be the Southwest category page.

    Is there an easy solution for this? Maybe a conditional statement that can look at categories? You help is always appreciated.

    #16058
    Rob
    Member

    Hey Robert. Interesting request; I can certainly see the value here. Let me get our dev Jonah to take a look when he hits the forums today and to see if there’s a way you can hack this.

    #16084
    Jonah
    Participant

    Hey Robert,

    Yes, you would have to use some sort of conditional logic to determine if you are in a specific category, where the back to events link takes you. The Events Calendar uses taxonomy terms for categories so you should be able to do something like this with the is_tax conditional tag (http://codex.wordpress.org/Function_Reference/is_tax) like so:


    if(is_tax('tribe_events_cat','my_cat_slug') {
    // one specific back link
    } elseif(is_tax('tribe_events_cat','another_cat_slug') {
    // another specific back link
    } else {
    // a general back link
    }

    Does that help?

    #16344
    Robert
    Member

    Thanks Jonah That helps. I will let you know when I have it working.

    #16345
    Robert
    Member

    Well I guess I do have a question. Would I add this code within the single.php or would I need to grab another file from ECP directory?

    #16346
    Robert
    Member

    Also, how would that work for the venue? The venue also has that link there. So is there any way to not look at category and maybe look at what source the page was generated from?

    This method would work for main events but i don;t know how to make venue work.

    #16347
    Robert
    Member

    This will not work in my case even for events.When you click on an event to view it the url changes from events/midwest ==> event/”event name”. It does not carry the category with it when you enter the event. Any suggestion on where to go from here?

    It almost seems as if ECP needs to look at the URL of the page you are on and carry it within the event once clicked into. Maybe pass a variable via tribe_get_events_link

    #16377
    Rob
    Member

    Thanks for the follow-ups, Robert. Got this back on Jonah’s plate today so you should expect a response from him shortly.

    #16383
    Jonah
    Participant

    Hi Robert, you should be able to make the change in /wp-content/plugins/the-events-calendar/views/single.php and /wp-content/plugins/the-events-calendar/views/single-venue.php and it should work to wrap those conditions around the links, determining which category you are on and displaying the appropriate link.

    #16434
    Robert
    Member

    Okay I am still having trouble. I have implemented the code but still no luck. Maybe I am coding wrong. Can you take a look? http://pastebin.com/ViiYMnEb

    My site example http://dev.championroper.com/events/category/midwest/

    #16489
    Jonah
    Participant

    Hey Robert, no problem, we’ll get this sorted out. I steered you in the wrong direction actually. is_tax should only be used for taxonomy archive lists and wouldn’t be used for single post views. You can use has_terms() instead like so: https://gist.github.com/2004548

    You’ll want to replace the categories and add others as needed. The only downside to this approach is if an event is in two of your categories.

    I hope that helps!

    #16496
    Robert
    Member

    Works like a charm! Thanks Jonah. One issue that might be worth while to figure out is the venue back button. The code given for the category link back works great, but the venue (since it is in the event) will not go back to the previous page the user was on, instead it goes to category. I could leave it, but what if I wanted to link it to the event I was on?

    If I was a small events site this would not be much trouble to update the file every now and then. In my case I have 200 to 300 events in the system and growing. Is there a function I could run passing the previous pages link? Surely ECP knows what venue is in what event.

    Any suggestions or a path you could guide me down?

    #16541
    Jonah
    Participant

    Hey Robert,

    It would be difficult to detect the exact event that the user just came from because venues can be assigned to many events so you’d somehow have to store the event the user came from and use that for the back link. I think the easiest method for this would be to simply put a javascript back link: http://www.w3schools.com/jsref/met_his_back.asp

    The only downside to this is if the person came to the venue some other way, then the back button would not function in the way you want (it would always go back to whatever the previous page was in the browsing history).

    Does that make sense?

    #16544
    Robert
    Member

    Hey Jonah,

    No that makes perfect sense. This brings up an idea to work around. My skills are so far away from attempting this but is there a way to set up conditional logic to basically look at if the user came from an external site or from my site? So if the user came from somewhere other than my site, send user back to main events, but if user came from somewhere within my site, send them back to the previous page? Does that make sense? Also do you think it can be done or do you see a hole I am not seeing?

    BTW, Thanks again for all your help. You guys are simply the best WordPress plugin developers and support group, hands down!

    #16639
    Jonah
    Participant

    Hi Robert, that’s pretty out my league but I’m thinking you may want to do some sort of conditional 301 redirects. I took a quick look on Google and it looks like there are some good ideas there, like this: http://schoonology.com/a-proper-migration-conditionally-apply-a-301-redirect-with-wordpress/

    Hopefully that will point you in the right direction!

Viewing 15 posts - 1 through 15 (of 16 total)
  • The topic ‘Back button linked to categories’ is closed to new replies.