<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Bring Your Own Terms Of Service &#187; Component</title> <atom:link href="http://byotos.com/tag/component/feed/" rel="self" type="application/rss+xml" /><link>http://byotos.com</link> <description></description> <lastBuildDate>Sat, 24 Jul 2010 21:29:37 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0</generator> <item><title>Improving custom component installation</title><link>http://byotos.com/2009/07/improving-custom-component-installation/</link> <comments>http://byotos.com/2009/07/improving-custom-component-installation/#comments</comments> <pubDate>Sat, 25 Jul 2009 18:53:08 +0000</pubDate> <dc:creator>Paul Gibbs</dc:creator> <category><![CDATA[BuddyPress]]></category> <category><![CDATA[Code Sample]]></category> <category><![CDATA[Component]]></category> <category><![CDATA[WPMU]]></category><guid
isPermaLink="false">http://metabiscuits.com/?p=9</guid> <description><![CDATA[When implementing a custom component in BuddyPress, you will often have additions for the member theme. Member themes live in their own folder, /wp-content/bp-themes/. To render a member theme template, your component will call dpa_load_template() which takes an argument of &#8230; <a
href="http://byotos.com/2009/07/improving-custom-component-installation/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>When implementing a <a
href="http://codex.buddypress.org/how-to-guides/creating-a-custom-buddypress-component/">custom component</a> in <a
href="http://buddypress.org/">BuddyPress</a>, you will often have additions for the member theme. Member themes live in their own folder, <code>/wp-content/bp-themes/</code>.</p><p>To render a member theme template, your component will call <code>dpa_load_template()</code> which takes an argument of the name of the template to load. The path is hardcoded to the <code>/wp-content/bp-themes/</code> folder.</p><p>The problem with this is that after installation of a custom component, the site administrator will need to move the relevant member theme files (bundled with your component) into <code>/wp-content/bp-themes/</code>. This is an annoyance to site administrator, and it may end up being a frequent support request (&#8220;why is X not working?&#8221;).  This very first hurdle may even stop people trying out your component.</p><p>Something else I&#8217;ve seen is that when installing future updates, people may forget that they need to move the updated member theme files into place; this can cause incompatibility issues between versions of your software, something we&#8217;ve seen with recent versions of BuddyPress.</p><p>For my upcoming &#8220;Achievements&#8221; plugin (think a cross between forum points and <a
href="http://en.wikipedia.org/wiki/Xbox_Live">Xbox Live</a>), I decided all that I wanted the site administrator to do would be to download it from the Plugins admin panel &#8211; no moving files into the member theme.</p><p>So, I present to you my code: (06/01/10 &#8211; updated for BP 1.1.3+)</p><pre class="brush: php;">
bp_core_load_template( 'yourcomponent_theme_filename' );  // loads /plugins/your_plugin/filename.php

function yourcomponent_screen_filter_template( $located_template, $template_name ) {
	if ( !empty( $located_template ) )
		return $located_template;

	if ( $bp-&amp;gt;current_component != $bp-&amp;gt;your_component-&amp;gt;slug )
		return false;

	if ( false !== strpos( $template_name[0], 'yourcomponent_theme_' ) ) {
		$prefix = strlen( 'yourcomponent_theme_' );
		$template_name = substr( $template_name[0], $prefix, strlen( $template_name[0] ) - $prefix );
		$template_path = WP_PLUGIN_DIR . &amp;quot;/your_plugin/$template_name&amp;quot;;

		if ( file_exists( $template_path ) )
			return $template_path;
	}

	return false;
}
add_filter( 'bp_located_template', 'yourcomponent_screen_filter_template', 10, 2 );
</pre>]]></content:encoded> <wfw:commentRss>http://byotos.com/2009/07/improving-custom-component-installation/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using apc
Page Caching using apc (user agent is rejected)
Database Caching 1/5 queries in 0.001 seconds using apc
Object Caching 287/288 objects using apc
Content Delivery Network via Amazon Web Services: CloudFront: Amazon Web Services: S3: media1.byotos.com

Served from: byotos.com @ 2010-07-29 18:36:29 -->