Theming Exchange - Hooking into Exchange Templates

From IThemes Codex
(Difference between revisions)
Jump to: navigation, search
 
(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) and look for the <code>do_action</code> reference to find the one you need.
 
Dig into the templates (ithemes-exchange/lib/templates) and look for the <code>do_action</code> reference to find the one you need.
 +
 +
==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 18:00, January 19, 2015

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.

See also


← Back to Exchange Codex Home

Personal tools
Namespaces
Variants
Actions
iThemes Codex
Codex Navigation
Toolbox