Skip to content

Commit

Permalink
Start the readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ljb0904 committed Dec 30, 2019
1 parent ac261ef commit 37e77e2
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,66 @@
# october-catalog

Catalog for OctoberCMS.

Simple catalog for OctoberCMS. Category model is a nested tree and is reorderable.

Components return Collections and Eloquent Models for ease of use in exploring the
build of the theme pages. No assumptions are made on display of the catalog.

## Categories

To show categories, include the component CategoryList on your page. CategoryList
requires no parameters.
```
...
[CategoryList]
==
```

Then, in twig template, to get the Root Category collection,
```
{% set obCategoryList = CategoryList.getRootCategories() %}
{% if obCategoryList.isNotEmpty() %}
<ul>
{% for obCategory in obCategoryList if obCategory.nestedCount > 0 %}
<li>{{ obCategory.name }} has {{ obCategory.productCount }} local product(s)</li>
{% endfor %}
</ul>
{% endif %}
```

We can get the subcategories of any category by
```
{{ obCateogry.subcategories }}
```
which is a collection of Category Model.

We can use CategoryItem to get a single Category from url slug
```
title = "Category Page"
url = "/category/:slug"
[CategoryItem]
slug = "{{ :slug }}"
==
{% set obCategory = CategoryItem.get() %}
{{ }}
```

## Products
We can get all products for a category with ProductList. ProductList requires no
parameters.
```
{% set obProductList = ProductList.get(obCategory) %}
{% if obProductList.isNotEmpty() %}
<ul>
{% for obProduct in obProductList %}
<li>{{ obProduct.name }}</li>
{% endfor %}
</ul>
{% else %}
<p>No products.</p>
{% endif %}
```


0 comments on commit 37e77e2

Please sign in to comment.