WP-AppKit’s themes have a menu template. This menu is configured in your app’s WordPress panel. But you might want to create a link or a button to display a specific screen in your app outside the “official” app’s menu. So how can we do that?
In single page apps, navigation is handled with fragment identifiers (aka. anchors, see more at http://en.wikipedia.org/wiki/Fragment_identifier and http://backbonejs.org/#Router). If you wonder what’s a fragment identifier, it’s an optional part of the URL beginning with the # sign.
The main difference between classic web URL and the WP-AppKit’s links is that there is nothing before the # sign. The # sign is also followed by keywords (eg. component).
<a href="#component-cats">Articles about cats</a>
At the moment, fragment formats for WP-AppKit’s themes are:
|Component (ie. post list, a single page, a page tree…)||#component-[component-slug-defined-in-wordpress]|
You can also use the nice TemplateTags object in your templates or in the functions.js.
|Get a post link||TemplateTags.getPostLink(post_id,’posts’)|
|Get a page link||TemplateTags.getPageLink(page_id,component_slug)|
|Get comments link for a post||TemplateTags.getCommentsLink(post_id)|
|Get the previous screen link||TemplateTags.getPreviousScreenLink()|
A last word to say is that there is no 404 error in an app. If your link is wrong, it defaults to the home screen.