Can - wrap href Custompress embed code in Events template?

<a href<?php echo do_shortcode('[ct id="ct_Website_text_f450" property="title | description | value"]'); ?> target="_blank">Visit this site</a>

Can this be used in EVENTS + template to provide desired front end behaviour.?

Want it to display in
Single entry front end.

  • Jack Kitterhing

    Hi there @be,

    Hope you're well today and thanks for your question.

    I don't believe that would work, I presume the custom field value is a link?

    If that is the case, you can use the code by my colleague Alex here https://premium.wpmudev.org/forums/topic/how-to-set-up-website-field-for-custompress#post-532666 to make custom fields clickable :slight_smile:

    Thank you!

    Kind Regards
    Jack.

  • be

    Yes am using that code to make the http clickable however..

    This requires every user to add a website into the field with the
    http:// extension - which as we all know does not necessarily do well (lots of end users who do not...)
    We also need the customfield to do a href for TEL
    so each phone number becomes mobile click to call....

    IF the custompress fields could wrap - this would work..

    as per previous thread
    https://premium.wpmudev.org/forums/topic/custompress-fields-add-to-events-front-end
    I am unable to determine if it does..

  • be

    Hi again @Vladislav
    Can you please advise, this is a busy live site and having much trouble keeping folks waiting..

    Can we wrap custompress embed code if not can this be considered or a way round..

    As to the other threads - cannot get custompress embed codes to display data front end on recurring events.. even using the shortcode in the post..
    They do display in single date events using shortcodes..

    Nor do they display at all when used in the single event template.

    Help please

  • Jack Kitterhing

    Hi there @be,

    Thanks for the additional information, in that case, the a href should technically work, though I haven't tested it does, but in theory it should :slight_smile:

    On the recurring events issues, I've just spoken with Ve about this and he's taking a look, it seems like it may be a bug, though we're not 100% sure yet, as recurring events aren't specifically checked in the template, so it shouldn't be causing an issue, though it seems it is.

    Thanks for your patience here.

    Kind Regards
    Jack.

  • be

    Thanks again @Jack Kitterhing

    Can you please confirm for me that any Custompress Template embed code works?

    Have tested gone to default template etc etc..
    using the embed code including non wrapped in the
    single-incsub_event.php
    shows nothing front end..

    I understand how much is going on - but please note its a live site with hundreds of web links and phone numbers and we are in limbo with the year changeover to rollover events and folks are getting mighty testy..
    :slight_smile:

  • Jack Kitterhing

    Hi there @be,

    Hope you're well today, sorry we don't have a fix yet, though Ve is aware of the issues.

    Currently, if the listings were added, links wouldn't be clickable and custom fields can't be edited on the front-end (just replied to your other thread).

    In the mean time, if you did add those listings, you'd have the recurring issue with the custom field, but on a plugin update once this is fixed (asap), then this would work correctly without any manual changes needed.

    Thanks!

    Kind Regards
    Jack.

  • be

    Ok - so here is the issue in a nutshell as it were.. (had asked prior to moving first site to events+ and was given the impression that everything we needed it to do was already functioning)

    1 - Geolocating calendars - https://premium.wpmudev.org/forums/topic/shortcode-addition-as-there-is-no-geo-location-support..
    which we need a workaround for but without knowing what will display frontend we are stuck.

    2 - If we have to use Event categories for shortcodes - how do we remove the cats from display - https://premium.wpmudev.org/forums/topic/remove-event-cat-tag-from-single-event-page happy to remove them anyway because they are going to a not found page when clicked..

    3 - If the custompress embed codes do not allow front end entry on events+ it will mean re evaluating the use and data placement of all of the events..
    we need another way round - so at a standstill

    4 - because there is no import facility this is a very manual, time consuming job and will be a very large problem if we have to go back and resave or replace data on every entry.. (our testing produced duplicate events all over the place... )

    5 - There are payment to event owner and other issues but the issues above are the biggest drag at the moment...

    and did I mention a very very unhappy site..
    :o(

  • Vladislav

    Hello,

    Just to add some insight into why the custompress fields might not work as you'd expect them to for recurring events. The recurring events instances (i.e. the events that are displayed on the front-end to your users) are actually individual instances replicated on certain dates from the hub event. This hub event is also where the CustomPress field is defined. So, to make any custompress field work as you'd expect it to, we need to place it in the proper context, for an example like this:

    <?php if ($event->is_recurring_child()) { $post = get_post($event->get_parent()); } ?>
        <a href="<?php echo esc_url(do_shortcode('[ct id="ct_Website_text_f450"]')); ?>" target="_blank">Visit this site</a></h1>
    <?php if ($event->is_recurring_child()) { $post = get_post($event->get_id()); } ?>

    As you see, we're first checking if we're dealing with a recurring instance event and, if we do, we're temporarily switching contexts to a post that has this CustomPress field set. Once we're done with showing our field, we don't need the parent context anymore, so we're switching it back to the original instance instead. You can use this approach in your single event template, in order to get the CustomPress fields you're after displayed properly.

  • Jack Kitterhing

    Hi there @be,

    Thanks for the additional information.

    1: I believe that the best current workaround would be to use the Google maps integration, though the issue with this there isn't actually a way to split those into separate calendars, based on the location, there is no geo location search/filter currently. Perhaps tagging and then doing a custom WP_Query via tag? :slight_smile:

    2: Varies theme to theme, but it should be .footer-entry-meta { display: none; } you can use firebug to get the exact element class :slight_smile:

    4: You could import in a .csv format for standard events as events is a custom post type of incsub_event, but importing a event that should be recurring wouldn't work.

    5: I'm afraid that isn't possible currently, events can only handle payments to the one PayPal account and not multiple using chained payments or similar. Though it would make a great addition :slight_smile:

    Thanks!

    Kind Regards
    Jack.

  • be

    Hi and thanks again\@Vladislav

    So, to make any custompress field work as you'd expect it to, we need to place it in the proper context, for an example like this:

    Unfortunately entering any code including the one above in the template
    single-incsub_event.php

    Returns nothing front end as also tested by Jack above

    Hope you're well today, I've been testing this can confirm that it doesn't work I'm afraid.

    So to clarify -
    if we use BLOCK shortcode in the post directly it will display on single events ..

    This is not a practical solution as there are many event owners..

    Anything else - templates or recurring event shortcodes and nothing displays front end..

    We need the custompress embed code to function in the template...

    At this point we are headed for major issues with this site and any and all help as a matter of urgent timing is greatly appreciated..

  • be

    @Jack Kitterhing
    1 - no doesn't work - and we need calendar per area - have found a workaround very manual but need to be operating..

    2 - Done

    3 - Still cannot get them to display in template either shortcode or embed ..

    4 - this site has 2985 events waiting to go on unfortunately 2938 are Recurring so not an option... (see why I am getting greyer by the minute and there are lots of at this point downright angry folks involved)

    5- Can this go as a feature request or do I need to reask..?

  • Vladislav

    Hello,

    I have made an assumption that you're already using the plugin's default template, but let's make sure we have this covered just in case, as the code works just fine for me. So, to get this to work, you need to have "Override default appearance?" checkbox checked in the plugin settings. Also, you need to either have a file named "single-incsub_event.php" in your theme's root directory with those changes applied, or you need to have the proper single template selected in the "Single Event template" selection box. For an example, if you have been editing the default-templates/default/single-incsub_event.php, you'll want to make sure you have the "Plugin: Default" option selected. Can you please double-check if that's the case?

  • be

    brahhhahhhha..

    That was it - in appearance did not have the Single Event template set to default - it was on calendar.. have to test recurring but can see it on single event
    OK - only works with Event Template set to plugin default...
    Have a CSS issue and no breadcrumbs.
    How to remove comments from that page then CSS should be ok - its sitting over the entry box and we don't need comments.

    This is an impression of a hug... 0

    :slight_smile: THANKYOU again.....

  • be

    Workaround for 1 - 2 - 3 as above

    6 - Further to wrapping custompress fields - could you who have far more knowledge re coding and this plugins behaviour please advise..best approach or alternative please......

    To be used in the template....

    Field purpose - to create a _dropdown viewable list of data.. (this is a precreated field and need the option to enter the field and use maybe java or your suggested method to get the table to view..

    Currently using..

    <a href=""ReverseDisplay('Dlist18')"">Show/Hide list pool that is done here</a>
    <script type="text/javascript" language="JavaScript">// <![CDATA[
    function HideContent(d) { document.getElementById(d).style.display = "none"; } function ShowContent(d) { document.getElementById(d).style.display = "block"; } function ReverseDisplay(d) { if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; } else { document.getElementById(d).style.display = "none"; } }
    // ]]></script>
    <div id="Dlist18" style="display: none;">[table id=18 /]</div>

    so a major portion of the events will have their own list to be added to view in their events..
    Intention -
    [table id=18 /] - is a table shortcode -
    If we enter this shortcode in the custompress field for each event,
    Wrap if practical - the custompress field
    To display frontend as

  • Vladislav

    Hello,

    Since we can count on having jQuery library present on such pages, we can make the toggling code much simpler. Basically we can do this in two parts, one for the toggling link and the actual table (this would go within the loop). The other part would be the javascript, which would go outside the loop so you don't have repeated javascript blocks. Here's an example of what I had in mind.

    This would be the first part, the toggling link and the shortcode-powered table in the wrapper:

    <a href="#Dlist18" class="toggleable-table-switch" >Show/Hide list pool that is done here</a>
    <div id="Dlist18" style="display:none">[table id=18 /]</div>

    The important bits here is that a) the toggling link has a class we'll be using later on, and b) the toggling link "href" attribute points to the table wrapped ID. We will be making use of this fact to simplify our javascript code next.

    This is the javascript code that will make the toggling the shortcode output visibility happen. This can be anywhere on the page, preferably outside loops - we don't need this code repeated, because we'll be targeting the wrappers for toggling via the link "href" attribute:

    <script>
    (function ($) {
    $(function () {
    	$("a.toggleable-table-switch").off("click").on("click", function (e) {
    		e.preventDefault();
    		$($(this).attr("href")).toggle();
    	});
    });
    })(jQuery);
    </script>

    This way, you can have as many toggling links/wrapped table pairs as you need, and control them with one central, simple bit of code. I hope this helps.

  • be

    Thanks so much again @Vladislav
    What we were hoping to achieve was a way to utilise the Custompress field for the wrapper..

    ie- there are many tables and many table IDs - each matching.
    So \

    event 1 - has table 1 table id 1
    event 2 - has table 2 table id 2 etc..

    Seeking a way to utilise the custom field so we can enter the relevant table and id for each event just like any other event specific info and have it display front end in the template..
    Or
    a place to add the specific href in each event...

    We have Hundreds of individual recurring events..

  • Vladislav

    Oh, right, I think I got it now. Okay, so combining the code above with the CustomPress field value obtaining code we had previously, the first part could look a bit like this:

    <?php if ($event->is_recurring_child()) { $post = get_post($event->get_parent()); } ?>
    	<?php $table_id = do_shortcode('[ct id="ct_Website_text_f450"]'); ?>
        <a href="#Dlist<?php echo $table_id; ?>" class="toggleable-table-switch" >Show/Hide list pool that is done here</a>
        <div id="Dlist<?php echo $table_id; ?>" style="display:none">
        	<?php echo do_shortcode('[table id=' . $table_id . ' /]'); ?>
        </div>
    <?php if ($event->is_recurring_child()) { $post = get_post($event->get_id()); } ?>

    This will a) obtain a value from the CustomPress field, b1) use that value to set A HREF in the markup, b2) also use that value for the DIV ID and, lastly, c) use that same value to render the table shortcode within the wrapper. Please, note that this code will use the CustomPress field value for each event - the recurring instances will also have this value set, and this value will be whatever is entered in the parent event CustomPress field.

    The second part (javascript) from my previous post would still remain the same:

    <script>
    (function ($) {
    $(function () {
    	$("a.toggleable-table-switch").off("click").on("click", function (e) {
    		e.preventDefault();
    		$($(this).attr("href")).toggle();
    	});
    });
    })(jQuery);
    </script>

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.