Giter Site home page Giter Site logo

grav-theme-knowledge-base's Introduction

Knowledge Base Theme

Abandonment Notice: I'm afraid I simply don't have the time to maintain my Grav themes and plugins. Those interested in taking over should refer to the "Abandoned Resource Protocol". Feel free to fork and replace. So long, and thanks for all the fish.

This is a basic theme for a knowledge base for Grav CMS. It is minimal by design and is easy to customize. It is based on Yahoo's Pure.css framework.

Installation

Installing the Knowledge Base theme can be done in one of two ways. The GPM (Grav Package Manager) installation method enables you to quickly and easily install the theme with a simple terminal command, while the manual method enables you to do so via a zip file.

The theme by itself is useful, but you may have an easier time getting up and running by installing the skeleton. The Knowledge Base skeleton is a complete site with the theme itself, required plugins and configuration, and sample content.

GPM Installation (Preferred)

The simplest way to install this theme is via the Grav Package Manager (GPM) through your system's Terminal (also called the command line). From the root of your Grav install type:

bin/gpm install knowledge-base

This will install the Knowledge Base theme into your /user/themes directory within Grav. Its files can be found under /your/site/grav/user/themes/knowledge-base.

Manual Installation

To install this theme, just download the zip version of this repository and unzip it under /your/site/grav/user/themes. Then, rename the folder to knowledge-base. You can find these files either on GitHub or via GetGrav.org.

You should now have all the theme files under

/your/site/grav/user/themes/knowledge-base

NOTE: This theme is a modular component for Grav which requires the CMS itself and the following plugins to properly function as written (you can of course modify the theme once installed):

Updating

Backwards Compatibility Alert: If you are updating from 1.x and have used theme inheritance to customize the theme, then you must copy the contents of your customized knowledge-base.yaml file into your new theme's configuration file.

Furthermore, if you have overridden any template files, please note the following change. All instances of config.themes['knowledge-base'] have been replaced with grav.theme.config.

As development for the Knowledge Base theme continues, new versions may become available that add additional features and functionality, improve compatibility with newer Grav releases, and generally provide a better user experience. Updating Knowledge Base is easy, and can be done through Grav's GPM system or manually.

GPM Update (Preferred)

The simplest way to update this theme is via the Grav Package Manager (GPM). You can do this with this by navigating to the root directory of your Grav install using your system's terminal (also called command line) and typing the following:

bin/gpm update knowledge-base

This command will check your Grav install to see if your Knowledge Base theme is due for an update. If a newer release is found, you will be asked whether or not you wish to update. To continue, type y and hit enter. The theme will automatically update and clear Grav's cache.

Manual Update

Manually updating Knowledge Base is pretty simple. Here is what you will need to do to get this done:

  • Delete the your/site/user/themes/knowledge-base directory.
  • Download the new version of the Knowledge Base theme from either GitHub or GetGrav.org.
  • Unzip the zip file in your/site/user/themes and rename the resulting folder to knowledge-base.
  • Clear the Grav cache. The simplest way to do this is by going to the root Grav directory in terminal and typing bin/grav clear-cache.

Note: Any changes you have made to any of the files listed under this directory will also be removed and replaced by the new set. Any files located elsewhere (for example a YAML settings file placed in user/config/themes) will remain intact.

Customizing

To modify or customize this theme, you must first read and follow the documentation on theme inheritance. Following these instructions is the only way to ensure that your changes are not lost when the theme gets updated.

NOTE: You will need to copy and paste the contents of knowledge-base.yaml into your newly created <themename>.yaml!

Configuration

This theme can be configured in two places: knowledge-base.yaml and site.yaml.

knowledge-base.yaml

Here is the default configuration, which is commented to explain what the different settings do:

params:
  articles:
    root: /home                # the route where the articles themselves live
    blacklist: ['scratch']     # list of categories to ignore
    show:             # if all are set to false, the article header is removed
      date: true      # show article date in the article header
      authors: true   # show article authors in the article header
      topics: true    # show assigned topics in the article header
      time: true      # show reading time in the article header
  front:              # params for the front page content
    maxrows: 3        # the maximum number of rows on the front page
    maxentries: 5     # maximum number of articles displayed for each category
  sidebar:            # params for the sidebar
    maxentries: 5     # maximum number of articles to display in "Popular" and "Latest" sections
    show:               # if all are set to false, the sidebar is removed
      categories: true  # show Category list in the sidebar
      popular: true     # show the Popular Articles sidebar
      latest: true      # show the Latest Articles sidebar

Notes on params:articles:blacklist: Any articles containing a blacklisted category will not appear on the front page, in the sidebar, or in the list of articles by a given author.

site.yaml

Your site.yaml must specify three taxonomies:

taxonomies: [category,tag,author]

The only theme-specific customization looked for here is the text for the footer. You can change the footer text without touching the templates by adding something like the following to user/config/site.yaml:

footertext: |
	<p>
		First footer line.
	</p>
	<p>
		Here's a second.
	</p>

CSS

The template loads theme://css/custom.css if it exists. The simplest way to customize the CSS is to create this file in your inherited theme and add what styles you need. This way the base css/knowledge-base.css can be updated without losing your customizations.

Templates

To override templates, simply copy the file from the base theme into the same place in your inherited theme and edit as desired. If you configured your inheritied theme correctly, the Grav system will first look for files in your inherited theme. If it's not present, it will pull the file from the base theme.

Content

Templates

The following templates are available:

  • author is used for displaying information about an author and articles they have authored.

  • default is a blank template that just dumps a page's content.

  • error is used for displaying error messages.

  • front is only used for generating the front page. The front page is organzed by the category taxonomy.

  • item is used for an article.

  • taxonomy is used to display articles by taxonomy (i.e., category, tag, author).

Structure

Hopefully you're working with the skeleton packge that contains all the sample content. If not, at least have a look at that repository so you can follow along.

The theme expects three routes under the user/pages folder:

  • /home (or whatever was specified in user/config/themes/knowledge-base.yaml as articleroot)

    This is where all the knowlege base articles live. Each article should have its own folder containing an item.md file. There are a few prerequisites for the page front matter:

    • It must contain a title field.
    • It must contain an explicit date field representing the published date.
    • It must have at least one category assigned for it to appear on the front page. tag is completely optional. author is recommended. Multiple values are supported in any taxonomy.

    Two different icons are currently supported. By default, all articles are marked with a "text" icon. If the article contains media (usually video), then add media: video to the front matter. The "video" icon should then be used.

  • /taxonomy

    This is where users can get lists of articles by taxonomy. The taxonomy.md file can be titled in any way you wish, and it is recommended that caching be disabled. If no query parameters are passed, then it will display a list of known taxonomies. If a taxonomy is passed via the name parameter, then it will list valid values for that taxonomy. If the taxonomy value is also passed (via the val parameter), then a list of all articles matching that specific taxonomy will be listed.

    A note about authors: If a specific author page exists (see /authors route below), then the author's name will link to it. If no such page exists, then a generic list of articles will be generated.

  • /authors

    This folder should contain a top-level page that contains the following front matter:

    redirect: taxonomy?name=author

    All other content and headers will be ignored.

    The folder should then contain folders for each author (optional). The slug is determined by the built-in hyphenize twig filter. Each of those folders should contain an author.md file. The page's front matter must include an author field containing the properly capitalized and spaced name of the author. The template will create an initial heading, dump the page content (including images), and then follow with a list of articles this person authored. If no such folder exists, then the /taxonomy page will create a simple list of articles written by that author.

The sample content also shows a "Contact Us" page that you will need to configure yourself.

Credits

This is my first theme. Feedback and pull requests are warmly welcomed.

I decided to try this after a forum post asking if such a template already existed. The poster linked to a theme called "knowhow" by Hero Themes. That theme inspired this one, but this one was coded completely from scratch with no reference to the original code.

grav-theme-knowledge-base's People

Contributors

avantar avatar awrog avatar carragom avatar ftertre avatar hctagalong avatar lazyyz avatar lipository avatar lucasvieites avatar perlkonig avatar rapsli avatar rbukovansky avatar sebasvisser avatar theflighteur avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

grav-theme-knowledge-base's Issues

[FeatReq] Options for style of listings articles on homepage

I would like to be able to tell what to show on homepage, meaning how to list articles and which on homepage. I.e.:

Combobox with this options

  • Last 5 articles per category (current behaviour)
  • Last 5 articles of the whole site
  • Selected 5 articles with 5 input field for article links
    • /article01
    • /article05
    • /article02
    • /article04
    • /article03

Would it be possible?

Req: disable display of page.media.images at end of content

Is there a compelling reason to display (again) all page.media.images at the end of a page?

item.html.twig:

<section class="content">
   {{ page.content }}
   <p></p>
   {% for image in page.media.images %}
      {{ image.cropResize(700, 400).html("title", "alt", "itemscreenshot") }}
   {% endfor %}
</section>

Is it possible to define a frontmatter-variable to suppress this?
e.g. show_pagemedia

{% if page.header.show_pagemedia %}
   {% for image in page.media.images %}
      {{ image.cropResize(700, 400).html("title", "alt", "itemscreenshot") }}
   {% endfor %}
{% endif %}

Theme inheritence

I'm trying to create inherited theme, but as I have submitted here getgrav/grav#1353 it doesn't seem to be working.

Any idea what could be wrong? Thank you.

Don't display 'Comments' when the comments plugin is not activated

To prevent displaying 'Comments' at the bottom of an article when the comments plugin is not activated might I suggest adding a check at line 71 of item.html.twig:

{% if config.plugins.comments.enabled %}
<section class="comments">
<h2>{{ 'COMMENTS'|t }}</h2>
</section>
{% endif %}

[FeatReq] Options to show parts of pages

@Perlkonig Do you think it would be possible to make this theme more "optional", meaning On/Off switches which will show or hide parts of pages? I.e.:

  • Show Popular articles
  • Show Latest articles
  • Show Date of article
  • Show Author of article

etc.?

How to exclude search bar and sidebar from a specific page?

I would like to exclude the search bar and sidebar from some specific pages, e.g. http://<my domain/about. How would I be able to do that?

Is customising this theme using Theme Inheritance method the only way to achieve that?

Thanks a lot in advance

Exclude certain categories from knowledge base

Thanks a lot for your wonderful theme that i have easily followed and implemented a knowledge base on a GRAV site.

Please. I need your help in excluding certain categories from the knowledge base. Because, I also have a blog, news and events section on the site. So i want only the knowledge base categories to appear in the knowledge base.

I understand that this is the loops that display the categories of the knowledge base

{% for cat in taxonomy.taxonomy['category']|keys|sort|slice(0,maxrows*2) %}
	{% set node = node|merge([cat]) %}
	{% if node|length == 2 %}
		{% set rows = rows|merge([node]) %}
		{% set node = [] %}
	{% endif %}
{% endfor %}

I have tried modifying it to this to see if i can filter the categories but still not working

{% for cat in taxonomy.findTaxonomy({'category':['Housing','Programme']})|keys|sort|slice(0,maxrows*2) %}
	{% set node = node|merge([cat]) %}
	{% if node|length == 2 %}
		{% set rows = rows|merge([node]) %}
		{% set node = [] %}
	{% endif %}
{% endfor %}

Thanks for your kind help.

Last articles in Sidebar doesn't work when using subdirectories

When we use subdirectories in the HOME folder, the component Last articles of the sidebar doesn't work well. It tries to display the parents directories as an article, but not the articles in the subdirectories.

I see in the code that this is related to that line.
{% set articles = page.find(homeroute).children.order('date', 'desc') %}

But I don't have enough skills with twig & co to be able to propose a fully working PR.

Error 404 on accessing Categories

Hello Aaron,

I am not sure if this is an issue on Knowledge Base theme, or generic configuration issue on my Grav CMS.

I have started to put content on my web site. So far only 1 topic per categories. And I have only 3 categories so far. When I click on any categories, e.g. Grav CMS, I got error 404. The URL of the missing content is for instance http://<my domain>/taxonomy?name=category&val=Grav%20CMS.

So unlike on the demo page https://www.perlkonig.com/knowledge-base/ where I can access any categories, e.g. Topic 1, I get error 404 on my web site.

What could be the cause of this issue? Or is it because I missed installing any other plugins a part from the required ones? If so, which one please?

Thanks a lot in advance for your help.

Kind regards,

Anto

Small issues

Could you please make below shown happen? I believe it would make site look much better...
Thanks.

kb_issues

Theme inheritance: hardcoded theme names vs. theme config

When inheriting from the knowledge-base theme, one might wish to change the theme config in the derived theme, without touching the original. And while Grav apparently does not inherit a base theme's config, this can be achieved by copying over the param section of user/themes/knowledge-base/knowledge-base.yaml into the derived theme's config file (underneath or above the streams section responsible for the inheritance).

However, knowledge-base is accessing the theme config via config.themes['knowledge-base'], using the hardcoded theme name. This is null in a derived theme. Only config.themes['derived-theme'] (assuming the name of the child theme to be derived-them) is defined there. This leads to at least two issues:

  • The inherited theme breaks in several places (no sidebar, blacklist not working, ...)
  • Config changes to the inherited theme (performed as outlined above) take no effect

This issue has also been present in the deliver theme, leading to this issue, for example. The last reply there also outlines the solution:

  1. Add the following at the top of the base template:

     {% set theme_config = attribute(config.themes, config.system.pages.theme) %}
    

This is already present in the knowledge-base\templates\partials\base.html.twig, but never used.

  1. Then use theme_config instead of config.themes['theme-name'] in all template files.

theme_config will evaluate to config.themes['knowledge-base'] if the theme is used directly (hence, everything works exactly as before) and to config.themes['derived-theme'] in a derived theme. As per Flavio Copes' reply linked above, this is how it should be done.

Implementing this is as trivial as a search and replace in the template files. However, I'm not sure if this could potentially break existing setups for users? I don't think it should, though. Also, I'm wondering why no other users have reported this issue, while there apparently are people who do inherit from knowledge-base, as evident by this issue report. Shouldn't the sidebar be missing for them, amongst other issues? Maybe I am missing or confusing something here.

Side note: I think this is a bit of an issue with Grav. One would expect that if a specific config setting is not present in the derived theme's config, Grav would go looking in the base theme's config. This is what the tutorial about theme inheritance implies when it says "You can of course customize any part of the original base-theme". However, as per my testing as well as the forum link above, this seems not to be the case, making the whole them inheritance a bit inconsistent / counter-intuitive.

How to use Category page teplate?

Firstly, thanks for a great theme!
But I wonder how to use the new cetegory page template. You write "Categories can now have landing pages" but how do I get that to work?

relatedpages doesn't work

For some reason that I couldn't figure out yet the related pages are not showing up. But there a quiet a few pages that contain the same tags and fit into the same category.

Did I configure the plugin wrong? Is there something missing in the theme that I should watch out for?

Category links don't work.

My environment.

Grav v1.6.28
Theme : Knowledge Base v2.1.1

CentOS Linux release 7.9.2009 (Core)
PHP 7.3.25 (cli) (built: Nov 24 2020 11:10:55) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.25, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.25, Copyright (c) 1999-2018, by Zend Technologies
http://localhost/taxonomy?name=category&val=Orange

Error!
Woops. Looks like this page doesn't exist.

Hello.I love this theme. Please check when you have time.
thanks.

Comments in this theme

I'm trying to decipher why this is part of template item.html.twig:

<section class="comments">
     <h2>{{ 'COMMENTS'|t }}</h2>
</section>

Is there any reason for it? Is there any plugin this is dependable on? If so, could it please show it only when that plugin is available and enabled?

Thanks.

Multisite.

Does this theme work for multisite?

I have installed it on my server, and verified that it works on single site. However, when I access it in multisite mode, I got:

screen shot 2017-04-15 at 11 26 41 am

Category missing from list.

The last category is missing from list, when the number of categories is odd.

For example, say you have 5 categories, and only the first 4 are displayed, the 5th is missing. If you create a new category to make the total 6, all are displayed.

Req: up-to-date skeleton

I (still) love this theme and have it in use.
I've had quite some trouble updating it from 1.5 to GRAV 1.6.26.
Eventually I've got it to work, and it is still works like a charm!

It would be great (for new users) if the skeleton could be updated to the latest GRAV 1.6.x version

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.