Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Separate add.cgi page

Quote Reply
Separate add.cgi page
I want to create another submission page with different fields on it. I created a new template, "trade.html", a new submit page, trade.cgi. and a new template include, include_trade_form. The trade.cgi page is still using the add.html template.

How do I tell trade.cgi to use trade.html as the template for that page?

Thanks.
Quote Reply
Re: [Spacemanspiff] Separate add.cgi page In reply to
Hi,

If you still use the code of the add.cgi, the add.html is always displayed. You have to put on the new code or make some hooks into glinks.

Hope that helps

Cheers,

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] Separate add.cgi page In reply to
Hi Tandat,

Thanks for the response.

I am using the add.cgi code on the trade.cgi page. I just don't know what to change or add to get the trade.html template to load instead of the add.html template.

I assume this line in add.cgi

Code:
$PLG->dispatch('handle_add', \&Links::User::Add::handle);

says to use add.pm to handle generating and processing the form. I looked all over that page and couldn't find anything that said to use add.html as the template. As you can probably guess I'm not very proficient with coding so unless it jumps out at me I probably won't see it.

Also, what is a hook. I see that mentioned a lot but don't know what it is.

Thanks again.
Quote Reply
Re: [Spacemanspiff] Separate add.cgi page In reply to
Hi,

Yes, that is the case. The Links/User/Add::handle will call the add.html template at some lines "print Links::SiteHTML::display('add'..."

There are two options for this case.

1) Copy the Add.pm as Trade.pm and change the lines "print Links::SiteHTML::display('add'..." into "print Links::SiteHTML::display('trade'..." and the line in the trade.cgi into $PLG->dispatch('handle_add', \&Links::Trade::Add::handle);

Or

2)Create a small plugin and add a hook 'site_html_add' and check if user are from trade.cgi, then call the template trade.html.

Hope that helps,

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [Spacemanspiff] Separate add.cgi page In reply to
Hi,

I tend to use a bit of a different approach (it depends really if you are asking for payments or not).

1) In add.html, change:

Code:
<%include include_form.html%>

...to:

Code:
<%if trade%>
<%include include_form_trade.html%>
<%else%>
<%include include_form.html%>
<%endif%>

2) Then, make a copy of include_form.html, but save as include_form_trade.html, and then make the changes to the fields you don't want them to use.

3) Then, its a simple case of just calling add.cgi?trade=1;ID=xxx (or add.cgi?trade=1 on its own) for the Trade Add Form , or or add.cgi (or add.cgi?ID=xxx) for the normal add form.

Hope that helps.

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!
Quote Reply
Re: [Spacemanspiff] Separate add.cgi page In reply to
OK, here's what I came up with.

I thought something along the lines of what Tendat suggested (creating a User::trade page) would work but I didn't know what all had to be changed on the page and in other places. That's why I started this post. I tried that method and got an error.

Code:
Undefined subroutine &Links::User::Trade::handle called at
/home/mryum/public_html/cgi-bin/links/admin/GT/Plugins.pm line 133.

Now although I understood what Andy was suggesting (I'd actually already made the trade include form) it looked
too easy, but it worked like a charm.

I don't have two separate pages, but that's fine as I can load a different template depending on whether the submission
is a trade or just a request for a directory listing, which is exactly what I wanted.

As usual, thanks for all the help.
Dean
Quote Reply
Re: [Spacemanspiff] Separate add.cgi page In reply to
Spacemanspiff wrote:
Now although I understood what Andy was suggesting (I'd actually already made the trade include form) it looked
too easy, but it worked like a charm.

I don't have two separate pages, but that's fine as I can load a different template depending on whether the submission
is a trade or just a request for a directory listing, which is exactly what I wanted.

I guess it worked ok for you then? :)

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!