Formbuilder - 'next page' to anchor on page

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
Edwin_IandD
Forum Members
Forum Members
Posts: 80
Joined: Thu Aug 12, 2010 2:27 pm

Formbuilder - 'next page' to anchor on page

Post by Edwin_IandD »

Hello everybody,

I hope this is possible:

I am building a multiple page form in formbuilder and it all works really well except for one thing.

On the website there is a big header with a menu and a couple of stunning photos that takes up the whole of the viewport. The main content (including the form) is underneath.

Now obviously I do not want to show the whole top half of the page when somebody goes to the next page of the form, but automatically go to the top of the next page of the form.

I can't seem to find any way of doing this in the form template (where I assume I should change this). If anybody has any ideas that would be great.

Many thanks, Edwin
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Formbuilder - 'next page' to anchor on page

Post by velden »

Would a solution with ajax be an option for you (no need to reload the whole page)?

Regarding the anchor: do you use a custom form builder template or just one of the default (generic) ones?

BTW: don't know if it's possible at all to use #anchor in POST url's...
JohnnyB
Dev Team Member
Dev Team Member
Posts: 731
Joined: Tue Nov 21, 2006 5:05 pm

Re: Formbuilder - 'next page' to anchor on page

Post by JohnnyB »

I don't have a multi-page form to look at and was wondering what the URL looks like on the second page? Is there a query string in it that can be looked up or 'pretty urls'? If there is a query string, you could test for it in your Layout Template and then do an if/then statement to hide the header image when that query is found.

For example, if Formbuilder generates a URL for the second page similar to:
;http://my-webpage-form.com/index.php?formbuilder_page=2
You can use {$smarty.get.page} inside of your layout template to test if the user is on page 2.

Using the Contains Modifier plugin will make it easy to do inside your template:

Code: Select all

{if !$smarty.get.page|contains:'formbuilder_page=2'}
...<img src="my-cool-header.png">...
{/if}
So, if the URL doesn't indicate the user is viewing page 2, then show the header image....


Another approach is to set a cookie when the user goes to page 2. That can be done by using the Call to a User Defined Tag field in formbuilder after your page break field. The UDT will set a cookie, then you can test inside of your template for the cookie. You should probably destroy the cookie after the form is submitted using another UDT.

In your template, you could test:

Code: Select all

{if isset($smarty.cookies.multipageform) && $smarty.cookies.multipageform == 'TRUE'}
...<img src="my-cool-header.png">...
{/if}
The UDT called might look something like this to set the cookie:

Code: Select all

$name = 'multipageform';
$value = 'TRUE';
$expire = 0;
$path = '/';
setcookie($name, $value, $expire, $path, '', 0, 0);
to unset it, change the $expire to something like, time() - 3600 in another UDT.


*** completely untested, sorry *** Let us know if you try this and it works. ;D
Last edited by Dr.CSS on Wed Jan 22, 2014 4:37 pm, edited 1 time in total.
Reason: Please use double quotes or something on fake links so they aren't clickable...
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--
Edwin_IandD
Forum Members
Forum Members
Posts: 80
Joined: Thu Aug 12, 2010 2:27 pm

Re: Formbuilder - 'next page' to anchor on page

Post by Edwin_IandD »

Thanks a lot for the reactions.

I must admit that under the pressure of time and getting the job finished I went for the easy solution by hiding the header using CSS.

A 'back to top' button next to the form will unhide the header just in case somebody would like to use the menu on the top of the page.

Thanks anyway! Your solution might serve somebody else and I will surely keep it in mind for the next time.
Post Reply

Return to “Modules/Add-Ons”