Skip to content

Commit

Permalink
rtd
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichel committed Nov 15, 2024
1 parent 515693b commit 3fb0c70
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 0 deletions.
48 changes: 48 additions & 0 deletions docs/content/developers/guides/dynamic-blocks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
hide:
- toc
tags:
- Catagory
- CMS blocks
---

# Dynamic block contents in category page

In _backend > Catalog > Manage Categories_, we can configure a category page and put it on the main menu. The page contents are rendered in

> app\design\frontend\base\default\template\catalog\category\view.phtml
If we want to render an HTML table in which its data are taken from the database, we would follow these steps:

1. Create a custom block `mymodule/mytable` with template `mymodule/mytable.phtml`.
2. Whitelist our block for rendering in the frontend: backend > System > Permissions > Blocks
3. Create a CMS static block: backend > CMS > Static Blocks and set the _Content_ to render from our block with this directive:
```html
{{block type="mymodule/mytable" template="mymodule/mytable.phtml"}}
```
4. Create a subcategory: backend > Catalog > Manage Categories > Add a subcategory and in the _Display Setings_ tab, set the category attribute _Display Mode_ to _Static block only_ and _CMS Block_ pointing to our block.

Voila, the HTML table is rendered under the menu we just created. However, every time the table in the database is updated, and because CMS blocks rendering are taken from the cache, we would need to refresh the cache.

What if the table is constantly being updated, or there is an expiry condition on some data which shouldn't be included? In which case, we would want to render the HTML table dynamically. It's actually quite easy to do:

1. In the subcategory page in backend, set the _Description_ to this:
```html
{{block type="mymodule/mytable" template="mymodule/mytable.phtml"}}
```
2. Continue on to the _Display Setings_ tab and set the _CMS Block_ to _Please select a static block ..._.
3. In our config file, either in the module `etc/config.xml` or in the `local.xml`, insert the following:

```xml
<config>
<global>
<catalog>
<content>
<tempate_filter>cms/template_filter</tempate_filter> <!-- Note the typo on template must remain as "tempate". -->
</content>
</catalog>
</global>
</config>
```

That's it, the table is now rendered dynamically. There 's no need to create the CMS static block.
10 changes: 10 additions & 0 deletions docs/content/developers/guides/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
tags:
- Guides
---

# Guides

**Guides** are focused on accomplishing a specific task and assume that you are
already familiar with the basics of OpenMage. If you're looking for an
introduction to packaging, see :doc:`/tutorials/index`.
10 changes: 10 additions & 0 deletions docs/content/developers/tutorials/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
tags:
- Tutorials
---

# Tutorials

**Tutorials** are opinionated step-by-step guides to help you get familiar
with concepts. For more detailed information on specific
topics, see :doc:`/guides/index`.
8 changes: 8 additions & 0 deletions docs/content/users/modules/core/swatches.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
tags:
- Modules
---

# Swatches

Find a good description at: https://sherocommerce.com/tutorial-configurable-swatches-in-magento/
2 changes: 2 additions & 0 deletions docs_includes/abbreviations.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*[HTML5]: Hyper Text Markup Language
*[JSON]: JSON (JavaScript Object Notation) is a lightweight data-interchange format.
*[Mailpit]: Mailpit is a small, fast, low memory, zero-dependency, multi-platform email testing tool & API for developers.
*[MariaDB]: One of the possible databases OpenMage is compatible to.
*[MySQL]: One of the possible databases OpenMage is compatible to.
*[n98-magerun]: The n98 magerun cli tools provides some handy tools to work with Magento from command line.
*[OpenMage]: This project
*[phpMyAdmin]: phpMyAdmin is a free software tool written in PHP, intended to handle the administration of MySQL over the Web.
Expand Down
8 changes: 8 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,12 @@ extra:
Install: install
JavaScript: js
Modules: modules
PHP-7.4: php
PHP-8.0: php
PHP-8.1: php
PHP-8.2: php
PHP-8.3: php
PHP-8.4: php
TinyMCE: tinymce
Security: security

Expand Down Expand Up @@ -176,12 +178,16 @@ nav:
- 'Events':
- developers/events/list.md
- 'Guides':
- developers/guides/index.md
- developers/guides/dynamic-blocks.md
- developers/guides/observer.md
- 'Tools':
- developers/ddev.md
- developers/phpstorm.md
- 'Multistore':
- developers/error-pages.md
- 'Tutorials':
- developers/tutorials/index.md
- 'Documentation':
- developers/mkdocs.md
- 'Modules':
Expand All @@ -192,6 +198,8 @@ nav:
- users/modules/logging.md
- users/modules/products.md
- users/modules/social.md
- 'Core':
- users/modules/core/swatches.md
- 'Payment':
- users/modules/payment/bitcoin.md
- 'Themes':
Expand Down

0 comments on commit 3fb0c70

Please sign in to comment.