Skip to content

Commit

Permalink
support categories, fixes #106
Browse files Browse the repository at this point in the history
  • Loading branch information
dennmuel committed Nov 12, 2019
1 parent fa410fb commit 176c548
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 0 deletions.
4 changes: 4 additions & 0 deletions styles/bootstrap.less
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@
}
}

.article_count {
margin-bottom: 1em;
}

// Because we want to float the search right when the header is not collapsed
// Why you no give us pull-md-right bootstrap?
.pull-md-right {
Expand Down
40 changes: 40 additions & 0 deletions templates/frontend/components/breadcrumbs_catalog.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{**
* templates/frontend/components/breadcrumbs_catalog.tpl
*
* Copyright (c) 2014-2019 Simon Fraser University
* Copyright (c) 2003-2019 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @brief Display a breadcrumb nav item showing the location in the catalog.
* This only supports one-level of nesting, as does the category hierarchy data.
*
* @uses $type string What kind of page should we use to construct urls
* (category, series, new)?
* @uses $parent Category A parent category if one exists
* @uses $currentTitle string The title to use for the current page.
* @uses $currentTitleKey string Translation key for title of current page.
*}

<nav class="cmp_breadcrumbs cmp_breadcrumbs_catalog" role="navigation" aria-label="{translate key="navigation.breadcrumbLabel"}">
<ol class="breadcrumb">
<li>
<a href="{url page="index" router=$smarty.const.ROUTE_PAGE}">
{translate key="common.homepageNavigationLabel"}
</a>
</li>
{if $parent}
<li>
<a href="{url op=$type path=$parent->getPath()}">
{$parent->getLocalizedTitle()|escape}
</a>
</li>
{/if}
<li class="active">
{if $currentTitleKey}
{translate key=$currentTitleKey}
{else}
{$currentTitle|escape}
{/if}
</li>
</ol>
</nav>
99 changes: 99 additions & 0 deletions templates/frontend/pages/catalogCategory.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{**
* templates/frontend/pages/catalogCategory.tpl
*
* Copyright (c) 2014-2019 Simon Fraser University
* Copyright (c) 2003-2019 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @brief Display the page to view a category of the catalog.
*
* @uses $category Category Current category being viewed
* @uses $publishedSubmissions array List of published submissions in this category
* @uses $parentCategory Category Parent category if one exists
* @uses $subcategories array List of subcategories if they exist
* @uses $prevPage int The previous page number
* @uses $nextPage int The next page number
* @uses $showingStart int The number of the first item on this page
* @uses $showingEnd int The number of the last item on this page
* @uses $total int Count of all published submissions in this category
*}
{include file="frontend/components/header.tpl" pageTitleTranslated=$category->getLocalizedTitle()}

<div class="page page_catalog_category">

{* Breadcrumb *}
{include file="frontend/components/breadcrumbs_catalog.tpl" type="category" parent=$parentCategory currentTitle=$category->getLocalizedTitle()}
<h1>
{$category->getLocalizedTitle()|escape}
</h1>

{* Image and description *}
{assign var="image" value=$category->getImage()}
{assign var="description" value=$category->getLocalizedDescription()|strip_unsafe_html}
<div class="about_section{if $image} has_image{/if}{if $description} has_description{/if}">
{if $image}
<div class="cover" href="{url router=$smarty.const.ROUTE_PAGE page="catalog" op="fullSize" type="category" id=$category->getId()}">
<img src="{url router=$smarty.const.ROUTE_PAGE page="catalog" op="thumbnail" type="category" id=$category->getId()}" alt="null" />
</div>
{/if}
{if $description}
<div class="description">
{$description|strip_unsafe_html}
</div>
{/if}
</div>

{if !$subcategories->wasEmpty()}
<nav class="subcategories" role="navigation">
<h2>
{translate key="catalog.category.subcategories"}
</h2>
<ul>
{iterate from=subcategories item=subcategory}
<li>
<a href="{url op="category" path=$subcategory->getPath()}">
{$subcategory->getLocalizedTitle()|escape}
</a>
</li>
{/iterate}
</ul>
</nav>
{/if}

{* Count of articles in this category *}
<div class="article_count">
{translate key="catalog.browseTitles" numTitles=$total}
</div>

{* No published titles in this category *}
{if empty($publishedSubmissions)}
<p>{translate key="catalog.category.noItems"}</p>
{else}
<ul class="cmp_article_list articles">
{foreach from=$publishedSubmissions item=article}
{include file="frontend/objects/article_summary.tpl" article=$article hideGalleys=true}
{/foreach}
</ul>

{* Pagination *}
{if $prevPage > 1}
{capture assign=prevUrl}{url router=$smarty.const.ROUTE_PAGE page="catalog" op="category" path=$category->getPath()|to_array:$prevPage}{/capture}
{elseif $prevPage === 1}
{capture assign=prevUrl}{url router=$smarty.const.ROUTE_PAGE page="catalog" op="category" path=$category->getPath()}{/capture}
{/if}
{if $nextPage}
{capture assign=nextUrl}{url router=$smarty.const.ROUTE_PAGE page="catalog" op="category" path=$category->getPath()|to_array:$nextPage}{/capture}
{/if}
{include
file="frontend/components/pagination.tpl"
prevUrl=$prevUrl
nextUrl=$nextUrl
showingStart=$showingStart
showingEnd=$showingEnd
total=$total
}
{/if}

</div><!-- .page -->

{include file="frontend/components/footer.tpl"}

0 comments on commit 176c548

Please sign in to comment.