Forum for discussing general topics related to Couch.
6 posts Page 1 of 1
Hi

I am getting the hang of couch cms now and have put it in a clients website and so far so good but am building a website up via the admin side and have done all the pages apart from the contact page which will have a form on it, how can I build the contact form up in the admin side, I pasted the form code in under source code on the text box but it don't work, it just displays the html code instead of the actual form itself

I have used index.php as a template file to build all the other pages

Is there a way regarding the contact form being built or a way around the coding in the text area box please

Thank you in advance

Kind regards

Ian
Hi Ian,

Letting the client input executable code from the back-end is never a good idea.
You should expose to the client only the things that change. The contact-form code, per se, is unlikely to change. Perhaps only the messages or the mail addresses will.

The most straightforward way of creating a contact form would be to use a separate template (say, named contact.php) for it. I suggest you use this method.

However, since you have created all pages using a single template (index.php), if you wish to create a contact form out of index.php, I suggest you create the form code as a snippet (e.g. contact.html) and then put a check in the page-view of index.php as follows -
Code: Select all
<cms:if k_page_name='contact'>
   <cms:embed 'contact.html' />
<cms:else />
   ... your existing code handling all other pages here ...
</cms:if>
The trick above would be to name the form bearing cloned-page as 'contact' - the embedded snippet will do the rest.

Hope this helps.
Hi KK

Thank you so much for the reply, appreciate it

Makes sense regarding never letting the client editing or making changes to the form

Will try the idea of making a snippet called contact.html and then put the form coding in that html file and then use the following coding and put in the index.php file

Code: Select all
<cms:if k_page_name='contact'>
   <cms:embed 'contact.html' />
<cms:else />
   ... your existing code handling all other pages here ...
</cms:if>


Thank you again, will let you know how it goes

Kind regards

Ian
Thank you again KK, worked perfect
It occurred to me that with this method a user could still mess things up by changing the name of the page, say to "contact-us." Another approach would be to add a checkbox to the template, so the contact form could be toggled on/off for any page.
Code: Select all
<cms:editable name='contact'
    label="Contact Form" desc="Check this box to add the contact form to this page"
    opt_values='Add Contact Form to Page'
    type='checkbox' />

Then you would include the form with something like this:
Code: Select all
<cms:if contact >
   <cms:embed 'contact.html' />
<cms:else />
   ... your existing code handling all other pages here ...
</cms:if >


This idea could be expanded to allow a whole set of optional features on pages: a contact form, news feed, photo gallery, donation form, different images, etc. In this way you could overcome some of the limitations of generating all pages from a single template and add a little more flexibility to pages.
Code: Select all
<cms:editable name='feature'
    label="Special Features" desc="Check a box to add the feature to this page"
    opt_values='Contact | News Feed | Gallery | Event Calendar'
    type='checkbox' />

Then you would use conditional statements to include the features anywhere you want on the outputted page.
Code: Select all
<cms:if feature='Contact' >
   <cms:embed 'contact.html' />
<cms:else />
   ... your existing code handling all other pages here ...
</cms:if >

or
Code: Select all
<cms:if feature='Gallery'>
   <cms:pages masterpage='gallery.php' />
   ... gallery code in here ...
   </<cms:pages>
</cms:if>

Just a thought.
Hi tim

Thank you for the post and advice, appreciate it

We had a re think and done it slightly different, we coded a php contact page, uploaded it to the web server and created a contact page in the admin side and redirected to the contact.php page and works perfect that way

Kind regards

Ian
6 posts Page 1 of 1