BTW- this is off topic but... have you found an easy way to preview links before they get submitted. I am guessing that with your work on the blogging plugin you have encountered this problem and found a way around it.
Jul 15, 2005, 2:46 PM
Enthusiast (854 posts)
Jul 15, 2005, 2:46 PM
Post #2 of 33
Views: 17049
I'll look into it. That's probably going to require a hook, which I'm not really familar with doing. A quick and dirty solution would be to embed the code directly in search.cgi. something like:
use lib 'C:/Program Files/Apache Group/Apache2/cgi-bin/glinks/admin';
use Links qw/$PLG $IN/;
use Links::User::Search;
local $SIG{__DIE__} = \&Links::fatal;
Links::init('C:/Program Files/Apache Group/Apache2/cgi-bin/glinks/admin');
Links::init_user();
if ($IN->param("preview")) {
print $IN->header();
print Links::user_page ("add_preview", $IN);
}
else {
if ($PLG->dispatch('check_request', \&Links::check_request)) {
$PLG->dispatch('handle_search', \&Links::User::Search::handle);
}
}
Create a new template called 'add_preview.html'. Then add an extra submit button to add.html:
Philip
------------------
Limecat is not pleased.
Code:
use strict; use lib 'C:/Program Files/Apache Group/Apache2/cgi-bin/glinks/admin';
use Links qw/$PLG $IN/;
use Links::User::Search;
local $SIG{__DIE__} = \&Links::fatal;
Links::init('C:/Program Files/Apache Group/Apache2/cgi-bin/glinks/admin');
Links::init_user();
if ($IN->param("preview")) {
print $IN->header();
print Links::user_page ("add_preview", $IN);
}
else {
if ($PLG->dispatch('check_request', \&Links::check_request)) {
$PLG->dispatch('handle_search', \&Links::User::Search::handle);
}
}
Create a new template called 'add_preview.html'. Then add an extra submit button to add.html:
Code:
<input type="submit" name="preview=1" value="Preview">Philip
------------------
Limecat is not pleased.
Jul 15, 2005, 9:35 PM
Enthusiast (854 posts)
Jul 15, 2005, 9:35 PM
Post #6 of 33
Views: 17064
After you install the plugin, you need to do a little template work since I did not include it with the plugin.
You need to add the following line to add.html:
Then basicly make a copy of add_success.html and name it add_preview.html. add the form include if you want, so that users don't have to hit their history button to make changes.
That should be all you need to do.
Philip
------------------
Limecat is not pleased.
You need to add the following line to add.html:
Code:
<input type="SUBMIT" name="add=1&preview=1" value="Preview Link">Then basicly make a copy of add_success.html and name it add_preview.html. add the form include if you want, so that users don't have to hit their history button to make changes.
That should be all you need to do.
Philip
------------------
Limecat is not pleased.
Jul 16, 2005, 5:58 AM
User (376 posts)
Jul 16, 2005, 5:58 AM
Post #8 of 33
Views: 17085
Jul 16, 2005, 3:17 PM
Enthusiast (854 posts)
Jul 16, 2005, 3:17 PM
Post #10 of 33
Views: 17050
Attached is an updated plugin. It now will add the drop down list to the form on the preview page. Just to note: 'Category_Name' is the selected categorys' full name, whereas 'Category' is the select list. Unfortunately, if you want any error checking done on the preview page, you need to add it in yourself because the whole routine must be bypassed to keep the link from actually being added. there are probably some missing tags as a result.
And yes, you can basicly do the same for the modify routines by using the 'modify_link' hook instead of 'add_link'.
Philip
------------------
Limecat is not pleased.
And yes, you can basicly do the same for the modify routines by using the 'modify_link' hook instead of 'add_link'.
Philip
------------------
Limecat is not pleased.
Jul 16, 2005, 5:33 PM
User (376 posts)
Jul 16, 2005, 5:33 PM
Post #11 of 33
Views: 16998
I am confused about how to modify the category code from the include form to work with the preview plugin?
<div class="row<%unless category_loop_selected%> required<%endunless%> clear">
<label for="CatLinks.CategoryID" class="name">Category:<%unless category_loop_selected%> <span>*</span><%endunless%></label>
<div class="value<%if category_loop_selected%> wrappedtext<%endif%>">
<%if category_loop_selected%>
<%if category_loop.length > 1%>
<ul><%loop category_loop%><li><%Full_Name%><input type="hidden" name="CatLinks.CategoryID" value="<%escape_html ID%>" /></li><%endloop%></ul>
<%else%>
<%loop category_loop%><%Full_Name%><input type="hidden" name="CatLinks.CategoryID" value="<%escape_html ID%>" /><%endloop%>
<%endif%>
<%else%>
<select id="CatLinks.CategoryID" name="CatLinks.CategoryID">
<%loop category_loop%>
<option value="<%escape_html ID%>"<%if selected%> selected="selected"<%endif%>><%' ' x $CatDepth%><%Name%></option>
<%endloop%>
</select>
<%endif%>
</div>
</div>
Code:
<div class="row<%unless category_loop_selected%> required<%endunless%> clear">
<label for="CatLinks.CategoryID" class="name">Category:<%unless category_loop_selected%> <span>*</span><%endunless%></label>
<div class="value<%if category_loop_selected%> wrappedtext<%endif%>">
<%if category_loop_selected%>
<%if category_loop.length > 1%>
<ul><%loop category_loop%><li><%Full_Name%><input type="hidden" name="CatLinks.CategoryID" value="<%escape_html ID%>" /></li><%endloop%></ul>
<%else%>
<%loop category_loop%><%Full_Name%><input type="hidden" name="CatLinks.CategoryID" value="<%escape_html ID%>" /><%endloop%>
<%endif%>
<%else%>
<select id="CatLinks.CategoryID" name="CatLinks.CategoryID">
<%loop category_loop%>
<option value="<%escape_html ID%>"<%if selected%> selected="selected"<%endif%>><%' ' x $CatDepth%><%Name%></option>
<%endloop%>
</select>
<%endif%>
</div>
</div>
Jul 16, 2005, 6:36 PM
User (376 posts)
Jul 16, 2005, 6:36 PM
Post #13 of 33
Views: 16937
Yes I am using v3.0.4
I figured it out.
I pasted the include form on to the add_preview.html page and replaced the following category code:
<label for="CatLinks.CategoryID" class="name">Category:<%unless category_loop_selected%> <span>*</span><%endunless%></label>
<div class="value<%if category_loop_selected%> wrappedtext<%endif%>">
<%if category_loop_selected%>
<%if category_loop.length > 1%>
<ul><%loop category_loop%><li><%Full_Name%><input type="hidden" name="CatLinks.CategoryID" value="<%escape_html ID%>" /></li><%endloop%></ul>
<%else%>
<%loop category_loop%><%Full_Name%><input type="hidden" name="CatLinks.CategoryID" value="<%escape_html ID%>" /><%endloop%>
<%endif%>
<%else%>
<select id="CatLinks.CategoryID" name="CatLinks.CategoryID">
<%loop category_loop%>
<option value="<%escape_html ID%>"<%if selected%> selected="selected"<%endif%>><%' ' x $CatDepth%><%Name%></option>
<%endloop%>
</select>
<%endif%>
</div>
</div>
It gets replaced with:
<label class="name">Category: <span>*</span></label>
<div class="value wrappedtext">
<%~if Category_loop.length > 1%>
<ul><%loop Category_loop%><li><%loop_value%></li><%endloop%></ul>
<%~else%>
<%Category%>
<%~endif%>
</div>
</div>
Thank you very much Philip. This has been a plugin that has been needed for a very long time. You did it very easily and elegantly.
I figured it out.
I pasted the include form on to the add_preview.html page and replaced the following category code:
Code:
<div class="row<%unless category_loop_selected%> required<%endunless%> clear"> <label for="CatLinks.CategoryID" class="name">Category:<%unless category_loop_selected%> <span>*</span><%endunless%></label>
<div class="value<%if category_loop_selected%> wrappedtext<%endif%>">
<%if category_loop_selected%>
<%if category_loop.length > 1%>
<ul><%loop category_loop%><li><%Full_Name%><input type="hidden" name="CatLinks.CategoryID" value="<%escape_html ID%>" /></li><%endloop%></ul>
<%else%>
<%loop category_loop%><%Full_Name%><input type="hidden" name="CatLinks.CategoryID" value="<%escape_html ID%>" /><%endloop%>
<%endif%>
<%else%>
<select id="CatLinks.CategoryID" name="CatLinks.CategoryID">
<%loop category_loop%>
<option value="<%escape_html ID%>"<%if selected%> selected="selected"<%endif%>><%' ' x $CatDepth%><%Name%></option>
<%endloop%>
</select>
<%endif%>
</div>
</div>
It gets replaced with:
Code:
<div class="row required clear"> <label class="name">Category: <span>*</span></label>
<div class="value wrappedtext">
<%~if Category_loop.length > 1%>
<ul><%loop Category_loop%><li><%loop_value%></li><%endloop%></ul>
<%~else%>
<%Category%>
<%~endif%>
</div>
</div>
Thank you very much Philip. This has been a plugin that has been needed for a very long time. You did it very easily and elegantly.
Jul 17, 2005, 2:17 PM
Enthusiast (854 posts)
Jul 17, 2005, 2:17 PM
Post #15 of 33
Views: 17005
I'll look into it and see if I can expand the plugin to work with the user registration and link modification routines. I'm off from work Monday and Tuesday so I'll have time to piddle around.
If you want to give it another try, here's some general instructions:
1) uninstall the plugin
2) go to the plugin wizard, and select "LinkPreview" to edit.
3) Click past the first couple of pages until you get 'hooks' section
3) select 'modify_link', click 'use'. select 'PRE' from the other pull-down list.
4) change the bottom field to read 'Plugins::LinkPreview::pre_modify_link'.
5) click 'add hook'
6) repeat, except select 'POST', and subroutine name 'Plugins::LinkPreview::post_modify_link'
7) click through a few more screens, until you get to an option to overwrite/keep existing LinkPreview.pm. choose NOT to overwrite.
8) click through to the end of the wizard.
9) go to the plugin manager and click the edit link for LinkPreview.pm
10) create subroutines 'pre_modify_link' and 'post_modify_link' based on the existing subs.
You may need to manually grab the links data.
Philip
------------------
Limecat is not pleased.
If you want to give it another try, here's some general instructions:
1) uninstall the plugin
2) go to the plugin wizard, and select "LinkPreview" to edit.
3) Click past the first couple of pages until you get 'hooks' section
3) select 'modify_link', click 'use'. select 'PRE' from the other pull-down list.
4) change the bottom field to read 'Plugins::LinkPreview::pre_modify_link'.
5) click 'add hook'
6) repeat, except select 'POST', and subroutine name 'Plugins::LinkPreview::post_modify_link'
7) click through a few more screens, until you get to an option to overwrite/keep existing LinkPreview.pm. choose NOT to overwrite.
8) click through to the end of the wizard.
9) go to the plugin manager and click the edit link for LinkPreview.pm
10) create subroutines 'pre_modify_link' and 'post_modify_link' based on the existing subs.
You may need to manually grab the links data.
Philip
------------------
Limecat is not pleased.
Jul 17, 2005, 6:26 PM
Enthusiast (854 posts)
Jul 17, 2005, 6:26 PM
Post #17 of 33
Views: 16991
hehe... an expert I am not (yet). but I will say this: It is much easier for a complete novice to add functionality to Links SQL than it ever was in Links 2.0. In Links 2.0 you really needed to be a seasoned Perl programer to safely hack any snippet of code since there was no hook system (to overide functions) or plugin system (to automate installation of addons) or globals editor (to add smaller scale functions for templates).
Philip
------------------
Limecat is not pleased.
Philip
------------------
Limecat is not pleased.
Jul 19, 2005, 4:28 PM
Enthusiast (854 posts)
Jul 19, 2005, 4:28 PM
Post #19 of 33
Views: 16922
Dude, just realized something. No plugin is needed to actually do this. A global, however, is all you need to actually pull up the category name.
Just make sure the "preview" submit button does NOT include "add". ie:
As long as "add=" isn't true, the script will just load the form again, but it will include any submited values.
Then you can create a global to get the category name:
Category_Full_Name
my $vars = shift;
my $cat = $DB->table("Category")->select("Full_Name", { ID => $vars->{'CatLinks.CategoryID'} })->fetchrow();
return $cat;
}
use it in your template like:
Please confirm the information below:<br>
<table border=0 cellpadding=3 cellspacing=0>
<tr><td>Title:</td><td><%Title%></td></tr>
<tr><td>URL:</td><td><%URL%></td></tr>
<tr><td>Category:</td><td><%Category_Full_Name%></td></tr>
<tr><td>Description:</td><td><%Description%></td></tr>
<tr><td>Contact Name:</td><td><%Contact_Name%></td></tr>
<tr><td>Contact Email:</td><td><%Contact_Email%></td></tr>
</table>
<%endif%>
<form action="<%db_cgi_url%>/add.cgi" enctype="multipart/form-data" method="POST">
<table border="0" cellspacing="0" cellpadding="0">
<%include include_form.html%>
<tr>
<td> </td>
<td>
<input type="SUBMIT" name="add" value="Add Link">
<input type="submit" name="preview=1" value="Preview Link">
</td>
</tr>
</table>
</form>
Philip
------------------
Limecat is not pleased.
Just make sure the "preview" submit button does NOT include "add". ie:
Code:
<input type="submit" name="preview=1" value="Preview">As long as "add=" isn't true, the script will just load the form again, but it will include any submited values.
Then you can create a global to get the category name:
Category_Full_Name
Code:
sub { my $vars = shift;
my $cat = $DB->table("Category")->select("Full_Name", { ID => $vars->{'CatLinks.CategoryID'} })->fetchrow();
return $cat;
}
use it in your template like:
Code:
<%if preview%> Please confirm the information below:<br>
<table border=0 cellpadding=3 cellspacing=0>
<tr><td>Title:</td><td><%Title%></td></tr>
<tr><td>URL:</td><td><%URL%></td></tr>
<tr><td>Category:</td><td><%Category_Full_Name%></td></tr>
<tr><td>Description:</td><td><%Description%></td></tr>
<tr><td>Contact Name:</td><td><%Contact_Name%></td></tr>
<tr><td>Contact Email:</td><td><%Contact_Email%></td></tr>
</table>
<%endif%>
<form action="<%db_cgi_url%>/add.cgi" enctype="multipart/form-data" method="POST">
<table border="0" cellspacing="0" cellpadding="0">
<%include include_form.html%>
<tr>
<td> </td>
<td>
<input type="SUBMIT" name="add" value="Add Link">
<input type="submit" name="preview=1" value="Preview Link">
</td>
</tr>
</table>
</form>
Philip
------------------
Limecat is not pleased.
Jul 19, 2005, 6:51 PM
User (376 posts)
Jul 19, 2005, 6:51 PM
Post #21 of 33
Views: 16945
I'm afraid I don't follow you. Using the <input type="submit" name="preview=1" value="Preview Link"> on the modify.html page doesn't do anything. It still sends the data to the modify_success.html page without using modify_preview.html. Maybe I am doing something wrong? Could you walk me through the steps used to use the preview link plugin for the link modify pages?
Jul 19, 2005, 9:10 PM
Enthusiast (854 posts)
Jul 19, 2005, 9:10 PM
Post #22 of 33
Views: 16902
Hm... while the method I described earlier works for add.cgi, it won't work for exactly the same for modify.cgi. Regardless of whether or not the form is submitted for processing, it will replace any form input with the original values. Since you are using 3.x, You can get around that by using the hash style tags to get the value from the GT::CGI object.
For example, instead of "URL", use "IN.URL"
alternatively (or for people using 2.x) you can use a global:
form_input
my $field = shift;
return $IN->param($field);
}
which you can call as "form_input('URL')"
You also need to remove the line:
<input type="hidden" name="modify" value="1">
and change the submit button from "modify_submit" to "modify=1".
That SHOULD take care of everything except for the category field, which has me stumped. I may have to try doing the plugin again if I can't figure it out. I'm pulling my hair out on that one.
Philip
------------------
Limecat is not pleased.
For example, instead of "URL", use "IN.URL"
alternatively (or for people using 2.x) you can use a global:
form_input
Code:
sub { my $field = shift;
return $IN->param($field);
}
which you can call as "form_input('URL')"
You also need to remove the line:
<input type="hidden" name="modify" value="1">
and change the submit button from "modify_submit" to "modify=1".
That SHOULD take care of everything except for the category field, which has me stumped. I may have to try doing the plugin again if I can't figure it out. I'm pulling my hair out on that one.
Philip
------------------
Limecat is not pleased.
Jul 20, 2005, 5:52 AM
User (376 posts)
Jul 20, 2005, 5:52 AM
Post #23 of 33
Views: 17005
This seems to address the form issue (although I haven't as yet tried it) But how would I call the modify.html to display the preview in modify_preview.html since the plugin calls link_preview.html. I will try to address the category display issue once the page calls and page displays are working smoothly. This is coming together slowly but surely.
Jul 21, 2005, 12:34 AM
Enthusiast (854 posts)
Jul 21, 2005, 12:34 AM
Post #24 of 33
Views: 16932
I believe I have figured out how to get this to work 100% without the use of the plugin I posted. It involves using a few globals and an array of set tags, and changing the include_form.html template a bit. Right now, I've got to get me some sleep -- need to be at work in the morning.
When I get back from work at 5 pm I'll test out my theory for the category menu and post the results.
(the preview system otherwise works fine. you just aren't understanding what needs to be done. I will post full instructions and example templates later.)
Philip
------------------
Limecat is not pleased.
When I get back from work at 5 pm I'll test out my theory for the category menu and post the results.
(the preview system otherwise works fine. you just aren't understanding what needs to be done. I will post full instructions and example templates later.)
Philip
------------------
Limecat is not pleased.