##
---- file 2 ----
package ORI::Schema::Result::Contenttype;
extends 'DBIx::Class::Core';
__PACKAGE__->table("contenttypes");
__PACKAGE__->add_columns(
"id" => { data_type => "integer" },
"text" => { data_type => "text" },
);
__PACKAGE__->set_primary_key("id");
_PACKAGE__->has_many(
"contentlinks" => "ORI::Schema::Result::Contentlink",
{ "foreign.content_id" => "self.id" },
);
__PACKAGE__->many_to_many("repos", "contentlinks", "repo");
####
---- file 3 ----
package ORI::Schema::Result::Contentlink;
extends 'DBIx::Class::Core';
_PACKAGE__->table("contentlinks");
__PACKAGE__->add_columns(
"content_id" => { data_type => "integer" },
"repo_id" => { data_type => "integer" },
);
__PACKAGE__->set_primary_key("content_id", "repo_id");
__PACKAGE__->belongs_to(
"content" => "ORI::Schema::Result::Contenttype",
{ id => "content_id" },
);
__PACKAGE__->belongs_to(
"repo" => "ORI::Schema::Result::Repo",
{ id => "repo_id" },
);
####
---- within controller ----
# Get the first 10 results (getting all crashes the system! )
$c->stash( repos => [ $c->model('ORIdatabase::Repo')->search(
{}
{
rows => '10'
}
)
] );
---- In Template ----
[% FOREACH repo IN repos -%]
[% repo.oaibaseurl %]
[% repo.system_url %]
[% repo.lat %]
[% repo.long %]
[% repo.opstatus %]
[% repo.fulltext %]
[% repo.mandate %]
[% END -%]
####
---- within controller ----
# Get the first 10 results (getting all crashes the system! )
# Add in a join to get all the contents (ManyToMany relationship)
$c->stash( repos => [ $c->model('ORIdatabase::Repo')->search(
{}
{
join => 'contents',
prefetch => 'contents',
rows => '10'
}
)
] );
---- In Template ----
[% FOREACH repo IN repos -%]
[% repo.oaibaseurl %]
[% repo.system_url %]
[% repo.lat %]
[% repo.long %]
[% repo.opstatus %]
[% repo.fulltext %]
[% repo.mandate %]
[% repo.mandate %]
[% # How to I get the list of content types? -%]
[% END -%]