Gossamer Forum
Quote Reply
New pages
Whenever i need a new page i do the following: In nph_build i add some new lines to build cool pages

Code:
my $page = $CFG->{build_xyz_path} . "/" . "index.php";
my $url = $CFG->{build_xyz_url} . "/" . "index.php";

print $USE_HTML
? qq|Building <a href="$url" target="_blank">XYZ</a>...\n|
: qq|Building XYZ...\n|;

my $fh = _open_write($page);
print $fh Links::Build::build(xyz => {eng=>0});
close $fh;
my $perms = oct $CFG->{build_file_per};
chmod $perms, $page;

Here you can see eng=>0, because i buidl everything twice times for german/english.

Then i add a some new lines to build.pm

Code:
$COMPILE{build_xyz} = __LINE__ . <<'END_OF_SUB';
sub build_xyz{
# ------------------------------------------------------------------
# Generate the xyz page. Takes as options:
#
# Pass eng => 0/1

my $opts = shift;

if (ref $opts ne 'HASH') {
Links::debug("Invalid option passed to build_new: $opts") if $Links::DEBUG;
return;
}

if (! exists $opts->{eng}) {
$opts->{eng} = '0';
}

if ($opts->{eng} eq '0') {
return Links::SiteHTML::display('xyz', { });

} else {
return Links::SiteHTML::display('xyz2', { });

}
}
END_OF_SUB

Finally i said to myself, why the hell you do it again and again?

It should be enough to pass some vars, right?

nph-build:

print $fh Links::Build::build(xyz => {eng=>0, tpl => "name"});

build.pm

my $template = $opts->{tpl};

and

return Links::SiteHTML::display($template, { });



I have not tested now, but it should run. How much i love this old lady. :)
Subject Author Views Date
Thread New pages Robert 7709 Mar 14, 2017, 1:40 PM
Thread Re: [Robert] New pages
Andy 7506 Mar 15, 2017, 12:05 AM
Thread Re: [Andy] New pages
Robert 7456 Mar 15, 2017, 9:31 AM
Thread Re: [Robert] New pages
Robert 7313 Mar 17, 2017, 1:00 PM
Thread Re: [Robert] New pages
Andy 7271 Mar 17, 2017, 11:48 PM
Thread Re: [Andy] New pages
Robert 7221 Mar 18, 2017, 6:54 AM
Post Re: [Robert] New pages
Andy 7204 Mar 18, 2017, 7:03 AM