Theme Templates Integration: Content

In previous tutorial we have learn what theme templates are needed for plugin to work. Now, we need to see how each template looks like. We will see full templates content for all 6 templates plugin needs. If you have more than one product type, you need 2 more templates for each one.

Each template is displayed in full. But, top and bottom for each one depend on you theme, and only middle part (GD Products Center comment block) is related to plugin and needs to be copied in full.

Compare Template

This template is always named like this: gdpc-compare.php.

[php]<?php get_header(); ?>

<div id="container" class="one-column">
<div id="content" role="main">

<?php

// GD Product Center //
if (!defined("GDPRODUCTSCENTER_INSTALLED")) {
_e("GD Product Center plugin is not active.", "gd-products-center");
} else {
gdpc_render_compare();
}
// GD Product Center //

?>

</div><!– #content –>
</div><!– #container –>

<?php get_footer(); ?>[/php]

GD Product Center code is in the middle inside the comments block clearly marked First few and last few lines are standard for the template. All template content here is from TwentyTen theme.

Products Index Template

This template is always named like this: gdpc-products.php.

[php]<?php get_header(); ?>

<div id="container" class="one-column">
<div id="content" role="main">

<?php

// GD Product Center //
if (!defined("GDPRODUCTSCENTER_INSTALLED")) {
_e("GD Product Center plugin is not active.", "gd-products-center");
} else {
gdpc_render_product_types();
}
// GD Product Center //

?>

</div><!– #content –>
</div><!– #container –>

<?php get_footer(); ?>[/php]

The only difference here is that this template calls different function on line 12.

Company: Brand – Single

This template name is: single-gdpccmp_name.php. Name is replaced by the name of the company.

[php]<?php get_header(); ?>

<div id="container">
<div id="content" role="main">

<?php

// GD Product Center //
if (have_posts()) :
while (have_posts()) :
the_post();

if (!defined("GDPRODUCTSCENTER_INSTALLED")) {
_e("GD Product Center plugin is not active.", "gd-products-center");
} else {
gdpc_render_single_company();
}

endwhile;
endif;
// GD Product Center //

?>

</div><!– #content –>
</div><!– #container –>

<?php get_sidebar(); ?>
<?php get_footer(); ?>[/php]

Company: Brand – Archive

This template name is: archive-gdpccmp_name.php. Name is replaced by the name of the company.

[php]<?php get_header(); ?>

<div id="container">
<div id="content" role="main">

<?php

// GD Product Center //
if (!defined("GDPRODUCTSCENTER_INSTALLED")) {
_e("GD Product Center plugin is not active.", "gd-products-center");
} else {
gdpc_render_archive_companies();
}
// GD Product Center //

?>

</div><!– #content –>
</div><!– #container –>

<?php get_sidebar(); ?>
<?php get_footer(); ?>[/php]

Product Type: Single Product

This template name is: single-gdpccpt_name.php. Name is replaced by the name of the product type.

[php]<?php get_header(); ?>

<div id="container">
<div id="content" role="main">

<?php

// GD Product Center //
if (have_posts()) :
while (have_posts()) :
the_post();

if (!defined("GDPRODUCTSCENTER_INSTALLED")) {
_e("GD Product Center plugin is not active.", "gd-products-center");
} else {
gdpc_render_single();
}

endwhile;
endif;
// GD Product Center //

?>

</div><!– #content –>
</div><!– #container –>

<?php get_sidebar(); ?>
<?php get_footer(); ?>[/php]

Product Type: Products Archive

This template name is: archive-gdpccmp_name.php. Name is replaced by the name of the product type.

[php]<?php get_header(); ?>

<div id="container">
<div id="content" role="main">

<?php

// GD Product Center //
if (!defined("GDPRODUCTSCENTER_INSTALLED")) {
_e("GD Product Center plugin is not active.", "gd-products-center");
} else {
gdpc_render_archive();
}
// GD Product Center //

?>

</div><!– #content –>
</div><!– #container –>

<?php get_sidebar(); ?>
<?php get_footer(); ?>[/php]

Next tutorial will show how to make all templates for a theme.

Comments

Leave a Reply