Having InfoPath forms in SharePoint is great, but sometimes customers complain about how to open the form.
Most likely users have to navigate in a given site to the InfoPath form library, and there click "New" in order to start-up a new form. This little piece of code makes it a lot easier by putting a link on a page.
So, what you need to do is to add a "Content Editor" webpart on the page you want to have the link displayed. Open the source editor and paste/change following snippet:
I guess you can all see what to replace in your snippet
. Might also be better to have a relative link instead of an abolute one, I just copied some code from the rendered HTML source of the given InfoPath form library AllItems.aspx page.
<script language="JavaScript">
function NewAbsenceRequest()
{
createNewDocumentWithRedirect('http:\u002f\u002flocalhost:8040\u002fhr\u002fAbsenceRequests\u002fForms\u002ftemplate.xsn', 'http:\u002f\u002flocalhost:8040\u002fhr\u002fAbsenceRequests', 'SharePoint.OpenXmlDocuments.2', true, 'http://localhost:8040/hr/_layouts/FormServer.aspx?XsnLocation=http://localhost:8040/hr/AbsenceRequests/Forms/template.xsn', 0)
}
</script>
<a href="BLOCKED SCRIPT NewAbsenceRequest();">New Absence Request<a>
!!! Replace the "BLOCKED SCRIPT" by "JavaScript" and a ":", this is replaced by Community Server.
Have fun!