Home>Support>template not showing in custom widget

template not showing in custom widget

Notice: This thread is over two years old; the information may be outdated. Please consider creating a new thread if you require free support. If you have an active SiteOrigin Premium license, you can email our premium support desk at [email protected].

I made a custom widget and everything is showing fine in the back end. The widget is populated and the info saves. My problem is that nothing is showing on the front end. Not even simple html. I have shortened my code for easier reading. Just took out some of the settings. In the tpl folder, I have a file named address.php that should display the front end but I get nothing. Are there any common errors that would prevent it from showing on the front end? Not even the html shows. The widget displays on the back end and works just fine.

File structure

address-widget
folder assets
folder styles
folder tpl
address.php
address-widget.php


/*
Widget Name: Mosty Address Widget
Description: Displays a formatted address widget!'.


*/

class Address_Widget extends SiteOrigin_Widget {
	function __construct() {

		parent::__construct(
			'address',
			__( 'Mosty Address Widget', 'mosty' ),
			array(
				'description' => __( 'A formatted address widget', 'mosty' ),
			),
			array(
			),
			false,
			plugin_dir_path(__FILE__)
		);
	}
	
	function get_widget_form() {
		return array(
	
			'title' => array(
				'type' => 'text',
				'label' => __('Title.', 'mosty'),
				'default' => 'Contact Us'
			),
		);
	}

	function get_template_name($instance) {
		return 'address';
	}

	function get_style_name($instance) {
		return 'address-style';
	}
}
siteorigin_widget_register('mosty_address_widget', __FILE__, 'Address_Widget');

This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 7 years, 6 months ago Alex S
    Hi, I Work Here

    Hi ThemeBuddies,

    Can you please send me a complete archive of the referenced widget? This will allow me to get a better idea of why this may not be working. Sorry mate.

  2. 7 years, 6 months ago ThemeBuddies

    Alex, I figured it out. I believe part of the issue is that there is not enough information in the tutorial for creating a widget to make it work without problems. I think it came down to having incorrect information in the constructor. I have it working but I had to poor over other plugins for the siteorigin page builder to figure it out.

  3. 7 years, 6 months ago Alex S
    Hi, I Work Here

    Hi ThemeBuddies,

    Can you please provide specifics on what you feel is missing in the documentation? I’m not saying our documentation is perfect, I just need more information on what you feel is lacking specifically so I can forward that to Andrew so this can be corrected. Oddly, I just tried and was able to follow the documentation without issue so I’m not too sure what steps are missing.

  4. 7 years, 6 months ago ThemeBuddies

    I am sure it’s ok. There is just more information that could be in there. Like why the constructor is holding the form fields when they could go in a function called get_widget_form

Replies on this thread are closed. Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More