Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the community forum?
All Topics
Kenneth

Toolset Document Template

I love the feature of having the Page Template available as a column in Admin Columns. Kudos for this brilliant feature. Wouldn’t it be great to have this feature on posts and custom posts too? Unless I’m missing something, WordPress out of the box doesn’t include the versatility of changing the template of a post and certainly not a custom post. One of the great features of Toolset is Document Templates which basically apply the template concept (the ability to change it) to posts and custom posts. Handy! And your Add-on for Toolset is a God-send! If you could add the Document Template field in Toolset as an additional column in Admin Columns (as you did with the Page Template) it would be the icing on the cake! Let’s see that one V 4.5.5 🙂 Thanks

2 weeks ago
Stefan
Developer

Thanks for your feedback and suggestion. It seems that document templates are part of Toolset Views and I’m not familiar with that plugin at this moment. Our toolset integration only integrates with the features in Toolset Types and not (yet) Toolset Views.

It seems like a valid column, so I’ll create a feature request for it. First, we’ll have to look at the Views plugin in overall and see if we want to include that plugin to the integration or not. After that, we can have a look at deciding which column would be good candidates for new custom columns.

Btw, it is possible to add page templates to other post types as well.
Have a look at the ‘Template Post Type’ line that you can put in your header comment to make it work for specific post types. And this should work with our plugin as well.

Page Templates

2 weeks ago
Stefan
Developer

I have a workaround for you that already might work for you.
You could add a custom field column and look for the custom field ‘_views_template’.
This custom fields contains the ID of the related view (template) for that post.
You can enable inline edit and leave the rest of the settings as is.
I wrote two hooks for you that you can put in your theme or custom code plugin.

1) The first hook allows you to inline edit the column and select the view for your post. You might want to tweak it some more because it now allows you to set any view instead of only the view for that post type you’re on. I did not dive into the API yet, but I suspect they have a nice API call for that.

2) The second hook will alter the value (which is an ID by default) and transform it into the template name (post type). I hope this will help you get this feature already in place for your environment.

/**
 * @param array     $settings
 * @param AC\Column $column
 */
function acp_editing_set_views_templates( $settings, $column ) {
	if ( $column instanceof AC\Column\CustomField && $column->get_meta_key() === '_views_template' ) {
		$all_templates = get_posts(array(
			'post_type' => 'view-template',
			'posts_per_page' => -1,
			'fields' => 'ids'
		));

		foreach( $all_templates as $template_id ){
			$settings['options'][ $template_id ] = get_the_title( $template_id );
		}
		$settings['type'] = 'select';

	}

	return $settings;
}

add_action( 'acp/editing/view_settings', 'acp_editing_set_views_templates', 10, 2 );

/**
 * @param string $value
 * @param int $id
 * @param AC\Column $column
 *
 * @return string
 */
function ac_display_template_title( $value, $id, $column ) {
	if ( $column instanceof AC\Column\CustomField && $column->get_meta_key() === '_views_template' ) {
		$value = get_the_title( $value );
	}

	return $value;
}
add_action( 'ac/column/value', 'ac_display_template_title', 10, 3 );
2 weeks ago

You must be logged in to reply to this topic.