Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

LinkPreview plugin

(Page 2 of 2)
> >
Quote Reply
Re: [jgkiefer] Preview plugin In reply to
The problem is that the value for the field 'CatLinks.CategoryID' mysteriously gets replaced. To get the proper value, a global needs to be used and a new instance of GT::CGI must be started. (ie, you can't rely on $IN because the value for 'CatLinks.CategoryID' is munged when the script starts.)

here are some general instructions...

form_input
Code:
sub {
my $cgi = new GT::CGI;
my $field = shift;
return $cgi->param($field);
}

Category_Full_Name
Code:
sub {
my $id = shift;
my $cat = $DB->table("Category")->select("Full_Name", { ID => $id })->fetchrow();
return $cat;
}

in modify.cgi:

Code:
<%set cat_id = form_input('CatLinks.CategoryID')%>
<%Category_Full_Name($cat_id)%>

In include_form.html:
Code:
<%loop category_loop%>
<%if preview%>
<option value="<%escape_html ID%>"<%if ID == $cat_id%> selected="selected"<%endif%>><%'&nbsp;&nbsp;' x $CatDepth%><%Name%></option>
<%else%>
<option value="<%escape_html ID%>"<%if selected%> selected="selected"<%endif%>><%'&nbsp;&nbsp;' x $CatDepth%><%Name%></option>
<%endif%>
<%endloop%>

You need to use "form_input('field_name')" or "in.field_name" pre-fill the form input boxes. IE, do NOT use 'URL' -- use <%form_input('URL')%> or <%in.URL%>.

I'll work out some templates in a little bit.

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] Preview plugin In reply to
On the link preview I am not having a problem with categories or category drop downs displaying in V3. I do not know about displaying categories or category drop downs in the modify preview as I am unable to get the modify preview to function at all.
Quote Reply
Re: [jgkiefer] Preview plugin In reply to
The drop down list is only an issue with modify.cgi. Attached are my copies of include_form.html, add.html, and modify.html. Everything works for me, so if you add the globals from my most recent post and use my templates as a guide, than it should work for you as well.

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] Preview plugin In reply to
Wow, works great! Your solution is simple and elegant. Cool
You have made a substantial contribution as this feature has been needed for a long time.
I know how much time you have spent on this and I really appreciate it.
Thank you...

Jeff
Quote Reply
Re: [jgkiefer] Preview plugin In reply to
This is a very nice plugin but and I am not sure if Philip is still active in the forums but hopefully someone can help. I am trying to add some additional fields with dropdown menus that I am having problems working with this (in the preview mode and retain seleted values in the preview mode).

I am trying to add a state selection dropdown menu and I want it to retain selected state value in the preveiw mode and until the form is submitted. What I have in the include_form is as follows:

<div class="row required clear">
<label for="State" class="name">State:</label>
<div class="value">
<select size=
"1" id="State" name="State">
<option value=""></option>
<%if preview%>
<option value="<%escape_html State%>"<%if State == AK%> selected="selected"<%endif%>>Alaska</option>
<option value="<%escape_html State%>"<%if State == AR%> selected="selected"<%endif%>>Arkansas</option>
<option value="<%escape_html State%>"<%if State == AZ%> selected="selected"<%endif%>>Arizona</option>
<%else%>
<option value="<%if State%><%escape_html AK%><%endif%>">Alaska</option>
<option value="<%if State%><%escape_html AR%><%endif%>">Arkansas</option>
<option value="<%if State%><%escape_html AZ%><%endif%>">Arizona</option>
<%endif%>
</select>
</div>
</div>

But when I select a state and click the preview button, it just reverts to Arizona all the time. Hope someone can help. Thanks in advance!
Quote Reply
Re: [socrates] Preview plugin In reply to
You need to use 'eq' for a string comparison, not '=='.

Adrian
Quote Reply
Re: [brewt] Preview plugin In reply to
Adrian,

Thanks, After your suggestion I have tried the following and it doesn't seem to work - by the way is the rest of it correct?

<option value="<%escape_html State%>"<%if State eq AK%> selected="selected"<%endif%>>Alaska</option>

and

<option value="<%escape_html State%>"<%if State eq 'AK'%> selected="selected"<%endif%>>Alaska</option>

Any other suggestions?

Thanks!

Last edited by:

socrates: May 28, 2010, 1:35 AM
Quote Reply
Re: [socrates] Preview plugin In reply to
Have you tried testing what <%State%> holds?

Do:

Code:
FOO: <%State%>

..so you can see if its got the value in that you are expecting. The 2nd format looks like it should work fine

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
> >