Themes and PHP

From ExponentCMS Docs

Jump to: navigation, search
Edit Menu

Image:Icon_Designers_40px.png Themes and PHP

This page contains information about using PHP with Exponent Themes.

Contents

Exponent Specific PHP Functions

These are the Exponent PHP Functions which add content modules to an Exponent Theme. You can add or remove content modules, by editing the index.php file in your /themes/youractivetheme/ folder. Adding any of these functions this file will add the associated content module to all pages of your website. To remove a content module, such as the Login Module from your website, remove the relevant PHP function from the index.php file for your active theme.

Please note that removing a Container Module from a page does not remove any content which you've already added to a page of your website.

Container Modules

To insert the Main Container Module into a page, use:

<?php pathos_theme_main(); ?>

To insert the Left Container Module into a page, use:

<?php pathos_theme_showSectionalModule("containermodule","Default","","@left"); ?>

To insert the Right Container Module into a page, use:

<?php pathos_theme_showSectionalModule("containermodule","Default","","@right"); ?>

To insert the Header Container Module into a page, use:

<?php pathos_theme_showModule("textmodule","Default","","sitetitle"); ?>

To insert the Footer Container Module into a page, use:

<?php pathos_theme_showModule("textmodule","Footer","","footer"); ?>

Copyright

To display the site's Copyright info, use:

<?php exponent_theme_showModule("textmodule","Wide","","copyright"); ?>

File Paths

These are the file paths used in a PHP template to access specific Exponent folders.

Themes Folder Path

To access the Themes Folder Path, use:

<?php echo THEME_RELATIVE; ?>

Google Translation Module

To display the Google Translation Module on a page, use:

<?php pathos_theme_showModule("googletranslationmodule","","",""); ?>

Note: You must install this module before you add it to a page

HTML Header

To generate the Exponent HTML Header, use:

<?php echo pathos_theme_headerInfo($section); ?>

Login Module

To insert the Login Module into a page, use one of the following:

<?php if (isset($_REQUEST['login']) || exponent_sessions_loggedIn()) {pathos_theme_showModule("loginmodule","Default");} ?> 
<?php exponent_theme_showModule("loginmodule","Default","Member Login"); ?>
<?php exponent_theme_showModule("loginmodule","Logout Only","","@right"); ?>

Navigation

To insert a site Navigation menu, use one of the following PHP functions depending on which type of menu you wish to use on your site:

<?php pathos_theme_showModule("navigationmodule","Breadcrumb"); ?>
<?php pathos_theme_showModule("navigationmodule","Children Only"); ?>
<?php pathos_theme_showModule("navigationmodule","Collapsing Hierarchy"); ?>
<?php pathos_theme_showModule("navigationmodule","Default"); ?>
<?php pathos_theme_showModule("navigationmodule","Directional"); ?>
<?php pathos_theme_showModule("navigationmodule","Expanding Hierarchy"); ?>
<?php pathos_theme_showModule("navigationmodule","Full Hierarchy"); ?>
<?php pathos_theme_showModule("navigationmodule","Marked Hierarchy"); ?>
<?php pathos_theme_showModule("navigationmodule","Top Nav"); ?>
<?php pathos_theme_showModule("navigationmodule","You Are Here"); ?>

Note: For a full list of Navigation views installed on your system, look in the modules/navigationmodule/views/ folder, or in the themes/yourtheme/modules/navigationmodule/views/ folder for your active Theme.

Preview Module

To insert the Preview Module into a page, use:

<?php pathos_theme_showModule("previewmodule","Default"); ?>

Note: You must install this module before you add it to a page

Preview Module Admin Stylesheet

You can also use the preview module to load a separate CSS Stylesheet for users who are logged into your website. This may be desirable if, for instance, you are using a very narrow theme for your live site and need to increase the width of your site to allow space for Exponent's editing controls.

1. Create a CSS file with the additional styles you want to load for users who are logged in.

2. Name the CSS file admin.css and save it to your theme folder /themes/yourtheme/admin.css.

3. Create a Preview Module View with the following code:

{if $editMode == 1}
   <link rel="stylesheet" type="text/css" href="{$smarty.const.THEME_RELATIVE}admin.css"/>
{/if}

4. Name the view file _admin_css.tpl and save it to your theme folder /themes/yourtheme/previewmodule/_admin_css.tpl.

5. Edit your theme's index.php and insert the following code at the bottom of the header (this MUST GO BELOW your primary style sheet so it loads after):

<?php exponent_theme_showModule("previewmodule","_admin_css"); ?>

Your modified CSS will now load for all users who are logged into the site.

Search Module

To insert the Search Module into a page, use:

<?php pathos_theme_showModule("searchmodule","Default","",""); ?>

Site Title

To display your Exponent Site Title, use:

<?php echo SITE_TITLE; ?>

Source Selector

This HTML code and PHP source selector code must be placed in all Exponent Themes:

<body onLoad="pathosJSinitialize();">
    <?php pathos_theme_sourceSelectorInfo(); ?>

Generic PHP Functions

These are Generic PHP Functions which can be used in Exponent Themes.

Date and Year Display

To display the current date or year, use:

<?php $t=getdate(); $today=date('Y',$t[0]); print_r($today); ?>


Image:Icon_Resources_20px.png Designers Resources

Personal tools