Skip to content

Layouts

Jo Dickson edited this page May 8, 2018 · 1 revision

Themes and/or other plugins can define new "layouts" that customize the way career path lists and degree lists are displayed (via shortcode). Alternatively, the existing "classic" layouts can be overridden if desired.

Layout overrides described below can be added to your theme's functions.php file, or within a custom plugin.

Career Paths

Career path list layouts consist of four main hooks: the "before", "title", "list", and "after" hooks. Each hook name is generated dynamically based on whether or not a filter has been registered using the expected hook naming schema, outlined below.

To define a new layout, add at least one new filter to the hooks described below with a custom, consistent layout name (letters and underscores only; examples use the layout name "mylayout"). The default "classic" layout will be used for hooks without a layout-specific override defined. For instance, to create a new career paths layout "mylayout" that has a custom "before" template, you would need to create a filter that hooks into ucf_career_paths_display_mylayout_before.

ucf_career_paths_display_LAYOUTNAME_before

Markup displayed immediately before the career paths list. Filters passed to this hook must return the "before" markup (string).

Example

// Adds custom "before" markup for the "mylayout" [career-paths] shortcode layout.
<?php
function custom_career_paths_display_mylayout_before( $content, $items, $args ) {
	ob_start();
?>
	<div class="ucf-career-paths-wrapper ucf-career-paths-mylayout-wrapper">
<?php
	return ob_get_clean();
}

add_filter( 'ucf_career_paths_display_mylayout_before', 'custom_career_paths_display_mylayout_before', 10, 3 );

Arguments

  • $content: String, any existing markup passed in to the layout hook
  • $items: Array of career path post term objects
  • $args: Array of shortcode attributes

ucf_career_paths_display_LAYOUTNAME_title

Markup that displays the title text above the career paths list. Filters passed to this hook must return the "title" markup (string).

Example

// Adds custom title markup for the "mylayout" [career-paths] shortcode layout.
function custom_career_paths_display_mylayout_title( $content, $items, $args ) {
	$formatted_title = '';
	if ( $title = $args['title'] ) {
		$formatted_title = '<h3 class="ucf-career-paths-title">' . $title . '</h3>';
	}
	return $formatted_title;
}

add_filter( 'ucf_career_paths_display_mylayout_title', 'custom_career_paths_display_mylayout_title', 10, 3 );

Arguments

  • $content: String, any existing markup passed in to the layout hook
  • $items: Array of career path post term objects
  • $args: Array of shortcode attributes

ucf_career_paths_display_LAYOUTNAME

The career paths list markup. Filters passed to this hook must return the career path list markup (string).

Example

<?php
// Adds custom list markup for the "mylayout" [career-paths] shortcode layout.
function custom_career_paths_display_mylayout( $content, $items, $args ) {
	ob_start();
?>
	<ul class="ucf-career-paths-list">
	<?php foreach( $items as $item ) : ?>
		<li class="ucf-career-path-item"><?php echo $item->name; ?></li>
	<?php endforeach; ?>
	</ul>
<?php
	return ob_get_clean();
}

add_filter( 'ucf_career_paths_display_mylayout', 'custom_career_paths_display_mylayout', 10, 3 );

Arguments

  • $content: String, any existing markup passed in to the layout hook
  • $items: Array of career path post term objects
  • $args: Array of shortcode attributes

ucf_career_paths_display_LAYOUTNAME_after

Markup displayed immediately after the career paths list. Filters passed to this hook must return the "after" markup (string).

Example

// Adds custom "after" markup for the "mylayout" [career-paths] shortcode layout.
function custom_career_paths_display_mylayout_after( $content, $items, $args ) {
	ob_start();
?>
	</div>
<?php
	return ob_get_clean();
}

add_filter( 'ucf_career_paths_display_mylayout_after', 'custom_career_paths_display_mylayout_after', 10, 3 );

Arguments

  • $content: String, any existing markup passed in to the layout hook
  • $items: Array of career path post term objects
  • $args: Array of shortcode attributes

Degree Lists

TODO

Clone this wiki locally