Theming Exchange - Hooking into Exchange Templates

From IThemes Codex
(Difference between revisions)
Jump to: navigation, search
(Created page with "Each Exchange template contains a set of action hooks for theme and add-on developers to use. The best way to find the names of these hooks is looking within a template file, ...")
 
 
(One intermediate revision by one user not shown)
Line 27: Line 27:
 
</pre>
 
</pre>
  
There are hundreds (litterally) of action hooks to use.
+
There are (literally) hundreds of action hooks to use.
  
Dig into the templates (ithemes-exchange/lib/templates) to find the one for you.
+
Dig into the templates (ithemes-exchange/lib/templates) and look for the <code>do_action</code> reference to find the one you need.

Latest revision as of 17:14, January 30, 2014

Each Exchange template contains a set of action hooks for theme and add-on developers to use. The best way to find the names of these hooks is looking within a template file, but this page will try to explain the basic concept of these action hooks and how to use them.

When creating an add-on for Exchange, one thing a developer needs is a way to add the add-ons items to the different pages of Exchange. The best way to do this is with action hooks.

do_action( 'action_tag_name' );

Example

Let's say you wanted to add a notification (perhaps about an upcoming sale) to the cart, just above the cart items, but did not want to copy over the entire cart items template (templates/content-cart/elements/items.php). This could be accomplished using the follow hook:

do_action( 'it_exchange_content_cart_before_items' );

Here is what you would add.

function custom_sale_notification_before_cart_items() {
	?>
		<div class="notification">
			<p>There is an upcoming sale!</p>
		</div>
	<?php
}
add_action( 'it_exchange_content_cart_before_items', 'custom_sale_notification_before_cart_items' );

There are (literally) hundreds of action hooks to use.

Dig into the templates (ithemes-exchange/lib/templates) and look for the do_action reference to find the one you need.

Personal tools
Namespaces
Variants
Actions
iThemes Codex
Codex Navigation
Toolbox