Whenever i need a new page i do the following: In nph_build i add some new lines to build cool pages
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
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. :)
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. :)