Retired Documentation:  You are using the documentation for version 1.7.3 which was retired in 2013. Go here for the latest version documentation or check here for your available upgrades to the latest version.

Display Class

The Display class provides all the HTML display elements used in the ExpressionEngine Control Panel pages, including those of the modules. Nearly all required HTML elements can be displayed using this class.

set_return_data(title [string], body [string], crumb [string], rcrumb [string])

Sets return data for Display class.

Class: Display (DSP)

Description: Instead of uniquely setting the four main Display class varibles, you can use this function to set them for you.

$DSP->set_return_data($LANG->line('email_sent'), $success_mesage, $LANG->line('email_sent'));

allowed_group(which [string])

Verifies access depending on group

Class: Display (DSP)

Description: When a user or logged in member visits an EE site, the Session class ascribes user data to them that, among other things, pertains to their member groups's access to various parts of the site. which is the name of the field in the exp_member_groups database table. Returns false if they do not have access, true if they do.

if ( ! $DSP->allowed_group('can_access_admin'))
{
     return $DSP->no_access_message();
}

show_full_control_panel()

Outputs the default CP page.

Class: Display (DSP)

Description: Outputs the default Control Panel page. Used by the system.

show_restricted_control_panel()

Shows restricted version of the CP.

Class: Display (DSP)

Description: Outputs the default Control Panel page but lacking any of the usual links and bredcrumb. Used by the system for the login page and bookmarklet.

html_header(title [string])

Creates Control Panel's HTML header

Class: Display (DSP)

Description: Creates Control Panel's HTML header. Used by the system.

fetch_stylesheet()

Retrieves CSS for Control Panel

Class: Display (DSP)

Description: Retrieves the CSS content for the Control Panel depending on the user's settings. Used by the system.

file_open(file_location [string])

Opens up local file and returns contents

Class: Display (DSP)

Description: OPens up a local file and returns its contents, if unable to open file returns FALSE.

page_header(pad [int])

Creates topmost header for Control Panel

Class: Display (DSP)

Description: Creates topmost header for Control Panel, which contains the Quicklinks and logout links. Used by the system.

fetch_quicklinks()

Fetches Quicklinks for the user

Class: Display (DSP)

Description: Fetches the Quicklinks for the user that are displayed in the topmost header of the Control Panel. Used by the system.

fetch_quicktabs()

Fetches CP Tabs for the user

Class: Display (DSP)

Description: Fetches the Tabs that are added on to the default tabs in the Control Panel. Used by the system.

simple_header()

Creates a simple header for CP

Class: Display (DSP)

Description: Creates a simple version of the topmost header for Control Panel. Used by the system.

equalize_text(test [array])

Equalize length of all text in array

Class: Display (DSP)

Description: Lets one "equalize" the text length by adding non-breaking spaces before/after each line so that they all match, which is helpful for making navigation text all the same length

page_navigation()

Main Control Panel navigation

Class: Display (DSP)

Description: Creates the main Control Panel navigation depending on the user's access permissions. Used by the system.

content()

Content wrapper

Class: Display (DSP)

Description: Wraps the main page's content in a <div> tag and returns it. Used by the system.

secure_hash()

Adds Secure Hashes to CP

Class: Display (DSP)

Description: Adds Secure Hashes to $DSP->body when forms are found.

breadcrumb()

Creates breadcrumb navigation

Class: Display (DSP)

Description: Creates breadcrumb navigation for the Control Panel when the Display class's show_crumb is not set to FALSE. Used by the system.

right_crumb(title [string],url [string], extra [string], pop [bool])

Creates right crumb button

Class: Display (DSP)

Description: Creates a button on the right side of the breadcrumb area. Useful for stuff like a New Item button.

crumb_item()

Adds "breadcrum" formatting to an item

Class: Display (DSP)

Description: Adds "breadcrum" formatting to an item. Used by the system.

required(blurb [string])

Required field indicator

Class: Display (DSP)

Description: Returns the indicator that a field is required (red asterix by default). If blurb is set, it adds that string below the indicator.

content_close()

Closes a <div> tag.

Class: Display (DSP)

Description: Closes a <div> tag. Used by the Display class elsewhere for formatting content.

copyright()

Returns EllisLab, Inc. copyright

Class: Display (DSP)

Description: Returns EllisLab, Inc. copyright that is displayed at the bottom of the Control Panel. Used by the system.

html_footer()

HTML footer for Control Panel

Class: Display (DSP)

Description: Returns HTML footer for Control Panel. Used by the system.

error_message(message [string], num [int])

Output Error Message

Class: Display (DSP)

Description: Uses the Display class to output an error message. message is used for the outputted error message, while num deteremines if a "Back" link is added to the message (0 for no, 1 for yes).

if ( ! is_writeable($directory))
{
    return $DSP->error_message($LANG->line('upload_error'));
}

no_access_message(message [string])

Unauthorized access message

Class: Display (DSP)

Description: Uses the Display class to output an unauthorized access message.

if ( ! $DSP->allowed_group('can_admin_weblogs'))
{
    return $DSP->no_access_message();
}

pager(base_url [string], total_count [int], per_page [int], cur_page [int], qstr_var [string])

Creates Pagination

Class: Display (DSP)

Description: Returns the links for pagination by using the Pagination class. base_url is the base URL for the page, pre-pagination. total_count is the the total number of items. per_page is the number of items to show per page. cur_page is the current page being viewed (0 is the first page). qstr_var is the name of the variable in the URL's query string that determines the current pagination page.

// -----------------------------
//  Do we need pagination?
// -----------------------------

if ($query->num_rows > $row_limit)
{
    $row_count = ( ! $IN->GBL('row')) ? 0 : $IN->GBL('row');
    $url = 'C=communicate'.AMP.'M=view_cache';

    $paginate = $DSP->pager($url,
                            $query->num_rows,
                            $row_limit,
                            $row_count,
                            'row'
                            );
}

delete_confirmation(data [array])

Delete Confirmation Wrapper

Class: Display (DSP)

Description: Creates a standardized confirmation message used whenever something needs to be deleted.

$r = $DSP->delete_confirmation(
						array(
								'url'		=> 'C=modules'.AMP.'P=delete_module_confirm',
								'heading'	=> 'delete_module_heading',
								'message'	=> 'delete_module_message,
								'item'	=> $module_name,
								'extra'	=> '',
								'hidden'	=> array('module_id' => $module_id)
							)
						);

div(style [string], align [string])

Creates open <div> tag

Class: Display (DSP)

Description: Returns an opening <div> tag. style is the value of the style attribute for the <div> tag and is by default 'default'. align is optional and is used to specify alignment of the <div> tag.

$DSP->body .= $DSP->div('itemWrapper', 'center');

div_c

Closes a <div> tag

Class: Display (DSP)

Description: Returns a closing <div> tag.

$DSP->body .=  $DSP->div('itemWrapper').
               $DSP->anchor($link_url, $LANG->line($text)).
               $DSP->div_c();

qdiv(style [string], data [string])

Quick <div> tag for data

Class: Display (DSP)

Description: Returns data enclosed in a <div> tag with the style attribute style.

$DSP->body .= $DSP->qdiv('menuHeading', $LANG->line('email'));
// Returns <div style="menuHeading">Email Address</div>

span(style [string])

Opening <span> tag

Class: Display (DSP)

Description: Returns opening <span> tag with style style.

$DSP->body .= $DSP->span('alert').$LANG->line('assign_variable').$DSP->span_c();

span_c()

Returns closing <span> tag

Class: Display (DSP)

Description: Returns closing <span> tag.

qspan(style [string], data [string])

Quick <span> tag for data

Class: Display (DSP)

Description: Returns data enclosed in a <span> tag with the style attribute style.

$DSP->body .= $DSP->qspan('alert', $LANG->line('valid_email'));

heading(data [string], which [integer])

Create HTML header tag

Class: Display (DSP)

Description: Returns data enclosed in a an HTML header tag. which is used to specify which header tag to create, 1-6 (ex: <h3>).

$DSP->body .= $DSP->heading($LANG->line('error'), 3);

anchor(url [string], name [string], extras [string], pop [boolean])

Create HTML anchor (<a>) tag

Class: Display (DSP)

Description: Returns name enclosed in a an HTML anchor tag with the link url. extras allows the setting of extra content within the anchor tag like the title or target attribute. If pop is set to TRUE, then a target="_blank" will be added to the anchor tag. The default for pop is FALSE.

If you use extras to add additional attributes to the tag, such as javascript, remember to escape all quotes.

$DSP->body .= BR.$DSP->anchor('http://expressionengine.com/', 'ExpressionEngine', '', TRUE);

anchorpop(url [string], name [string], width [integer], height [integer])

Returns a link for a small Pop-up Window

Class: Display (DSP)

Description: Returns the HTML for an anchor that uses a javascript popup window link with url as the link and name as the link's name. You can specify the size of the window using width and height, which have default values of 500 and 400, respectively.

$DSP->body .= $DSP->anchorpop('http://expressionengine.com/', 'ExpressionEngine');

pagepop(url [string], name [string])

Returns a link for a Full Pop-up Window

Class: Display (DSP)

Description: Returns the HTML for an anchor that uses JavaScript to create a full page popup window with url as the link and name as the link's name.

$DSP->body .= $DSP->anchorpop('http://expressionengine.com/', 'ExpressionEngine');

mailto(email [string], name [string])

Returns a mailto link.

Class: Display (DSP)

Description: Returns a link containing a mail to link with email as the email address and name as the name of the link.

$DSP->body .= $DSP->mailto('webmaster@web.com', 'Webmaster');
// Returns <a href='mailto:webmaster@web.com'>Webmaster</a>

br(num [integer])

Returns a string of <br /> tags.

Class: Display (DSP)

Description: Returns a string of <br /> tags. num specified the number of <br /> tags to return.

qbr(num [integer])

Returns <br /> tags in a <div> tag.

Class: Display (DSP)

Description: Returns a string of <br /> tag enclosed in a <div> tag. num specified the number of <br /> tags to return. The reason for the <div> is XHTML Strict compatibility.

itemgroup(top [string], bottom [string])

Returns item group.

Class: Display (DSP)

Description: Returns a <div> with the style 'itemWrapper' (common in the CP for breaking up content) containing the data in top as the title (<>> with style 'itemTitle') and bottom as the main content.

nl(num [integer])

Returns a string of newlines (\n)

Class: Display (DSP)

Description: Returns a string of newlines with num being the number of new lines.

nbs(num [integer])

Returns a string of &nbsp; entities

Class: Display (DSP)

Description: Returns a string of &nbsp; entities with num being the number of &nbsp; entities.

table_open(properties [array])

Returns an opeing <table> tag

Class: Display (DSP)

Description: Returns an opeing <table> tag based on the array of attributes sent.

$r = $DSP->table_open(array('class' => 'tableBorder', 'width' => '100%'));

table_row(array [array])

Returns a complete table row

Class: Display (DSP)

Description: Returns a complete row of table data based on the text and data sent to it

$table_row = array(
				'cell1' => array('valign' => "top", 'width' => "220px", 'text' => $first_text),
				'cell2' => array('class' => "default", 'width'  => "8px"),
				'cell3' => array('valign' => "top", 'text' => $third_text));

$DSP->body .= $DSP->table_row($table_row).

table_close(padding [bool])

Returns closing <table> tag

Class: Display (DSP)

Description: Returns closing <table> tag. If parameter is TRUE, it adds some padding underneath table.

form_open(attributes [array], hidden [array])

Returns opening form tag

Class: Display (DSP)

Description: Returns opening form tag. The first parameter is for the attributes of the <form> tag and the second parameter are any hidden fields to include

$r = $DSP->form_open(
					array(
						  'action'	=> 'C=modules'.AMP.'M=forum',
						  'method'	=> 'post',
						  'name'	=> 'entryform',
						  'id'		=> 'entryform'
						 ),
					array(
						  'member_id' => $member_d,
						)
				 );

form_close()

Returns closing </form> tag

Class: Display (DSP)

Description: Returns closing </form> tag.

input_hidden(name [string], value [string])

Returns hidden field

Class: Display (DSP)

Description: Returns hidden field.

input_text(name [string], value [string], size [int], maxlength [string], style [string], width [string], extras [string], convert [boolean])

Returns input text form field

Class: Display (DSP)

Description: Returns input text form field. The convert parameter determines whether the value parameter has its entities converted to ASCII text, and the default is FALSE.

If you use extras to add additional attributes to the tag, such as javascript, remember to escape all quotes.

 $DSP->body .= $DSP->div('itemWrapper').
               $DSP->qdiv('defaultBold', BR.$LANG->line('category_name', 'cat_name')).
               $DSP->input_text('cat_name', $cat_name, '20', '60', 'input', '260px', '', TRUE).
               $DSP->div_c();

input_pass(name [string], value [string], size [int], maxlength [string], style [string], width [string])

Returns input password form field

Class: Display (DSP)

Description: Returns input password form field.

input_textarea(name [string], value [string], rows [int], style [string], width [string], extras [string], convert [boolean])

Returns textarea

Class: Display (DSP)

Description: Returns textarea form field. The convert parameter determines whether the value parameter has its entities converted to ASCII text, and the default is FALSE.

If you use extras to add additional attributes to the tag, such as javascript, remember to escape all quotes.

$DSP->body .= $DSP->div('itemWrapper')
              .$DSP->input_textarea('template_data', $query->row['template_data'], '25', 'textarea', '100%')
              .$DSP->div_c();

input_select_header(name [string], multi [string], size [integer], width [string])

Returns select list form tag

Class: Display (DSP)

Description: Returns select list form tag. The multi parameter should be set to 1, 'y', or 'yes', if you wish the tag to be a multi-select list, and you can set size to indicate how many options to show at once.

$DSP->body .= $DSP->div('itemWrapper')
              .$DSP->qdiv('itemTitle', $LANG->line('category_option'))
              .$DSP->input_select_header('category[]', 'y',8)
              .$DSP->input_select_option('all', $LANG->line('none'))
              .$DSP->input_select_option('none', $LANG->line('none'))
              .$possible_categories
              .$DSP->input_select_footer();

input_select_option(value [string], item [string], selected [string], extra [string])

Returns select list option tag

Class: Display (DSP)

Description: Returns select list option tag. value is the value that this option will be set as, whereas item is what is displayed for the option. To make an item selected, set selected equal to 1, 'y', or 'yes'. Finally, extra will add any extra attributes onto the <option> tag.

$DSP->body .= $DSP->div('itemWrapper')
              .$DSP->qdiv('itemTitle', $LANG->line('category_option'))
              .$DSP->input_select_header('category[]', 'y',8)
              .$DSP->input_select_option('all', $LANG->line('all'), 'y')
              .$DSP->input_select_option('none', $LANG->line('none'))
              .$possible_categories
              .$DSP->input_select_footer();

input_select_footer()

Returns closing <select> tag

Class: Display (DSP)

Description: Returns closing <select> tag.

input_checkbox(name [string], value [string], checked [string], extras [string])

Returns checkbox form tag

Class: Display (DSP)

Description: Returns checkbox form tag. To have the checkbox checked by default, set checked to 1, 'y', or 'yes'.

If you use extras to add additional attributes to the tag, such as javascript, remember to escape all quotes.

$DSP->body .= $DSP->input_checkbox('use_format', 'y', 1);

input_radio(name [string], value [string], checked [string], extras [string])

Returns radio button form tag

Class: Display (DSP)

Description: Returns radio button form tag. To have the radio button selected by default, set checked to 1, 'y', or 'yes'.

If you use extras to add additional attributes to the tag, such as javascript, remember to escape all quotes.

$DSP->body .= $DSP->input_radio('comment_notify', 'n', $selected);

input_submit(name [string], value [string], extras [string])

Returns form submit tag

Class: Display (DSP)

Description: Returns form submit tag.

If you use extras to add additional attributes to the tag, such as javascript, remember to escape all quotes.

toggle()

Returns JavaScript checkbox toggle code

Class: Display (DSP)

Description: Returns JavaScript checkbox toggle code, which allows you to create a checkbox at the top of a list of items that will automatically select or de-select all the items in the table. You must name the form 'target', name the select/de-select checkbox 'toggleflat' and add a bit of javascript to it, AND each item must have a checkbox named 'toggle[]' with a unique identifying code for each. See the example below for a bit more help.

$DSP->body .= $DSP->toggle();  // Load Javascript before form
$DSP->body .= $DSP->form('C=modules'.AMP.'M=moblog'.AMP.'P=delete_confirm', 'target');

$DSP->body .= $DSP->table('tableBorder', '0', '0', '').
              $DSP->tr().
              $DSP->td('tablePad');

// At the top, have one of the heading table cells contain a
// checkbox named 'toggleflag' with the onclick javascript.

$DSP->body .= $DSP->table('', '0', '0', '500px').
              $DSP->tr().
              $DSP->table_qcell('tableHeadingBold',
                                array(
                                      $LANG->line('moblog_view'),
                                      $LANG->line('moblog_modify'),
                                      $DSP->input_checkbox('toggleflag', '', '', "onclick=\"toggle(this);\"").
                                      NBS.$LANG->line('delete').NBS.NBS)
                                ).
              $DSP->tr_c();

$i = 0;

foreach ($query->result as $row)
{
     $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo';

     $modify_url = BASE.AMP.'C=modules'.AMP.'M=moblog'.AMP.'P=modify'.AMP.'id='.$row['moblog_id'];

     $DSP->body .= $DSP->tr();

     $DSP->body .= $DSP->table_qcell($style, $row['moblog_full_name'], '50%');
     $DSP->body .= $DSP->table_qcell($style, $DSP->anchor($modify_url,$LANG->line('moblog_modify')), '30%');

     // For each moblog/member/comment/etc. we have a checkbox with
     // the name being 'toggle[]' and the value the id.

     $DSP->body .= $DSP->table_qcell($style, $DSP->input_checkbox('toggle[]', $row['moblog_id']), '20%');

     $DSP->body .= $DSP->tr_c();
}

$DSP->body .= $DSP->table_c();

$DSP->body .= $DSP->td_c().
              $DSP->tr_c().
              $DSP->table_c();

$DSP->body .= $DSP->qdiv('itemWrapper', BR.$DSP->input_submit($LANG->line('delete')));
$DSP->body .= $DSP->form_c();

Top of Page