Adding a field in the backend to allow a user post a url to create a button?

Home Forums Calendar Products Events Calendar PRO Adding a field in the backend to allow a user post a url to create a button?

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1278033
    James O’Sullivan
    Participant

    Hi there, does the Event Calendar plugin have an option to enable another field in the backend somewhere here: http://recordit.co/vo4zNhhpYq so we can just paste the URL in? Then on the frontend a Book Now button would appear or link?

    Basically I have alot of contributed to my site as its a community site and we have alot of third party sites that handle the bookings. So I want to make it really easy for my users to fill out the custom link and on the frontend it just says book now basically. Kind of like the website field that exists right now but this would just say book now on the frontend?

    Any ideas on this one?
    Thanks,
    James

    #1278974
    Trisha
    Member

    Hello, James!

    Thank you for using The Events Calendar! I can help with this ?

    We do indeed have something like this! Got to Events > Settings > Additional Fields in the WordPress admin area. It will look something like this:

    When you add your event you’ll see the field just below the website field you mentioned:

    And it will appear on the front-end like so:

    Does this help answer your question? Let me know how it goes!

    Cheers,
    Trisha

    #1280310
    James O’Sullivan
    Participant

    Thank you, it kinda helps me here but it would be a little nicer to have the link hidden and just a button present itself here. Basically I am looking to have something visible and easy for my site contributors to update. Right now that would just be a link and for a book now facility it should really be a little more “stand out” if that makes sense. Is it easy to add some css here to turn this into a button for example? Or is that too much customization for a support thread? Thanks

    #1281455
    Trisha
    Member

    Hello, James!

    I understand! The easiest way to get the more precise look you want is to use a plugin called Advanced Custom Fields (ACF). You can find that here: https://wordpress.org/plugins/advanced-custom-fields/

    After you install the plugin on your site you need to add the fields for your button. You can find links to documentation for Advanced Custom Fields on the link above.

    Your fields should look something like this in the ACF admin area:

    Important to note:

    1. Remember the field names that you use, you will need them later.
    2. Select ‘Post Type is equal to tribe_events’ so that the meta box will display on the Events post type.
    3. I chose ‘side’ for the placement of the box but you have other choices, it doesn’t matter which one you choose for the meta box to work properly.

    It looks like this on the Add Event screen:

    You will need to move the ‘Single Event Meta (Organizer) Template into your theme in order to do finish this customization. The template is located at the-events-calendar/src/views/modules/meta/organizer.php there are instructions at the top of the file you’re moving. If you would like more detailed instructions you can also reference the  Themer’s Guide.

    Add the following code to the bottom of the file right before the closing ‘</div>’

    https://gist.github.com/trishasalas/26a90dbbc05f93100664a5e356ad74d0

    Note that I added the class ‘button’ to the link on Line 7, this causes it to inherit the default Events Calendar button style.

    This is the result:

    While this type of customization is normally outside the scope of what we support, it’s not terribly extensive and I think it can be super-useful to many. I hope it helps 🙂

    Let me know how it goes!

    Cheers,
    Trisha

    #1285588
    James O’Sullivan
    Participant

    HI Trisha,
    This is fantastic and much appreciated. I think this is super useful and really helpful for all kinds of bits and pieces people would like to add to the site.

    I am having a little bit of issue with the last step when I add the snippet to the file: the-events-calendar/src/views/modules/meta/organizer.php

    Basically I get this here: https://cl.ly/15063E2J2g3A and of course an error.

    Now when I remove the opening <?php and the closing <?php endif; ?> I then get this on the site here: https://cl.ly/1X2N1J213R2G

    Maybe you could let me know what I am doing wrong in this snippet on the last line of organizer.php

    Thanks again,

    #1287122
    James O’Sullivan
    Participant

    Ok so I had a look at the if statement and for some reason it keeps throwing an error so I decided to try this one here and it works

        <?php
    	$event_id = get_the_ID();
    	$book_now_link = get_post_meta( $event_id, 'book_now_link', true );
    	$book_now_text = get_post_meta( $event_id, 'book_now_text', true );
    	if ( (!empty ( $book_now_link )) && (!empty ( $book_now_text )) ) : ?>
    		<a class="button" href="<?php echo esc_url( $book_now_link );?>">
    			<?php echo esc_html( $book_now_text );?>
    		</a>
    <?php endif; ?>
    #1287397
    Trisha
    Member

    Hi, James!

    I’m so glad to see you got this worked out!

    I’m going to close this conversation out, but as always, if you need anything else feel free to reach out! I’m happy to help 🙂

    Cheers,
    Trisha

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Adding a field in the backend to allow a user post a url to create a button?’ is closed to new replies.