Anchors

From MegaZine3
Jump to: navigation, search
Plugin: Anchors
Name Anchors
Files
  • anchors.swf
Related plugins
This article is for the anchors plugin. Anchors could also refer to Layouting

The Anchors allows the use of anchors, names for pages by which they can be referred to. This allows jumping to pages using a name instead of a number, which makes references to pages more robust (the page's number can change) and readable ("index" is better than "3", no?).

If an anchor cannot be resolved, it is checked if the given value is a number, and if so, it is treated as a page number.

There is also a small set of predefined, reserved anchors which cannot be overridden:

Contents

Plugin interaction

This plugin is used by the SWFAddress plugin to resolve deep links when loaded, i.e. .../#/anchor instead of .../#/12 (anchor being the anchor name for the 13th page in the book, of course - 13th because the count starts at 0 in this case).

When loaded, this plugin registers a protocol with the Links plugin, named anchor:. It can be used in links to reference to anchors inside the book, i.e. to link to a specific page. Due to the way anchors are resolved (see above) it is also possible to use page numbers with this protocol.

Attributes

Chapter

anchor

Adding an anchor to a chapter is handled as if the anchor was added to the first page in the chapter.

Page

anchor

Adding an anchor to a page allows for easier navigation to the page by using a name instead of the page's number. This also guarantees that references to the page stay intact, even if the number of the page in the book changes.

Examples

<book plugins="links,anchors">
    <chapter>
        <page>
            <img src="data/cover.jpg"/>
            <!-- Goes to anchor "index" -->
            <area url="anchor:index" width="200" height="30"/>
            <!-- Goes to page 42 -->
            <area url="anchor:42"    width="200" height="30" top="30"/>
            <!-- Goes to last page -->
            <area url="anchor:last"  width="200" height="30" top="60"/>
        </page>
        <page anchor="index">
            <!-- Goes to anchor "chapter2" -->
            <img src="data/index.jpg" url="anchor:chapter2"/>
        </page>
        <!-- ... -->
    </chapter>
    <chapter anchor="chapter2">
        <!-- ... -->
    </chapter>
</book>
MegaZine3 Plugin-related articles
Plugins Anchors · Background Sounds · Batchpages · Bookmarks · Console · ElementIDs · Gallery · Google Analytics · Help · JavaScript · Keyboard Navigation · Links · NavigationBar · Options · Overlays · Password · PDFLinks · Print · PrintPDF · SWFAddress· Search · Sidebar · Slideshow · Titles
Plugin Articles Writing a plugin · Writing a plugin II · Plugin development
Personal tools
Namespaces
Variants
Actions
Navigation
documentation
miscellaneous
Toolbox