-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add documentation for the first block recipe
- Loading branch information
Sebastian Vetter
committed
Aug 6, 2013
1 parent
4cefd6e
commit 37c5b3f
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ Contents: | |
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
recipes | ||
|
||
|
||
Indices and tables | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
======= | ||
Recipes | ||
======= | ||
|
||
Create a Custom Template Block | ||
------------------------------ | ||
|
||
Start off by creating a new app in your project, e.g. a ``blocks`` app. Conent | ||
blocks in fancypages are basically Django models that require a few additional | ||
attributes and definitions. | ||
|
||
Let's assume we want to create a simple widget that displays a custom template | ||
without providing any additional data that can be edited. All we need to do is | ||
define the following model:: | ||
|
||
from fancypages.models.blocks import ContentBlock | ||
from fancypages.library import register_content_block | ||
|
||
@register_content_block | ||
class MyTemplateBlock(ContentBlock): | ||
name = _("My template") | ||
code = u'my-template' | ||
group = u'My Blocks' | ||
template_name = u'blocks/my_template_block.html' | ||
|
||
def __unicode__(self): | ||
return self.name | ||
|
||
The first three attributes ``name``, ``code`` and ``group`` are important and | ||
have to be specified on every new content block. | ||
|
||
+-----------+---------------------------------------------------------+ | ||
| ``name`` | Display name of the content block | | ||
+-----------+---------------------------------------------------------+ | ||
| ``code`` | **Unique** code for the block to be identified by | | ||
+-----------+---------------------------------------------------------+ | ||
| ``group`` | Blocks can be grouped by using the same group name here | | ||
+-----------+---------------------------------------------------------+ |