Page 1 of 1

Calling contact from from index.tpl?

Posted: Sat Nov 18, 2006 5:38 pm
by carl_galloway
Hi all,

I need to be able to put a static link to the contact form into my index.tpl, but there is a catch. This is for a new template that will be available for download so I need a guaranteed url even if the user has apache errorhandling, or rewrite, or nothing at all.

I've tried figuring out how the static pages sidebar plugin creates a link to the contact form which is always correct but I can't seem to duplicate this using smarty {$serendipityBaseURL}{$serendipityRewritePrefix}.

Does a method exist?

Carl

Re: Calling contact from from index.tpl?

Posted: Sat Nov 18, 2006 8:31 pm
by garvinhicking
Hi!

A fallback method to access URLs on all rewriting methods is always:

index.php?/FULL_URL

so

index.php?/pages/contactform.html

would work on allinstallations!

HTH,
Garvin

Posted: Sat Nov 18, 2006 8:48 pm
by carl_galloway
Ok, I tried that and it doesn't seem to work. This is how it look in index.tpl

Code: Select all

<li><a href="index.php?/pages/contactform.html">Contact</a></li>
Am I doing something stupid?

Posted: Sat Nov 18, 2006 9:38 pm
by garvinhicking
Hi!

This should work, but it might depend on the permalink/pagetitle of the contact form. Maybe you'd need to use the index.php?serendipity[subpage]=CONTACTFORMTITLE method?

HTH,
Garvin

Posted: Sat Nov 18, 2006 10:03 pm
by carl_galloway
gee this isn't my lucky day, using the code as provided by you doesn't work, is the CONTACTFORMTITLE something that can be used to form a URL? Is there another variable instead?

Sorry about this, I just want to push the envelope with this template.

Posted: Sat Nov 18, 2006 10:40 pm
by garvinhicking
Hi!

The CONTACTFORMTITLE needs to be replaced with the title ofthe contactform page you configured in the contactform plugin, AFAIK.

Regards,
Garvin

Posted: Sun Nov 19, 2006 1:49 am
by carl_galloway
mmm, and that's a problem. I'm doing this for a template that will be freely available for all users of s9y and I need to be able to code a full-proof method of getting the contact form url without having to get the user to do anything. If I was able to find out what the user calls their contact form by doing a database lookup, or by using some outputted variable from the contact form plugin then I could use your solution, but if I can't do that then I need another solution.

Sorry to be painful, I just want to increase usability.

Posted: Sun Nov 19, 2006 2:19 am
by garvinhicking
Hi!

Aaaah! Now I understand!

Yes, there is no way to get it, since users are able to customize the URLs for their contact form(s). Since its even possible to have multiple contact forms, to which one would you want to link to?!

The only way that you can surely get it to work is to make your config.inc.php either query the database, or create an event plugin that fetches all contact form plugins and inserts links to used plugin hooks.

I'm really sorry, but this is going to be both a technical solution, and it needs some conception :)

Bestregards,
Garvin

Posted: Sun Nov 19, 2006 2:33 am
by garvinhicking
Hi!

Another thing to think of: What happens if the user has not installed the contact form plugin at all?

You could put PHP into the config.inc.php of your template to fetch the pagetitle/URL to save it into the default value of an input field where a user should enterthe URL to the contact form. Then the query would only be send qwhen configuring. Of course this means it can't be used until the user "configured" his template intially.

Regards,
Garvin