Sha256: db213b4088cb655aae84813b9678fafea94814ef7d71946883fe643804e3b5b9

Contents?: true

Size: 1.5 KB

Versions: 8

Compression:

Stored size: 1.5 KB

Contents

Everything you need to access the pages stored in the database can be found on the `Documentation::Page` model.

## Finding pages

In most cases, you'll want to find a page based on its path from the root of the site, for example, `example/page/here` may be the string you want to use to find the `here` page.

```ruby
page = Documentation::Page.find_from_path('example/page/here')
```

## Useful page methods

Once you've found a page, there are a number of methods & attribute which may be useful to you.

* `title` - the page's title
* `content` - the markdown content for a page
* `compiled_content` - the HTML content for a page
* `parents` - returns an array of all the parents for the page
* `breadcrumb` - returns the items which should be included in a breadcrumb trail
* `full_permalink` - the full permalink including all parents
* `children` - all child pages for the page
* `has_children?` - whether or not the page has children
* `navigation` - appropriate navigation pages for this page

## Searching

If you wish to search pages, you should use the `Documentation::Page.search` method as shown below:

```ruby
result = Documentation::Page.search('query here', :page => 1)
```

Once you have a result object, you can use this to get information about the pages which matched the result. The following methods may be useful:

* `results` - the pages which have been found
* `excerpt_for(page)` - an excerpt to display for this page
* `empty?` - was the search empty?
* `total_pages` - the total number of pagination pages 

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
documentation-1.0.9 doc/developers-guide/building-views/accessing-pages.md
documentation-1.0.8 doc/developers-guide/building-views/accessing-pages.md
documentation-1.0.7 doc/developers-guide/building-views/accessing-pages.md
documentation-1.0.6 doc/developers-guide/building-views/accessing-pages.md
local_documentation-1.0.0 doc/developers-guide/building-views/accessing-pages.md
documentation-1.0.5 doc/developers-guide/building-views/accessing-pages.md
documentation-1.0.4 doc/developers-guide/building-views/accessing-pages.md
documentation-1.0.3 doc/developers-guide/building-views/accessing-pages.md