Theming Exchange - Filtering Exchange Template Part Elements

From IThemes Codex
(Difference between revisions)
Jump to: navigation, search
m
 
Line 38: Line 38:
  
 
'''Please note that these filters are for advanced users and should be used with caution.'''
 
'''Please note that these filters are for advanced users and should be used with caution.'''
 +
 +
==See also==
 +
 +
*[[Theming_Exchange_-_Getting_Started|Theming Exchange]]
 +
**[[:Theming_Exchange_-_Getting_Started|Getting Started]]
 +
**[[Theming_Exchange_-_Customize_Generated_Pages_Output|Customize Exchange Generated Pages Output]]
 +
**[[Theming_Exchange_-_Adding_Custom_Templates|Adding Custom Templates]]
 +
**[[Theming_Exchange_-_Functions_List|Functions List]]
 +
**Filters
 +
***[[Theming_Exchange_-_Remove_Default_Exchange_Stylesheet|Removing Default Stylesheet]]
 +
***[[Theming_Exchange_-_Filtering_Exchange_Template_Part_Elements|Filtering Exchange Template Part Elements]]
 +
**Actions
 +
***[[Theming_Exchange_-_Complete_Action_Hook_List|Complete Action Hook List]]
 +
***[[Theming_Exchange_-_Hooking_into_Exchange_Templates|Hooking into Exchange Templates]]
 +
**Conditionals
 +
***[[Theming_Exchange_-_Checking_if_on_an_Exchange_Page|Checking if on an Exchange Page]]
 +
**Snippets
 +
***[[Theming_Exchange_-_Getting_a_Product_Image_of_Any_Registered_Size|Getting a Product Image of Any Registered Size]]
 +
*[[:Exchange_Themes_Overview|Overview]]
 +
*[[:Exchange_Theme_Templates|Exchange Theme Templates]]
 +
*[[:Exchange_Template_Updates|Template Updates]]
 +
 +
<br />
 +
[[:Exchange|← Back to Exchange Codex Home]]

Latest revision as of 16:59, January 19, 2015

In most of the template parts for exchange you will notice a function: it_exchange_get_template_part_elements().

This function gives both theme and addons developers the power to alter what element(s) each template part loops through by providing a filter based on the context and detail that the function calls for.

Function Call

	it_exchange_get_template_part_elements( $context, $detail, $parts )

Filter Tag

	'it_exchange_get_context_detail_elements'

For example, in lib/templates/content-cart/loops/actions.php the function calls for the context 'content_cart' and the detail 'actions'. Our filter tag for modifying this is as follows.

	'it_exchange_content_cart_actions_elements'

This filter will return the $parts (which can be modified).

Example

For the filter above (it_exchange_get_content_cart_actions_elements), let's say we want to remove the apply-coupon action. We can do this by filtering the elements of that array like so:

function custom_exchange_filter_content_cart_actions( $parts ) {
	foreach ( $parts as $key => $part ) {
		if ( 'apply-coupon' == $part ) {
			unset( $parts[$key] );
		}
	}
	
	return $parts;
}
add_action( 'it_exchange_get_content_cart_actions_elements', 'custom_exchange_filter_content_cart_actions' );

Please note that these filters are for advanced users and should be used with caution.

See also


← Back to Exchange Codex Home

Personal tools
Namespaces
Variants
Actions
iThemes Codex
Codex Navigation
Toolbox