Skip to content

Commit

Permalink
Allow content to be passed inside [content] tag to be used as default.
Browse files Browse the repository at this point in the history
  • Loading branch information
racke committed Sep 20, 2013
1 parent 00ae9fc commit e5a68c4
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions plugins/content/code/content.tag
Expand Up @@ -9,20 +9,25 @@ sub {

$Tag->perl({tables => 'content'});

if ($function eq 'add') {
my %content;
my $add_sub = sub {
my $add_body = shift;
my %content;

# created timestamp
$content{type} = $opt->{type} || 'page';
$content{title} = $opt->{title};
$content{body} = $opt->{body};
$content{title} = $opt->{title} || '';
$content{body} = $add_body || $opt->{body};
$content{uid} = $opt->{uid} || $Session->{username};
$content{uri} = $opt->{uri};
$content{created} = $opt->{created} || $Tag->time({format => '%s'});

$code = $Db{content}->set_slice([{dml => 'insert'}], \%content);

return $code;
};

if ($function eq 'add') {
$add_sub->();
}

if ($opt->{uri}) {
Expand Down Expand Up @@ -68,6 +73,7 @@ sub {
}

$content{body} = $ctref->{body};
$body = '';
}
else {
if ($opt->{create_link}) {
Expand All @@ -94,6 +100,10 @@ sub {
$content{$_} = $opt->{params}->{$_};
}
}
elsif ($opt->{uri} && ! $ctref) {
# push content to database
$add_sub->($body);
}

return $Tag->uc_attr_list({hash => \%content, body => $body});
}
Expand Down

0 comments on commit e5a68c4

Please sign in to comment.