{layout='layouts/_about-layout'}

{!--
	404 redirect
	============
	This is a multi-entry channel page, it doesn't need third segment as is. So we use the following code to make sure the page sends a 404 if someone types in an incorrect URL in the browser address bar. i.e. http://example.com/about/sub-page/nothing
--}
{if segment_3}
	{redirect='404'}
{/if}

{!-- page vars (prefix p_) --}
{preload_replace:p_title='about {site_name}'}
{preload_replace:p_description='about {site_name}'}
{preload_replace:p_url='about'}
{!-- channel vars (prefix ch_) --}
{preload_replace:ch='about'}
{preload_replace:ch_status='Open|Default Page'}
{preload_replace:ch_disable='categories|category_fields|member_data|pagination'}
{!-- layout vars, channel/page related --}
{layout:set name='ch' value='{ch}'}
{layout:set name='p_url' value='{p_url}'}
{layout:set name='p_title' value='{p_title}'}
{layout:set name='ch_disable' value='{ch_disable}'}
{layout:set name='ch_status' value='{ch_status}'}
{if segment_2}{layout:set name='entry_ch' value='{ch}'}{/if}

		{!-- channel entries tag --}
		{exp:channel:entries channel='{ch}' disable='{ch_disable}' limit='1'{if segment_2} require_entry='yes'{if:else} status='Default Page'{/if}}
			{!-- layout vars, dynamic, not output --}
			{layout:set name='title' value='{if seo_title}{seo_title}{if:else}{p_title}{/if}{gv_sep}'}
			{layout:set name='description' value='{if seo_desc}{seo_desc}{if:else}{p_description}{/if}'}
			{!-- OpenGraph meta output --}
			{layout:set name='og_title' value='{if seo_title}{seo_title}{if:else}{p_title}{/if}'}
			{layout:set name='og_url'}{path='{p_url}'}{/layout:set}
			{layout:set name='og_description' value='{if seo_desc}{seo_desc}{if:else}{p_description}{/if}'}
			{!-- /layout vars, dynamic, not output --}

			{!-- content output --}
			<h1>{title}</h1>
			{!-- about_image is a grid field first we check to see if it exists then we output it's contents. --}
			{if about_image}
				{about_image}
					<figure {if about_image:align != 'none'}class="{about_image:align}"{/if}>
						<img src="{about_image:image}" alt="{about_image:caption:attr_safe}">
						<figcaption>{about_image:caption}</figcaption>
					</figure>
				{/about_image}
			{/if}
			{!-- page_content is a textarea with HTML output we don't need to wrap this tag with HTML as that is already included in it's output. --}
			{page_content}
			{!-- /content output --}

			{!--
				no results redirect
				===================
				If the entry doesn't exist, we redirect to 404. This works in tandem with the require_entry='yes' parameter on the channel entries tag.
			--}
			{if no_results}
				{redirect='404'}
			{/if}
		{/exp:channel:entries}
