<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY amp   "&#38;">
<!ENTITY copy   "&#169;">
<!ENTITY gt   "&#62;">
<!ENTITY hellip "&#8230;">
<!ENTITY laquo  "&#171;">
<!ENTITY lsaquo   "&#8249;">
<!ENTITY lsquo   "&#8216;">
<!ENTITY lt   "&#60;">
<!ENTITY nbsp   "&#160;">
<!ENTITY quot   "&#34;">
<!ENTITY raquo  "&#187;">
<!ENTITY rsaquo   "&#8250;">
<!ENTITY rsquo   "&#8217;">
]>


<xsl:stylesheet version="3.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ou="http://omniupdate.com/XSL/Variables"
xmlns:fn="http://omniupdate.com/XSL/Functions"
xmlns:ouc="http://omniupdate.com/XSL/Variables"
exclude-result-prefixes="ou xsl xs fn ouc"
expand-text="yes">

<xsl:import href="common.xsl"/>

<xsl:template name="template-headcode"/>
<xsl:template name="template-footcode"/>

<xsl:param name="current-breadcrumb">
	<xsl:choose>
		<xsl:when test="ou:not-empty(ou:pcf-param('breadcrumb'))">{ou:pcf-param('breadcrumb')}</xsl:when>
		<xsl:otherwise>{ou:pcf-param('heading')}</xsl:otherwise>
	</xsl:choose>
</xsl:param>

<xsl:template name="page-content">
	
	<xsl:variable name="search-root" select="if(ou:pcf-param('search-root') != '') then ou:pcf-param('search-root') else $dirname" />
	<xsl:variable name="logical-operator" select="if(ou:pcf-param('filter-option') = 'all') then true() else false()" />
	<xsl:variable name="filter-predicate" select="ou:get-filter-predicate($tags, 'tags/tag', $logical-operator)" />
	
	<xsl:variable name="filters">
		<xsl:text>items/item</xsl:text>	
		<!-- location filter is used so that only blog posts that are located in a given folder and its subfolders are returned -->
		<xsl:text>[starts-with(@href,'{replace($search-root, '/[^/]+$', '/')}')]</xsl:text>
		<xsl:if test="ou:pcf-param('post-author')!=''">
			<xsl:text>[author/text()='{ou:pcf-param('post-author')}']</xsl:text>
		</xsl:if>
		<xsl:if test="string-length(ou:pcf-param('post-year'))=4">
			<xsl:text>[contains(pubDate/text(), '{ou:pcf-param('post-year')}')]</xsl:text>
		</xsl:if>
		<xsl:value-of select="$filter-predicate" />
	</xsl:variable>
	
	<main class="content" id="main-content">
        <div class="page-header">
            <div class="container">
                <div class="row">
                    <div class="col-12">
						<h1>{if (ou:not-empty(ou:pcf-param('heading'))) then ou:pcf-param('heading') else'News Listing'}</h1>
                    </div>
                </div>
            </div>
        </div>
        <div class="container">
            <div class="row">
                <div class="col-12">
                    <div class="accordion nav-accordion" id="interiorNav">
                        <div class="accordion-item">
                            <h2 class="accordion-header">
                                <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#interiorNav-collapseOne" aria-expanded="true" aria-controls="interiorNav-collapseOne">
                                    <span class="fa fa-bars me-3"></span>
                                    Menu
                                </button>
                            </h2>
                            <div id="interiorNav-collapseOne" class="accordion-collapse collapse">
                                <div class="accordion-body">
									<xsl:call-template name="side-navigation" />
								</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-12">
                   <nav aria-label="breadcrumb">
					   <!-- see breadcrumbs xsl -->
					   <xsl:call-template name="output-breadcrumbs" />
					</nav>
                </div>
            </div>
            <div class="section section-reduced">
                <div class="row">
                    <div class="col-12 col-lg-9">
						<xsl:call-template name="dmc">
							<xsl:with-param name="options">
								<datasource>{ou:pcf-param('dsn')}</datasource>
								<xpath>{$filters}</xpath>
								<type>listing</type>
								<items_per_page>{ou:pcf-param('items-per-page')}</items_per_page>
								<querystring_control>true</querystring_control>
								<search_columns>title,description,author,searchtags</search_columns>
								<sort>date(pubDate) desc</sort>
							</xsl:with-param>

							<xsl:with-param name="script-name">blogs</xsl:with-param>
							<xsl:with-param name="debug" select="$dmc-debug" />
						</xsl:call-template>

						<xsl:apply-templates select="ouc:div[@label='maincontent']" />
                    </div>
                    <div class="col-12 col-lg-3">
						<xsl:apply-templates select="ouc:div[@label='sidebar']" />
<!-- 						Recent Articles -->
						<xsl:call-template name="dmc">
							<xsl:with-param name="options">
								<heading>Recent Articles</heading>
								<datasource>{ou:pcf-param('dsn')}</datasource>
								<xpath>items/item</xpath>
								<type>recent-sidebar</type>
								<items_per_page>4</items_per_page>
								<querystring_control>true</querystring_control>
								<search_columns>title,description,author,searchtags</search_columns>
								<sort>date(pubDate) desc</sort>
							</xsl:with-param>

							<xsl:with-param name="script-name">blogs</xsl:with-param>
							<xsl:with-param name="debug" select="$dmc-debug" />
						</xsl:call-template>
<!-- 						Featured News  -->
						<xsl:call-template name="dmc">
							<xsl:with-param name="options">
								<heading>Featured Posts</heading>
								<datasource>{ou:pcf-param('dsn')}</datasource>
								<xpath>items/item[featured/text()='true']</xpath>
								<type>sidebar</type>
								<items_per_page>5</items_per_page>
								<querystring_control>true</querystring_control>
								<search_columns>title,description,author,searchtags</search_columns>
								<sort>date(pubDate) desc</sort>
							</xsl:with-param>

							<xsl:with-param name="script-name">blogs</xsl:with-param>
							<xsl:with-param name="debug" select="$dmc-debug" />
						</xsl:call-template>
<!-- 						Related News  -->
						<xsl:call-template name="dmc">
							<xsl:with-param name="options">
								<heading>Related Posts</heading>
								<datasource>{ou:pcf-param('dsn')}</datasource>
								<xpath>{$filters}</xpath>
								<type>sidebar</type>
								<items_per_page>5</items_per_page>
								<querystring_control>true</querystring_control>
								<search_columns>title,description,author,searchtags</search_columns>
								<sort>date(pubDate) desc</sort>
							</xsl:with-param>

							<xsl:with-param name="script-name">blogs</xsl:with-param>
							<xsl:with-param name="debug" select="$dmc-debug" />
						</xsl:call-template>
<!-- 						Tag cloud -->
						<xsl:call-template name="dmc">
							<xsl:with-param name="options">
								<heading>Tag Cloud</heading>
								<datasource>{ou:pcf-param('dsn')}</datasource>
								<xpath>items/item</xpath>
								<type>available-tags</type>
								<querystring_control>true</querystring_control>
								<search_columns>title,description,author,searchtags</search_columns>
								<listing_page_url>https://hschub.ttuhsc.edu/_showcase/_redesign-2026/news-listing.aspx</listing_page_url>
							</xsl:with-param>

							<xsl:with-param name="script-name">blogs</xsl:with-param>
							<xsl:with-param name="debug" select="$dmc-debug" />
						</xsl:call-template>
                    </div>
                </div>
            </div>
        </div>
		<xsl:apply-templates select="ouc:div[@label='additionalcontent']" />
    </main>
</xsl:template>

</xsl:stylesheet>