Show values from custom table in views

Support MB Views Show values from custom table in viewsResolved

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #21512
    toni birdtoni bird
    Participant

    Hi, Is it possible to show values that are stored in a custom table that is within wp database? thanks

    #21518
    Long NguyenLong Nguyen
    Moderator

    Hi Toni,

    Yes, we can call a PHP function via the proxy mb in the view. Use this code to show values that are stored in the custom table.

    {{mb.rwmb_meta( $field_id, {'storage_type': 'custom_table', 'table': $table_name} )}}

    For more information, please follow this documentation https://docs.metabox.io/extensions/mb-views/#running-php-functions.

    #21543
    toni birdtoni bird
    Participant

    Hi Long, thanks for your reply, I'm getting this error...?

    Fatal error: Uncaught Twig_Error_Syntax: Unexpected character "$" in "obra-single" at line 50. in C:\xampp\www\wp-content\plugins\meta-box-aio\vendor\twig\twig\lib\Twig\Lexer.php:295 Stack trace: #0 C:\xampp\www\wp-content\plugins\meta-box-aio\vendor\twig\twig\lib\Twig\Lexer.php(227): Twig_Lexer->lexExpression() #1 C:\xampp\www\wp-content\plugins\meta-box-aio\vendor\twig\twig\lib\Twig\Lexer.php(126): Twig_Lexer->lexVar() #2 C:\xampp\www\wp-content\plugins\meta-box-aio\vendor\twig\twig\lib\Twig\Environment.php(653): Twig_Lexer->tokenize(Object(Twig_Source)) #3 C:\xampp\www\wp-content\plugins\meta-box-aio\vendor\twig\twig\lib\Twig\Environment.php(750): Twig_Environment->tokenize(Object(Twig_Source)) #4 C:\xampp\www\wp-content\plugins\meta-box-aio\vendor\twig\twig\lib\Twig\Environment.php(447): Twig_Environment->compileSource(Object(Twig_Source)) #5 C:\xampp\www\wp-content\plugins\meta-box-aio\vendor\twig\twig\lib\Twig\Environment.php(362): Twig_Environment->loadTemplate('obra-single') #6 C:\xampp\www\wp-content\plugins\meta in C:\xampp\www\wp-content\plugins\meta-box-aio\vendor\twig\twig\lib\Twig\Lexer.php on line 295

    thanks again

    #21545
    Long NguyenLong Nguyen
    Moderator

    Hi Toni,

    You need to change variables $field_id and $table_name by your value.

    
    {{mb.rwmb_meta( 'field_id', {'storage_type': 'custom_table', 'table': 'table_name'} )}}
    
    #21547
    toni birdtoni bird
    Participant

    Hi Long, thanks for your reply,I've done that already, but then nothing is shown. maybe I am missing something?

    #21554
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Please share the code that created the custom table and fields and the code in View. I will take a closer look and give a quick response.

    #21635
    toni birdtoni bird
    Participant

    Hi Long Thanks for your reply, I will share that, we are revisiting the whole website for more clients changes and will get to this issue later next week... will keep that as standby for now.. thanks

    #21664
    toni birdtoni bird
    Participant

    Hi , got it sorted with a different approach. many thanks

    cheers

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.