Themes and Templates

From aMember Pro Documentation
Revision as of 05:36, 7 February 2012 by Alexander (talk | contribs) (Create your own theme : step by step)
Jump to: navigation, search

Templates Syntax

aMember Pro v4 uses PHP-syntax based templates, like ones used in [|Zend Framework's Zend_View] or templates used in WordPress.

Finding the templates

aMember Pro templates are located in the following folders:

CSS files
JavaScript libraries
user-side templates
admin-side templates
user-side themes
admin-side themes


aMember Pro allows you to create a theme. You can copy any template, image or CSS from application/default/views folder to your theme folder and it will override default theme. Of course, it is effective only when your custom theme is enabled. It is recommended way to customer look&feel of aMember Pro, as your theme will not be overwritten by upgrades and it is easy to determine which exactly files were modified.

Create your own theme : quick todo

  • Create folder amember/application/default/themes/bob/
  • Go to aMember CP -> Setup : enable "bob" theme
  • Create file amember/application/default/themes/bob/theme.css and looking at amember/application/default/views/public/css/reset.css and amember.css, add custom styles to the theme.css.

After each step control results by looking at user pages.

Create your own theme : step by step

In this quick tutorial we will describe how to create new theme named mysite

  • STEP 1. Using your favorite FTP client, go to folder application/default/themes/ and create folder mysite
  • STEP 2. Create an html template file layout.phtml in the mysite folder

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title><?php p($title) ?></title>
    <?php $this->printLayoutHead(); ?>
<div class="am-body">
<?php include $this->_script('_top.phtml'); ?>

<?php if (empty($this->layoutNoTitle)): ?><h1><?php echo $title ?></h1><?php endif; ?>
<!-- content starts here -->
<?php echo $content ?>
<!-- content ends here -->

Here is a sample of theme-based image
<img src="<?php echo $this->_scriptImg('large-alert.png'); ?>">
and you can "override" base images too.

</div><!-- end of -->


This html contains the following important elements:

<?php p($title) ?> 
prints page title to HTML header
<?php $this->printLayoutHead(); ?> 
prints necessary header codes to HTML header
<div class="am-body"> ... </div> 
must be outside of your page where you embeds aMember content
<?php include $this->_script('_top.phtml'); ?> 
includes aMember top page items like language switch, login, logout and member menu items
<?php if (empty($this->layoutNoTitle)): ?><h1><?php echo $title ?></h1><?php endif; ?> 
conditionally displays page title
<?php echo $content ?> 
most important - displays aMember inner page content
<?php echo $this->_scriptImg('large-alert.png'); ?> 
(optionally) prints URL of image large-alert.png that you may upload to application/default/views/mysite/public/img/large-alert.png
  • STEP 3. Create a file application/default/themes/mysite/public/css/theme.css and put the following lines inside:

body { font-size: 16pt; background-color: lightred; }

  • STEP 4. Go to aMember Admin Control Panel -> Setup/Configuration, select "mysite" in "User Theme" dropdown and click "Save".

Congratulations! Your new theme created! If you open any of user-side pages, you will see it uses bigger text size, and red background color. Now, as you've got idea how to create templates, you can start real customization of your theme - change layout template as you want and change CSS styles as you want. Important note - step 2 and step 3 are both optional. If you do not need layout customization, it is not required to upload file layout.phtml, if you do not need CSS customization, you are also not required to upload the CSS file.