Retired Documentation
You are using the documentation for version 2.11.9. Go here for the latest version or check here for your available upgrades to the latest version.
Control Panel Styles¶
General Guidelines¶
External Links¶
To protect the users control panel URL from ending up in web server
referrer logs, use Cp::masked_url
from the Control Panel Class:
ee()->cp->masked_url('http://www.google.com');
Will result in:
http://example.com/index.php?URL=http://www.google.com
Internal Links¶
Internal control panel links should be generated with the cp_url()
helper function which generates control panel URLs based on parameters
passed in.
For example, to link to the content_publish
controller, pass it in
as the first parameter to cp_url()
:
cp_url('content_publish');
To link to a particular method in a controller, add it to the parameter with a slash:
cp_url('content_publish/method_name');
If the method accepts arguments, they can be passed in cleanly by adding them on the end separated by a slash:
cp_url('content_publish/method_name/5');
If the link requires any other GET parameters, they can be passed in via an associative array in the second parameter:
cp_url('content_publish/entry_form', array('channel_id' => $channel_id));
Control Panel Constants¶
BASE
- Name of control panel file with the users session idAMP
- Will render&
AJAX_REQUEST
- Returns Boolean TRUE if a request was made via an Ajax RequestQUERY_MARKER
- Renders a query marker (?
)APPPATH
- Server path to thesystem/expressionengine
directoryBASEPATH
- Server path to thesystem/codeigniter
directory.PATH_MOD
- Server path to thesystem/expressionengine/modules
directoryPATH_PI
- Server path to thesystem/expressionengine/plugins
directoryPATH_THIRD
- Server path to thesystem/expressionengine/third_party
directoryPATH_JQUERY
- Server path to jQuery files atsystem/expressionengine/javascript/compressed/jquery
Customizing the Control Panel Theme¶
To modify the default control panel theme, we recommend creating a new theme rather than directly editing default. Create a new theme folder, my_theme for example, and copy the images from the default theme so that you end up with:
themes/cp_themes/my_theme
themes/cp_themes/my_theme/images
For any PHP or CSS files that are not present in your theme, ExpressionEngine will “fall back” and retrieve them from default instead. This means that your custom theme need only consist of the PHP and CSS files you have actually modified.
As a security precaution, the default theme’s PHP files are not actually
located in themes/cp_themes/default
but are instead located within
the system folder at system/expressionengine/views
. If you would
like to override any of those files in your own theme, copy them to your
own theme’s directory in a views
folder, making sure that the copied
files maintain the same directory structure in your theme as they do in
the views
directory. E.g.:
- themes/cp_themes/
- my_theme
- css/
- images/
- views/
- .htaccess
- _shared/
- overview.php
- sidebar.php
- errors
- error_general.php
- my_theme
Notice the addition of a .htaccess
file. Since the files in the themes
folder are publicly accessible, for security you want to disallow direct
access to your PHP view files. For Apache v2.2, the contents of this
.htaccess file should be:
Order deny,allow
Deny from all
And for Apache 2.4:
Require all denied
This will prevent direct access to your PHP files from a web browser such as
http://example.com/themes/cp_themes/my_theme/views/errors/error_general.php
,
but will not affect ExpressionEngine’s ability to read the files as neeeded,
nor of the web browser being able to access the theme’s CSS, images,
JavaScript, etc.
Overriding Control Panel Style¶
ExpressionEngine attempts to load an override.css
stylesheet after
all others, allowing for easy customization of styling. For example, if
you just want to change the color of some elements, your theme might
consist of only one CSS file:
themes/cp_themes/my_theme/css/override.css
This stylesheet will be loaded just prior to the cp_css_end
hook.
Design Snippets¶
The following are basic design snippets that may be used:
Basic Control Panel Layout¶
<div id="mainContent">
<div class="contents">
<div class="heading">
<h2 class="edit">Page Title</h2>
</div>
<div class="pageContents">
// Page Content Goes Here
</div> <!-- pageContents -->
</div> <!-- contents -->
</div> <!-- mainContent -->
When designing for the module and extension control panel pages, all third-party markup will be rendered in the pageContents div.
Table-based Layout¶
The ExpressionEngine Control Panel makes usage of the Table Class. You may load this library in your controller using:
ee()->load->library('table');
Two default table styles are defined in the Control Panel Library.
$cp_table_template
$cp_pad_table_template
Example Table-based Layout¶
The following example is a single table row from the Wiki Module update.php view file.
<?php
$this->table->set_heading(array(
array('data' => lang('setting'), 'width' => '50%'),
lang('preference')
));
$this->table->add_row(array(
lang('moderation_emails', 'wiki_moderation_emails'),
form_error('wiki_moderation_emails').
form_input('wiki_moderation_emails', set_value('wiki_moderation_emails', $wiki_moderation_emails_value), 'id="wiki_moderation_emails"')
));
echo $this->table->generate();
$this->table->clear()
?>
Submit Buttons¶
Form submit buttons should be constructed with the CodeIgniter Form Helper. Basic implementation is as follows:
<?=form_submit(array('name' => 'submit', 'value' => lang('submit'), 'class' => 'submit'));?>
Note that in order to use the table based layout sample code you must first load the table library in your module’s method.