Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #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:
    Custom editor

    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?

    #757856

    Nevermind, code works fine you just have to update the page with the shortcode so the settings in the database are updated…

    #758678

    Hi,

    Thanks for the feedback, so I’m guessing it’s working as it should?

    Best regards,
    Rikard

    #759349

    Yeah it works just fine! Thanks!

    #759551

    Hi,

    Great, thanks for the feedback. Please open a new thread if you should have any further questions or problems.

    Best regards,
    Rikard

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Custom template builder avia-shortcode attributes not customizable?’ is closed to new replies.