Support Forum » User Profile

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • in reply to: Empty head tag when applying View to whole page #24071
    Beda SchmidBeda Schmid
    Participant

    Hummmm...

    Ok, here is what I found:

    1. If we just create a view and assign to The whole page layout, including header and footer, but do NOT insert a head tag, or do NOT call get_header, then the HTML source will be

      <html><head></head><body>This would be the View content. Whatever we put here, code, HTML, Twig, etc etc.</body></html>
    2. If we insert manually a head tag, it will replace the empty head tag, and produce what we insert in the View

    3. If we call get_header, it also replaces the head tag, and puts in what comes from the theme

    So far, so good, I misunderstood how it works, I think.
    I thought the view would simply replace all content and not expect any head or else like a "completely blank output"

    I can proceed, it is clear now.

    Thanks a lot, Long!

    in reply to: Map Field not working #24069
    Beda SchmidBeda Schmid
    Participant

    I confirm that with a valid Google Maps API, the backend also works.

    Interesting is, that the lat and long are saved as well without valid API Key but then the backend won't reflect the saved settings.

    Issue's resolved for the Google Map field, but it persists in the OSM Map, but is resolved when we map a address field to it.

    I guess with that we can close this ticket.

    Thanks!

    in reply to: Map Field not working #24066
    Beda SchmidBeda Schmid
    Participant

    Hi, thanks!
    I have shared the access details in the link/

    I also added explanation to the message how to find the issue.
    I found that this is an issue that was mentioned once here already https://support.metabox.io/topic/map-field-not-working/

    Thanks!

    in reply to: Empty head tag when applying View to whole page #24064
    Beda SchmidBeda Schmid
    Participant

    Hello
    Yes, I know that.

    But when you choose The whole page layout, including header and footer, then the result is a empty head tag, such as I explain in my firs post.

    The result will be (in HTML source):
    <html>
    <head></head>
    <body>
    HERE WILL DISPLAY THE VIEW ASSIGNED TO The whole page layout, including header and footer
    </body>
    </html>

    As you can see head is empty
    This is not good, as head should not be empty, or at least not insert by the plugin, so we could populate it on our own.
    Note, this head tag is not coming from theme, it comes form View assigned to the page.

    Thanks!

    in reply to: Image Select Field only offers first option #24060
    Beda SchmidBeda Schmid
    Participant

    OK, I think I misunderstood the hint in the field

    It works, if we indeed alter the value keys in the GUI.

    Sorry the trouble, no issue at all here, can be closed...

    in reply to: Image Select Field only offers first option #24059
    Beda SchmidBeda Schmid
    Participant

    The trick is to increase the array key.

    Hence, the correct code is

    'options' => [
    'value' => esc_html__( 'https://the-million-posts--site.tukutoi.com/wp-content/uploads/2020/12/a79b4e0b-a842-300a-a503-8288e4e8603c.jpg', 'text-domain' ),
    'value1' => esc_html__( 'https://the-million-posts--site.tukutoi.com/wp-content/uploads/2020/12/537f927b-2c14-3162-8a44-c0ac6c39fc8f.jpg', 'text-domain' ),
    ],
    ],

    AIO does not do this, it seems.
    Perhaps it is a bug?

    Beda SchmidBeda Schmid
    Participant

    Excellent thanks!

    For anyone findings this - with WP Grid Builder (and probably all other plugins creating index) you can query these fields easily.

    You just need to use the respective APIs to build the index, using the rwmb_get_value or rwmb_meta like in this example (for WP Grid Builder):
    $row['facet_value'] = rwmb_meta( 'meta_field_slug', '', $object_id );

    This also works for the map field, as long we match the Facet plugin expectations when building the index.

    This works for all kind of fields, since actually those indexes do not expect real existing data, we could even pass fake data to it.

    Thanks!

    in reply to: Map Field not working #24054
    Beda SchmidBeda Schmid
    Participant

    I found the "issue"
    It actually saves the data, but in the backend, in the map, it defaults still to Dublin after saving.

    Is this expected?

    I use only Metabox here.

    Beda SchmidBeda Schmid
    Participant

    That sounds great, thanks!

    As for importing data, are there suggested ways to import content (like post and postmeta) but to Custom Tables?
    Or would I have to custom code some importer in this case?

    Also I read in that other post, the Maps/Google field cannot be searched by FacetWP?
    I will test this, but just asking in case things changed meanwhile.

    Thanks!

    Beda SchmidBeda Schmid
    Participant

    Sorry the delay

    Indeed this is resolved, thanks!

    Beda SchmidBeda Schmid
    Participant

    Nice!

    Didn’t see that, thanks Long!

    Beda SchmidBeda Schmid
    Participant

    I was using the Builder (Backend UI).

    Indeed I can see now why this is, after reading the code you sent, I see a difference.
    The builder produces a code where the field query args array is a string:

    
    'query_args'  => [
        'post__not_in' => 'array( 773 )',
    ],
    

    Instead, it should be

    
    'query_args'  => [
        'post__not_in' => array( 773 ),
    ],
    

    So when using the AIO Builder, it will not register arrays correctly, it always seems to assume string as input, and produce string in the arg, which might even produce issues when the arg expects a numeric value.

    Perhaps this can be fixed in the builder, it would save time to edit code/save/reedit code etc

    Beda SchmidBeda Schmid
    Participant

    In case anyone stumbles on the same issues, this is how I solved it:

    1. First form includes only a few fields visibly
    2. It has a Custom Redirect Hook applied that does two things: Redirect to a new URL and passes certain input values to the URL, as well it deletes the post just created, as we don't want it to be saved just yet
    3. On the redirect target the final full form will allow to complete the process, and is populated by the available url parameters.

    The code:
    For the redirect and delete post actions:

    
    add_filter( 'rwmb_frontend_redirect', 'my_redirect_custom_hook', 10,2);
    function my_redirect_custom_hook($url, $config){
        if( $config['id'] == 'my-metabox-slug' && startsWith( $_POST['_wp_http_referer'] , '/referrer-base/' ) ){
    
            $url = 'site.com/target/?url_param_one=' . $_POST['metabox-field-one'] . '&url_param_two=' . $_POST['metabox-field-two'];
    
            wp_delete_post( $config['post_id'], true );
    
        }
    
        return $url;
    }
    //Helper Function since only PHP8 and above will support natively str_starts_with()
    function startsWith( $haystack, $needle ) {
         $length = strlen( $needle );
         return substr( $haystack, 0, $length ) === $needle;
    }
    

    Then on the target page (final form), read the URL arguments with JS and put them in the determined fields:

    
    jQuery( document ).ready(function($){
        function querySt(ji) {
    
            hu = window.location.search.substring(1);
            gy = hu.split("&");
    
            for (i=0;i<gy.length;i++) {
                ft = gy[i].split("=");
                if (ft[0] == ji) {
                    return ft[1];
                }
            }
        }
        var url_param_one = querySt("url_param_one");
        var url_param_two = querySt("url_param_two");
        document.getElementById('metabox_field_form_id_one').value = url_param_one;
        document.getElementById('metabox_field_form_id_two').value = url_param_two;
    });
    

    It will need some more care in sanitising the url params, and of course, change the slugs and ids to the specific use cases.

    Beda SchmidBeda Schmid
    Participant

    Ah, forgot:
    Is it possible to pass the values from first form to second form?

    Or, in other words, how’d go for populating form fields dynamically according a previously submitted form?

    I read only the post ID can be set by url param.
    However it must be possible somehow to populate other fields dynamically also?

    Thanks!

    Beda SchmidBeda Schmid
    Participant

    Thanks Long for confirming!

    I’ll use the hooks.

    Regards, Beda

Viewing 15 posts - 1 through 15 (of 15 total)