Now updated to be compatible with the latest version of Phile and adds the option to include current folder in the sibling list.
A plugin for providing sibling and ancestor records to Phile themes. By default, Phile provides {{ pages }}
to theme templates. This plugin adds {{ siblings }}
and {{ ancestors }}
Questions? Comments? Feel free to throw something in the issue tracker
- Create following directory structure
phile_install_dir/plugins/annabel82/philefamilytwo
- Download and place the repository files in that directory.
- Modify your config file to include the plugin. For example:
$config['plugins'] = array(
'annabel82\\philefamilytwo' => array('active' => true),
);
Your template files will now have 2 new variables: {{ siblings }}
and {{ ancestors}}
.
{{ siblings }}
will contain a Page object for each page & subdirectory in the current directory (except the current page).- For subdirectories, the Page object will point to the index.md file of the subdirectory.
{{ siblings }}
will be sorted in default sort order.
{{ ancestors }}
will contain a Page object for each parent, grandparent, etc. directory.- If the current page is not the index page for a directory, then the index page will for the current directory will be the first ancestor.
{{ ancestors }}
will be sorted from last ancestor to first ancestor (the parent directory)- Pages in the
{{ ancestors }}
array will have an additionalis_dir
property.
show_current_location
Type: boolean
Default: TRUE
If TRUE the current location will be included in the sibling list. This is useful if you're building menus, and you wish the included items to be static in order to avoid popping (where the values change) when changing pages.
sibling_dirs
Type: boolean
Default: TRUE
{{ siblings }}
ordinarily contains an entry for every page that is in the same directory as the currently viewed page. It will also contain an entry for every subdirectory that is in the same directory as the currently viewed page. The entry for each directory will point to the index.md
file in the subdirectory.
Setting this option to FALSE
will cause {{ siblings }}
to only contain entries for pages.
ancestor_sort
Type: string
Default: 'asc'
If 'asc' (or anything other than 'desc'), the 1st ancestor will be the homepage, and the last ancestor will be the parent.
If 'desc', the 1st ancestor will be the parent, the 2nd the grandparent, etc.
Given this content structure:
/content/
index.md
about.md
recipes/
index.md
pie.md
cakes/
index.md
redvelvet.md
angelfood.md
viewing | Ancestors | Siblings |
---|---|---|
/ | NULL |
/about.md /recipes/index.md |
/recipes/ | /index.md |
/recipes/pie.md /recipes/cakes/index.md |
/recipes/cakes/redvelvet.md |
/index.md /recipes/index.md /recipes/cakes/index.md |
/recipes/cakes/angelfood.md |