Custom Fields
Re-Envisioned › Support › MB Views › Show values from custom table in views
- This topic has 7 replies, 2 voices, and was last updated 5 months, 3 weeks ago by
toni bird.
-
CreatorTopic
-
August 28, 2020 at 11:48 PM #21512
Hi, Is it possible to show values that are stored in a custom table that is within wp database? thanks
-
CreatorTopic
-
AuthorReplies
-
August 29, 2020 at 9:28 AM #21518
Long Nguyen
ModeratorHi 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.
August 31, 2020 at 7:48 AM #21543toni bird
ParticipantHi 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
August 31, 2020 at 8:48 AM #21545Long Nguyen
ModeratorHi 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'} )}}
August 31, 2020 at 9:29 AM #21547toni bird
ParticipantHi Long, thanks for your reply,I’ve done that already, but then nothing is shown. maybe I am missing something?
August 31, 2020 at 3:37 PM #21554Long Nguyen
ModeratorHi,
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.
September 4, 2020 at 12:11 AM #21635toni bird
ParticipantHi 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
September 5, 2020 at 1:47 AM #21664toni bird
ParticipantHi , got it sorted with a different approach. many thanks
cheers
-
AuthorReplies
- You must be logged in to reply to this topic.