Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Links 3.2 add.cgi problem??

Quote Reply
Links 3.2 add.cgi problem??
Hello,

I seem to be having a problem with Links 3.2 (the most current version).

db_gen_category_list

If this setting is set to: No, the add.cgi does not put in anything in the Category input form.

Under: Setup > Build Options
db_gen_category_list Yes (AJAX) Yes (Basic) No

Here's what I got from the Build settings:
'Whether or not Gossamer Links should generate a category list when a category needs to be selected. If 'No' is selected, the user will have to view the category they wish to add the link to before clicking on 'Add a Link'. If you choose to display the category list, then you have two choices: an AJAX category selector (recommended if you have a lot of categories), or a simple select list dropdown. Note that users must have javascript enabled and have a browser that supports XMLHttpRequest before they can use the AJAX category browser.'

So after setting this to No, when I try adding a link from within a category, i.e. ... add.cgi?ID=23;d=1

It does not convert ID=23 into anything? The add form is left empty for Category field.

I tried to see the variables available in dump mode:
When 'db_gen_category_list' => '0', there is no category_loop variable
but when it's set to AJAX, or basic, there is a category_loop variable being created. (AJAX and basic work fine to create the Category field on the form)

So my question is... is this a bug? Or am I missing something?

Can someone try to change their setting to 'No' and then try adding a link from within a category? Please let me know if you get the same results.

I'm using 3.2, so it would be great if it was tried on the same version.

Thank you.
Quote Reply
Re: [mjmj] Links 3.2 add.cgi problem?? In reply to
It works on my copy. Have you made changes to the include_form.html template? Are you using the luna or older 2.x templates?

Adrian
Quote Reply
Re: [brewt] Links 3.2 add.cgi problem?? In reply to
Hi Adrian,

Yes, it's a brand new copy of Links 3.2 with the luna set.

No changes have been made to include_form.html

I think this is part of the code - bolded - (in include_form.html) that gets processed right? (when the option is set to No)

<%~if config.db_gen_category_list == 2%>
<script type="text/javascript" src="<%config.build_static_url%>/treecats.js"></script>
<%~set selected_cats = Links::Tools::category_list_selected%>
<%~loop selected_cats%>
<input type="hidden" name="CatLinks.CategoryID" value="<%escape_html ID%>" />
<%~endloop%>
<noscript>
<ul class="categories">
<%~loop selected_cats%>
<li><%Full_Name%></li>
<%~endloop%>
<%~if not selected_cats.length%>
<li><%Links::language('ADD_SELCAT')%></li>
<%~endif%>
</ul>
</noscript>
<div id="treecats"></div>
<script type="text/javascript">
var tc = new treecats({ <%-- selectionMode : 'multiple', --%> cgiURL : '<%config.db_cgi_url%>', imageURL : '<%config.build_static_url%>/<%t%>/images' });
tc.load();
</script>
<%~elsif category_loop_selected%>
<%~if category_loop.length > 1%>
<ul class="categories"><%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%>><%'&nbsp;&nbsp;' x $CatDepth%><%Name%></option>
<%~endloop%>
</select>
<%~endif%>

(the thing is there is no category_loop variable when the db_gen_category_list is set to No.
category_loop only exists when db_gen_category_list is set to AJAX or basic - when I put the GT dump on the page to see which variables are available)


Well, if I set the db_gen_category_list setting to No, this is what appears on the add.cgi page:
example: add.cgi?ID=1;d=1

(html of the form part)

<form action=http://site.com/cgi-bin/add.cgi enctype="multipart/form-data" method="post"><input type="hidden" name="d" value="1" />
<div class="row required clear">
<label for="Title" class="name">Title: <span>*</span></label>
<div class="value">
<input type="text" id="Title" name="Title" value="" class="text" />
</div>
</div>
<div class="row required clear">
<label for="URL" class="name">URL: <span>*</span></label>
<div class="value">
<input type="text" id="URL" name="URL" value="http://" class="text" />
</div>
</div>
<div class="row required clear">
<label for="CatLinks.CategoryID" class="name">Category: <span>*</span></label>
<div class="value wrappedtext">
<select id="CatLinks.CategoryID" name="CatLinks.CategoryID">
</select>
</div>
</div>
<div class="row clear">
<label for="Description" class="name">Description:</label>
<div class="value">
<textarea id="Description" name="Description" rows="3" cols="42"></textarea>
</div>
</div>
<div class="row clear">
<label for="Contact_Name" class="name">Contact Name:</label>
<div class="value">
<input type="text" id="Contact_Name" name="Contact_Name" value="Test2" class="text" />
</div>
</div>
<div class="row clear">
<label for="Contact_Email" class="name">Contact E-mail:</label>
<div class="value">
<input type="text" id="Contact_Email" name="Contact_Email" value=
username@email.com class="text" />
</div>
</div>
<div class="formsubmit">
<input type="submit" name="add" value="Add Link" class="submit" />
</div>
</form>


It seems like it's not pulling the category name or number. For AJAX and basic, it puts in the cat name and id just fine.

All I'm trying to do is not allow a user to add to certain categories. (I will add an extra field in category table which will flag whether or not a link can be added to that category, probably named something like canAdd)

I'm not sure why this is not putting the category information into the form. It works fine under AJAX and basic mode, but not the No setting.

Maybe this is not the way to do that? If maybe there's another way of not allowing users to post under certain categories but under the AJAX or basic mode, then that would be a work-around for this problem.

Thank you.
Quote Reply
Re: [mjmj] Links 3.2 add.cgi problem?? In reply to
It's actually this part of the template which should be generating the html for you:
Code:
<%~elsif category_loop_selected%>
<%~if category_loop.length > 1%>
<ul class="categories"><%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%>

Adrian
Quote Reply
Re: [brewt] Links 3.2 add.cgi problem?? In reply to
I also have this problem - I've just upgraded to 3.2. It was working perfectly before the upgrade.

Edit:
This is the code from Add.pm for displaying the form:

else {
my $category = {};
if ($CFG->{db_gen_category_list} == 1) {
require Links::Tools;
$category = Links::Tools::category_list();
$category->{Category} = sub { Links::Tools::category_list_html() };
}
print Links::SiteHTML::display('add', {
main_title_loop => Links::Build::build('title', Links::language('LINKS_ADD'), "$CFG->{db_cgi_url}/add.cgi" . (@id ? "?ID=" . join(';ID=', @id) : '')),
%$category
});
}

As far as I can see, if db_gen_category_list is not set to 1, the the $category variable is not set.

Last edited by:

afinlr: Mar 27, 2007, 11:15 AM
Quote Reply
Re: [afinlr] Links 3.2 add.cgi problem?? In reply to
It seems to work if you replace

my $category = {};

with

my $category = Links::Tools::category_list();
Quote Reply
Re: [afinlr] Links 3.2 add.cgi problem?? In reply to
The same problem exists in Modify.pm