How do I use a form in a plugin's pre_install sub?
According to docs...
I am trying to create a plugin install option that is the directory in which to install template.html files.
I am slowly making progress on the form, and having some difficulties as
the pre_install function does not allow me to use tags like I can in templates.
Furthermore, I don't understand how I then retrieve the form data once in the install sub.
Also, I do not know how to walk the hashref returned from Links::Tools::tpl_dir_select();
I am trying to create a dropdown menu of installed template sets.
This is the code I am working on. If anyone could shed some light this,
I would be greatful. I need to be able to use a while loop to index through
$template_set_loop, but I don't have <%loop template_set_loop%>.
Obviously I am confused.
# -----------------------------------------------------------------------------
# This function displays an HTML formatted message that will display any
# instructions/information to the user before they install the plugin.
#
my $Config = GT::Config->load("$CFG->{admin_root_path}/Links/Config/Data.pm");
my $theme = $Config->{'build_default_tpl'};
my $directory = 'luna';
# Links::Config::load_vars;
my $template_set_loop = Links::Tools::tpl_dir_select($theme, 'browser', '', 0);
my $popup = "<select name='templates'>";
#while ($template_set_loop) {
$popup.= "<option value=".$directory;
if($directory == $theme) {$popup .= " selected='selected'"; }
$popup .= ">".$directory."</option>";
#}
$popup.= "</select>";
my $inst_msg = qq~
$popup
<p>Choose a template set for this plugin's templates.<br>
If you install to the luna template set, the templates will be available to any set that inherits from luna.</p>
<form method="post" action="dummy_value">
<%Links::Tools::tpl_dir_select('luna, 'browser')%>
<select name='dburl'>
<%loop template_set_loop%>
<option value="<%directory%>"<%if $directory eq $theme%> selected="selected"<%endif%>><%directory%></option>
<%endloop%>
</select>
</form>
~;
return $inst_msg;
}This is basically scrap code, but it is all I have been able to muster up concidering the lack of <%foo%> tags.
The above <form> code doesn't really work at all, but it is what i had working in a template.
Thank you,
Chris
RGB World, Inc. - Software & Web Development.
rgbworld.com
According to docs...
Quote:
The pre install function displays a message to the user before the plugin is installed. It should return a string containing HTML that will be displayed. You can output an HTML form with form fields asking the user any information you will need in the actual install.I am trying to create a plugin install option that is the directory in which to install template.html files.
I am slowly making progress on the form, and having some difficulties as
the pre_install function does not allow me to use tags like I can in templates.
Furthermore, I don't understand how I then retrieve the form data once in the install sub.
Also, I do not know how to walk the hashref returned from Links::Tools::tpl_dir_select();
I am trying to create a dropdown menu of installed template sets.
This is the code I am working on. If anyone could shed some light this,
I would be greatful. I need to be able to use a while loop to index through
$template_set_loop, but I don't have <%loop template_set_loop%>.
Obviously I am confused.
Code:
sub pre_install { # -----------------------------------------------------------------------------
# This function displays an HTML formatted message that will display any
# instructions/information to the user before they install the plugin.
#
my $Config = GT::Config->load("$CFG->{admin_root_path}/Links/Config/Data.pm");
my $theme = $Config->{'build_default_tpl'};
my $directory = 'luna';
# Links::Config::load_vars;
my $template_set_loop = Links::Tools::tpl_dir_select($theme, 'browser', '', 0);
my $popup = "<select name='templates'>";
#while ($template_set_loop) {
$popup.= "<option value=".$directory;
if($directory == $theme) {$popup .= " selected='selected'"; }
$popup .= ">".$directory."</option>";
#}
$popup.= "</select>";
my $inst_msg = qq~
$popup
<p>Choose a template set for this plugin's templates.<br>
If you install to the luna template set, the templates will be available to any set that inherits from luna.</p>
<form method="post" action="dummy_value">
<%Links::Tools::tpl_dir_select('luna, 'browser')%>
<select name='dburl'>
<%loop template_set_loop%>
<option value="<%directory%>"<%if $directory eq $theme%> selected="selected"<%endif%>><%directory%></option>
<%endloop%>
</select>
</form>
~;
return $inst_msg;
}
The above <form> code doesn't really work at all, but it is what i had working in a template.
Thank you,
Chris
RGB World, Inc. - Software & Web Development.
rgbworld.com