This thread is over two years old and may be outdated. Please create a new thread if you need help, or email us if you have an active Premium license.

Intregating widget to siteorigin page builder please help me

10 years ago · Last reply by Greg Priday 10 years ago

Sorry I was forced to ask for help here, because I could not think to combine widgets my theme to the page builder siteorigin.
Widget structure

<?php
class Supermag_PageBuilder_StyleNews extends Supermag_PageBuilder_WidgetBase
{
	public $no_container = 1;
	public $title_field  = 'cat';
	public function __construct()
	{
		parent::__construct(
			'supermag_pagebuilder_news_focus',
			__('News Focus Block', 'supermag-opt'),
			array('description' => __('A block that lists news from a parent categories, making the latest one prominent, and have tabs for sub-categories.', 'supermag-opt'))
		);
	}
	public function widget($args, $instance)
	{
		extract($args);
		// supported attrs
		$attrs = array('posts', 'cat', 'tax_tag', 'sub_cats', 'sub_tags', 'sort_order', 'sort_by', 'highlights', 'offset', 'post_type', 'heading_type');
		// do_shortcode will be run by pagebuilder		
		echo '[news_focus '. implode(' ', $this->shortcode_attribs($instance, $attrs)) .' /]';
	}
	public function form($instance)
	{
		$defaults = array('posts' => 4, 'cat' => '', 'offset' => 0, 'post_type' => '');
		$instance = array_merge($defaults, (array) $instance);
		extract($instance);
		$render = Supermag::factory('admin/option-renderer'); /* @var $render Supermag_Admin_OptionRenderer */
		
	?>
	<input type="hidden" name="<?php echo $this->get_field_name('no_container'); ?>" value="1" />
	
		<label><?php _e('Number of Posts:', 'supermag-opt'); ?></label>
		<input name="<?php echo esc_attr($this->get_field_name('posts')); ?>" type="text" value="<?php echo esc_attr($posts); ?>" />
	<p class="description"><?php _e('Configures posts to show for each listing. Leave empty to use theme default number of posts.', 'supermag-opt'); ?>
		<label><?php _e('Sort By:', 'supermag-opt'); ?></label>
		<select name="<?php echo esc_attr($this->get_field_name('sort_by')); ?>">
			<option value=""><?php _e('Published Date', 'supermag-opt'); ?></option>
			<option value="modified"><?php _e('Modified Date', 'supermag-opt'); ?></option>
			<option value="random"><?php _e('Random', 'supermag-opt'); ?></option>
		</select>
		<select name="<?php echo esc_attr($this->get_field_name('sort_order')); ?>">
			<option value="desc"><?php _e('Latest First - Descending', 'supermag-opt'); ?></option>
			<option value="asc"><?php _e('Oldest First - Ascending', 'supermag-opt'); ?></option>
		</select>
		<label><?php _e('Highlighted Post(s):', 'supermag-opt'); ?></label>
		<input name="<?php echo esc_attr($this->get_field_name('highlights')); ?>" type="text" value="1" />
	<p class="description"><?php _e('Highlighted posts are displayed larger at left. If you have more than 10 posts, we recommend using 2 highlighted posts.', 'supermag-opt'); ?>
		<label><?php _e('Parent Category:', 'supermag-opt'); ?></label>
		<?php wp_dropdown_categories(array(
			'show_option_all' => __('-- None - Use a Tag --', 'supermag-opt'), 'hierarchical' => 1, 'hide_empty' => 0, 'order_by' => 'name', 'class' => 'widefat', 'name' => $this->get_field_name('cat'))); ?>
		<label><?php _e('or Parent Tag: (optional) ', 'supermag-opt'); ?></label>
		<input type="text" name="<?php echo $this->get_field_name('tax_tag'); ?>" value="" />
	<p class="description"><?php _e('You can enter a tag if you wish to show posts from a tag instead. Leave empty if you selected a category.', 'supermag-opt'); ?>
	<div class="taxonomydiv"> <!-- borrow wp taxonomydiv > categorychecklist css rules -->
		<label><?php _e('Sub Categories:', 'supermag-opt'); ?></label>
		<div class="tabs-panel">
			<ul class="categorychecklist">
				<?php
				ob_start();
				wp_category_checklist();
				echo str_replace('post_category[]', $this->get_field_name('sub_cats') .'[]', ob_get_clean());
				?>
			</ul>			
		</div>
	</div>
	<p class="description"><?php _e('News Focus blocks displays sub-categories as tabs. Select any sub-category you wish to display.', 'supermag-opt'); ?>
		<label><?php _e('or Sub Tag: (optional) ', 'supermag-opt'); ?></label>
		<input type="text" name="<?php echo $this->get_field_name('sub_tags'); ?>" class="widefat" />
	<p class="description"><?php _e('Separate tags with comma. e.g. cooking,sports', 'supermag-opt'); ?>
	<div>
		<label><?php _e('Heading Style:', 'supermag-opt'); ?></label>
		<select class="widefat" name="<?php echo esc_attr($this->get_field_name('heading_type')); ?>">
			<option value="block-filter"><?php _e('Block Heading With Filters', 'supermag-opt'); ?></option>
			<option value="block"><?php _e('Block Section Heading Style', 'supermag-opt'); ?></option>
			<option value="none"><?php _e('No Heading', 'supermag-opt'); ?></option>
		</select>
	</div>
	
		<label><?php _e('Offset: (Advanced)', 'supermag-opt'); ?></label> 
		<input type="text" name="<?php echo $this->get_field_name('offset'); ?>" value="0" />
	<p class="description"><?php _e('By specifying an offset as 10 (for example), you can ignore 10 posts in the results.', 'supermag-opt'); ?>
		<label><?php _e('Post Types: (Advanced)', 'supermag-opt'); ?></label>
		<input name="<?php echo esc_attr($this->get_field_name('post_type')); ?>" type="text" value="<?php echo esc_attr($post_type); ?>" />
	<p class="description"><?php _e('Only for advanced users! You can use a custom post type here - multiples supported when separated by comma. Leave empty to use the default format.', 'supermag-opt'); ?>
	<?php
	}
}

This is our free support forum. Replies can take several days.

Need fast email support? Get SiteOrigin Premium

Replies

10
  1. Jawanet Dev 10 years, 2 months ago

    Ok greg, sorry for my thread

  2. Greg Priday Staff 10 years, 2 months ago

    Hi Jawanet

    Do you still need help here? I’m not quite following what your question is, but if you can clarify, I’ll be sure to try help out.

  3. Jawanet Dev 10 years, 2 months ago

    I find it difficult to integrate my 3 widget theme with page builder.
    How do I submit my widget code here.

  4. Support Assistants 10 years, 2 months ago

    Hi Jawanet

    Thanks for your feedback. Are you saying that the widgets you’ve added to your theme aren’t appearing in Page Builder when clicking Add Widget?

  5. Jawanet Dev 10 years, 2 months ago

    Yes sir, the widget does not appear in the theme builder

  6. Support Assistants 10 years, 2 months ago

    Thanks for your feedback. Please, send us a copy of your theme and we’ll take a look. You could use the Add Media button provided above the comment field or a service like: https://www.wetransfer.com/.

    Thanks

  7. Jawanet Dev Private 10 years, 2 months ago

    This is a private message.

  8. Support Assistants 10 years, 1 month ago

    Thanks for the wait.

    From what I can see, your widget doesn’t appear at Appearance > Widgets. Is that correct? If so, you’d need to solve that challenge first. Once your widget appears at Appearance > Widgets it’ll be available to Page Builder.

  9. Jawanet Dev 10 years, 1 month ago

    I mean, the widget only appear in the page builder.

    My widgets on the page builder origin site can still be the old version, but for the new version to bring me trouble.

    4 widget please me to appear, I will make a donation

  10. Greg Priday Staff 10 years, 1 month ago

    Hi Jawanet

    If you want your widget to show up in the standard WordPress widgets interface, you’d need to make sure that you’re properly registering it using regsiter_widget.

    https://codex.wordpress.org/Function_Reference/register_widget

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.

Have a different question or issue?

Start New Thread