Krang::ElementClass::TopLevel - base class for top-level element classes
package ElementSet::article; use Krang::ClassLoader base => 'ElementClass::TopLevel';
# override new() to setup element class parameters
sub new {
my $pkg = shift;
my %arg = (name => "article",
children => [ 'deck', 'paragraph', 'image' ],
@_);
return $pkg->SUPER::new(%arg);
}
1;
This class serves as the base class for top-level element classes.
The root of an element tree must start with a sub-class of this class.
The methods provided allow this special element to control some
aspects of the Story or Category which contains it. For example, the
build_url method allows element classes to determine how a story
builds its URL.
Additionally, some methods make no sense for a top-level element
class, and they are stubbed out with implementations that croak. For
example, the input_form() method is useless for a top-level element
because the UI does not allow top-level elements to recieve input.
$url = $class->build_url(story => $story, category => $category)$url = $class->build_preview_url(story => $story, category => $category)@fields = $class->url_attributes()slug_use() is set to 'prohibit'.
@schedules = $class->default_schedules(element => $element, story_id ==> $story_id)$file_name = $class->filename()index unless overridden.
$file_extension = $class->extension()filename()) to be used when writing to disk data generated by this element tree. Will return .html unless overridden.
$class->versions_to_keep$class->save_hook(element => $element)$class->delete_hook(element => $element)$class->trash_hook(element => $element)$class->untrash_hook(element => $element)$class->retire_hook(element => $element)$class->unretire_hook(element => $element)$bool = $class->publish_check(element => $element)The default implementation just returns 1 (true) in all cases.
$bool = $class->force_republish(element => $element)The default implementation returns 0 (false) in all cases.
$bool = $class->use_category_templates(element => $element)The default implementation returns 1 (true) in all cases.
$bool = $class->publish_category_per_page(element => $element)If false, the category element will be published once, and its output will be matched up with each story page.
The default implementation returns 0 (false) in all cases.
Override this method to return 1 (true) if you want to generate content on category templates varies for each page in a story.
$category_input = $class->category_input()It returns 1 of 3 values: 'require' - user must specify category 'allow' - user may specify category 'prohibit' - user may not specify category
The default implementation returns 'require'.
=cut
sub category_input { return 'require'; }
@category_ids = $class->auto_category_ids(cover_date => $cover_date,
slug => $slug,
title => $title);$validate = $class->validate_category(category => $category,
cover_date => $cover_date,
slug => $slug,
title => $title);The default implementation returns 1 in all cases.
$slug_use = $class->slug_use()It returns 1 of 4 values: 'require' - slug is required 'encourage' - slug field is present in New Story CGI, but can be left empty 'discourage' - slug field is initially greyed-out in New Story CGI 'prohibit' - slug is prohibited
The default implementation returns 'encourage'.
=cut
sub slug_use { return 'encourage'; }
$title_to_slug = $class->title_to_slug()$bool = $class->hidden()Krang::Story>->hidden(). If
true, stories of this class will not return in a call to <
Krang::Story-find() >> unless the parameter show_hidden => 1
is set.
As an example: this is useful for story classes that aren't supposed to show up in most-recently-published lists. For example, the Krang RSS and HREF[Krang Sitemap|href://krang.sourceforge.net] addons republish nightly by default - neither of these story classes should show up in a cover displaying the most-recently-published stories.
This method is false by default.
$file_mode = $class->file_mode($filename)publish_frontend_app_template()
$self->publish_frontend_app_template(
publisher => $publisher,
fill_with_element => $element,
filename => "search_results.tmpl",
use_category => 1,
tmpl_data => {Foo => 123, Bar => 456},
);
This method is used to publish a template to the front-end of a website for
use by a front-end CGI. It is expected to be called from within the
fill_template() or publish() methods. This method takes the following
parameters:
filename.
fill_template() process.
NOTE: Template vars, loops (etc.) which are needed by your front-end CGI should be named ``<dyn_*>'' instead of ``<tmpl_*>'', e.g.:
<dyn_if some_boolean>
<dyn_loop some_loop>
<dyn_var foo1>
<dyn_var foo2>
<dyn_var foo3>
</dyn_loop>
</dyn_if>
This is to differentiate the template tags needed by the CGI from those needed by the Krang publishing process.
publish_frontend_app_stub()
$self->publish_frontend_app_stub(
publisher => $publisher,
filename => "myapp.pl",
app_module => 'Foo::Bar::Baz',
app_params => {Foo => 123, Bar => 456},
);
Publish a CGI ``instance script'' which will invoke a CGI::Application-based module. This method takes the following parameters:
param() method. (See the CGI::Application documentation.)
publish() method.
Defaults to false;