Tagged: avia template builder, custom template, enfold
-
AuthorPosts
-
March 8, 2017 at 2:42 pm #757794
Hi!
I’m trying to create custom avia-shortcodes to be used in the template builder. I’ve successfully added a separate shortcodes folder in my child-theme, got the shortcode to show up in the editor and im able to display an edit menu with custom text and icons in the avia layout builder. The problem im having is i cant seem to make the custom attributes i set in the editor to affect the executed shortcode.
I want to show a couple of events from our facebook page on the website, and i want to be able to position the events with the layout builder. I am able to select the number of posts to show through the layout builder, but i cant seem to get input options to work.
This is how the editor looks in my avia layout builder:
But a var_dump of the $atts in the shortcode_handle function gives the following result:
array(2) { [“blog_type”]=> string(5) “posts” [“items”]=> string(1) “2” }function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "") { global $avia_config; $fb = initiateFacebook(); $id = '475361259178157'; // Id of fb page to poll from $events = $fb->getEvents($id, 10); ob_start(); var_dump($atts); echo 'Hämtade ' . count($events) . ' evenemang'; $temp = ob_get_clean(); $output = "Detta är ett custom element från avia-builder!" . $atts['items'] . "<br>" . $temp; return $output; }
Heres the code which displays the editor page:
function popup_elements() { $this->elements = array( array( "name" => __("What page should be polled?", 'avia_framework' ), "desc" => __("Whats the page id of the page to pull events from?", 'avia_framework' ), "id" => "source-id", "type" => "input", "std" => __("475361259178157", 'avia_framework')), array( "name" => __("Number of events", 'avia_framework' ), "desc" => __("How many events should be displayed per page?", 'avia_framework' ), "id" => "items", "type" => "select", "std" => "3", "subtype" => AviaHtmlHelper::number_array(1,10,1, array('All'=>'-1')))); }
How can i make the attributes from the editor be available to my shortcode handler?
- This topic was modified 7 years, 9 months ago by Maskinsektionen.
March 8, 2017 at 3:43 pm #757856Nevermind, code works fine you just have to update the page with the shortcode so the settings in the database are updated…
March 10, 2017 at 5:13 am #758678Hi,
Thanks for the feedback, so I’m guessing it’s working as it should?
Best regards,
RikardMarch 11, 2017 at 11:30 am #759349Yeah it works just fine! Thanks!
March 12, 2017 at 6:23 am #759551 -
AuthorPosts
- The topic ‘Custom template builder avia-shortcode attributes not customizable?’ is closed to new replies.