NAME

Interchange6::Schema::Result::Navigation

DESCRIPTION

Navigation is where all navigation, category and static page details are stored. In addition information such as page title can be linked to these records as attributes.

Attribute

Common attribute names for a Navigation records include these examples.

meta_title meta_description meta_keywords head_js head_css

SYNOPSIS

NOTE: with items such as head_css which may contain more than one record you must set the priority of the record. This ensures each record has a unique value and also allows for proper ordering.

$nav->add_attribute({name => 'head_css', priority => '1'}, '/css/main.css');
$nav->add_attribute({name => 'head_css', priority => '2'}, '/css/fancymenu.css');

ACCESSORS

Primary key.

uri

URI.

Unique constraint. Is nullable.

See "generate_uri" method for details of how "uri" can be created automatically based on the value of "name".

type

Type, e.g.: nav, category.

scope

Scope, e.g.: menu-main, top-login.

name

Name, e.g.: Hand Tools, Fly Fishing Rods.

Defaults to empty string.

description

Description, e.g.: All of our hand tools, Our collection of top fly fishing rods.

Defaults to empty string.

alias

FK on "navigation_id" in Interchange6::Schema::Result::Navigation.

Can be used for things such as menus in different languages which link back to the primary navigation menu.

Is nullable.

parent_id

Used by DBIx::Class::Tree::AdjacencyList to setup parent/child relationships.

Is nullable.

priority

Signed integer priority. We normally order descending.

Defaults to 0.

product_count

Can be used to cache product counts.

Default to 0.

created

Date and time when this record was created returned as DateTime object. Value is auto-set on insert.

last_modified

Date and time when this record was last modified returned as DateTime object. Value is auto-set on insert and update.

active

Whether navigation is active and therefore should be displayed.

Boolean defaults to true (1).

METHODS

Attribute methods are provided by the Interchange6::Schema::Base::Attribute class.

new

Override inherited method to call "generate_uri" method in case "name" has been supplied as an argument but "uri" has not.

NOTE: is uri is supplied and is undefined then "generate_uri" is not called.

active_child_count

See "with_active_child_count" in Interchange6::Schema::ResultSet::Navigation for a resultset method which will prefill this data.

active_product_count

See "with_active_product_count" in Interchange6::Schema::ResultSet::Navigation for a resultset method which will prefill this data.

generate_uri($attrs)

Called by "new" if no uri is given as an argument.

The following steps are taken:

    1. Stash $self->name in $uri to allow manipulation via filters

    2. Remove leading and trailing spaces and replace remaining spaces and / with -

    3. Search for all rows in Interchange6::Schema::Result::Setting where scope is Navigation and name is <generate_uri_filter>

    4. For each row found eval $row->value

    5. Finally set the value of column "uri" to $uri

Filters stored in Interchange6::Schema::Result::Setting are executed via eval and have access to $uri and also the navigation result held in $self

Examples of filters stored in Setting might be:

{
    scope => 'Navigation',
    name  => 'generate_uri_filter',
    value => '$uri =~ s/badstuff/goodstuff/gi',
},
{
    scope => 'Navigation',
    name  => 'generate_uri_filter',
    value => '$uri = lc($uri)',
},

siblings_with_self

Similar to the inherited siblings method but also returns the object itself in the result set/list.

INHERITED METHODS

DBIx::Class::Tree::AdjacencyList

RELATIONS

active_children

Related object: Interchange6::Schema::Result::Navigation

Conditions: self.parent_id = foreign.navigation_id && foreign.active = 1

media_navigations

Type: has_many

Related object: Interchange6::Schema::Result::MediaNavigation

Type: has_many

Related object: Interchange6::Schema::Result::NavigationProduct

products

Type: many_to_many

Accessor to related product results ordered by priority and name.

Type: has_many

Related object: Interchange6::Schema::Result::NavigationAttribute

attributes

Type: many_to_many

Accessor to related attribute results.

Type: has_many

Related object: Interchange6::Schema::Result::NavigationMessage

messages

Type: many_to_many

Accessor to related Message results.