cforms II User Forum

Registration is currently disabled.
Guest

FAQs

Login form protected by Login LockDown.


Lost password?
Advanced Search

— Forum Scope —

  

— Match —

   

— Forum Options —

    

Wildcard usage:
*  matches any number of characters    %  matches exactly one character

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS
Re: Multiple forms on one or many pages / posts
September 9, 2007
4:06 am
tripp
Guest

Upgraded to 5.4 because I realized that my front page was not sending emails -- I list several posts on the front page, with an email form for each entry (because most entries are by different authors).  5.4 says it fixed this issue, but I am still getting errors and non-submitted forms.

Is there an easy fix to having multiple copies of the same form on the same page?

September 14, 2007
8:47 am
tripp
Guest

I should add that I am using the same form on the page:  It is mailed to whomever wrote the post as an alternative to leaving a comment.  It is erroring because the forms use the same "id"s, instead of naming them uniquely (such as appending with a number).

September 23, 2007
1:57 pm
Oliver
Munich, Germany
Admin
Forum Posts: 6400
Member Since:
March 6, 2005
Offline

tripp said:

I should add that I am using the same form on the page:  It is mailed to whomever wrote the post as an alternative to leaving a comment.  It is erroring because the forms use the same "id"s, instead of naming them uniquely (such as appending with a number).


You can use multiple different forms per page, but not the same form in multiple posts per page.

My recommendation is to only include the form (then it can be the same form) in the single or page view.

 

September 25, 2007
5:42 pm
tripp
Guest

That's what I have resorted to doing.  Would it be possible in future versions to
use names instead of ids for the forms and write out a unique identifier as part of the name?  Then you could have multiples of the same form on the same page.

Basically, I want an email form option on my blog along with the comment form.  A little DHTML and you can can flip back and forth between the two.   Each form emails to the post author (multi-author blog).  The plugin works great for all of this, except for the front page, where there are multiple posts.

September 25, 2007
9:21 pm
Oliver
Munich, Germany
Admin
Forum Posts: 6400
Member Since:
March 6, 2005
Offline

ID's for forms are required for several reasons, e.g. javascript references.

On top, some logic would need to be implemented to detect the same form being used more than once on a page and adding a "counter". Or alternatively enhance the PHP function call used to paint the form to include the "counter" and add some code to the main cforms function to create each form with a unique ID…not exactly a straight forward thing to do. But then again it's only software anything is possible :-) 

Further, I'm not sure how performance will suffer when having lots of posts on your index page. 

September 26, 2007
2:44 am
Dennis
Guest

Oliver said:

ID’s for forms are required for several reasons, e.g. javascript references.

On top, some logic would need to be implemented to detect the same form being used more than once on a page and adding a "counter". Or alternatively enhance the PHP function call used to paint the form to include the "counter" and add some code to the main cforms function to create each form with a unique ID…not exactly a straight forward thing to do. But then again it’s only software anything is possible :-) 

Further, I’m not sure how performance will suffer when having lots of posts on your index page. 


I don't know anything about Ajax (other than I like it.)  Couldn't you use Ajax to call the form on the index page, so you wouldn't have to load multiple forms.  I guess if someone really knew what they where doing, they could also make one close when the other opens.  

I use java to show/hide the tell-a-friend feature on singal posts and pages, but because it only hides the form it doesn't work on the index page (other than the first post).  For that page I use the 2nd deployment option as described in the help pages.

Don't get me wrong this is a great (if the the greatest) plugin.  If someone gives me a Ferrari I'm not going to complain it didn't come with a full tank of gas. Laughing

September 26, 2007
7:11 am
Dennis
Guest

I would have no idea how to program this but; if you added the post/page ID to the form ID#, so it would know the form/style but could differ the post ID.. could that work?

Something like this:

<!–cforms5<?php the_ID(); ?>–>

Not sure if that is a good example of what I'm talking about.Undecided

PS

I just tried posting some java code (I use on my site) and it messed up your entire page (even after marking it "code"). I hope I didn't break anything.Surprised

Thank God for edits.Embarassed

September 26, 2007
7:59 am
Oliver
Munich, Germany
Admin
Forum Posts: 6400
Member Since:
March 6, 2005
Offline

Dennis said:

I would have no idea how to program this but; if you added the post/page ID to the form ID#, so it would know the form/style but could differ the post ID.. could that work?

Something like this:

–>

–>


Dennis, unfortunately it's not that easy. Here is essentially, in a more detailed way, what needs to be done:

cforms would need to be adjusted to understand a dynamic & unique counter for a given form.

  • insert_custom_cform($fields='',$no='')
    would need to become
    insert_custom_cform($fields='',$no='',$dynID='')
  • function cforms($args = '',$no = '') {…
    would have to be
    function cforms($args = '',$no = '',$dynID='') {…
  • the tag ID needs to be set to
    id="cforms'.$no.'form'.$dynID.'"
  • Now in your index template, after the post content you will have to change your insert_custom_cform($fields='',$no='') PHP code to include this counter, e.g.

    insert_custom_cform($fields,'',$dynID);

    wich addresses your default form (hence the '') and passes on the variable $dynID, which in turn needs to be set to 0 before The LOOP and incremented after the cforms call ($dynID++;)

    The above is just off the top of my head – there may the one or other thing missing…but a start (does not respect javascript/ajax)!

September 26, 2007
1:35 pm
Dennis
Guest

Yes, you are much warmer than my "description."Laughing

I knew it looked foolish but it was the best way I could describe what I was talking about.

I followed your instructions and it gave me a "submit" button under each post but no form. When I click on it I get a success message under all the posts. So I guess it's missing a few things, but getting closer. Smile

PS

The rest of the forms in my contact section work fine. 

 

September 26, 2007
9:19 pm
Oliver
Munich, Germany
Admin
Forum Posts: 6400
Member Since:
March 6, 2005
Offline

Sorry, missed to say (there is probably more…) that you of course need to fill in the $fields array first. See the examples in the HELP section, you essentially need to recreate all fields that you have configured via the admin UI.

Also, since javascript is not "adjusted, you may want to turn off Ajax for this form (via the admin UI).

 

**edit:

and you want to change this line:

$action = $_SERVER['REQUEST_URI'] . '#usermessage'. $no . $actiontarget;

to

$action = $_SERVER['REQUEST_URI'] . '#usermessage'. $no . $dynID . $actiontarget;

AND this line

$content .= $nl . $indent . $tab . '<p id="usermessage'.$no.'a" class="info ' . $usermessage_class . '" >' . $usermessage_text . '</p>' . $nl;

to

$content .= $nl . $indent . $tab . '<p id="usermessage'.$no. $dynID .'a" class="info ' . $usermessage_class . '" >' . $usermessage_text . '</p>' . $nl;
 

AND finally

$content .= $indent . $tab . '<p id="usermessage'.$no.'b" class="info ' . $usermessage_class . '" >' . $usermessage_text . '</p>' . $nl;

to 

$content .= $indent . $tab . '<p id="usermessage'.$no.$dynID.'b" class="info ' . $usermessage_class . '" >' . $usermessage_text . '</p>' . $nl; 

 

September 29, 2007
4:41 am
Dennis
Guest

Forgot the $fields array the first time.Embarassed

 

But it is still submiting all forms with the changes above.

 

PS

Will this work with Tell-a-Friend? 

September 29, 2007
8:31 am
Oliver
Munich, Germany
Admin
Forum Posts: 6400
Member Since:
March 6, 2005
Offline

Unfortunately, with T-A-F the same limitation applies. Have you turned off Ajax?

Can you remind me of the URL so I can take a quick look? 

September 30, 2007
4:21 am
Dennis
Guest

Unfortunately the site is not complete yet, and it is in a subdirectory only assessable by the admin.

Ajax is off.

I think I may be doing something wrong with this part:

 "
wich addresses your default form (hence the ”) and passes on the variable $dynID, which in turn needs to be set to 0 before The LOOP and incremented after the cforms call ($dynID++;);"

Is there something I need to do before the loop?

 

Thanks 

September 30, 2007
9:32 am
Oliver
Munich, Germany
Admin
Forum Posts: 6400
Member Since:
March 6, 2005
Offline

I think the structure should be:

$dynID=0;

LOOP START

POST CONTENT

$fields = …. 

insert_custom_cform($fields,”,$dynID);

$dynID++; 

LOOP END

Forum Timezone: Europe/Berlin

Most Users Ever Online: 959

Currently Online:
34 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

tracedef: 43

mores: 21

Gyrus: 20

frozenwaste: 18

asuffredini: 15

photoworks: 14

Member Stats:

Guest Posters: 3739

Members: 1463

Moderators: 3

Admins: 2

Forum Stats:

Groups: 1

Forums: 4

Topics: 5339

Posts: 18706

Newest Members: juredujmovic, dreamkeeper, rajattyagi, wrokaa, lukass

Moderators: Paul (421), cnymike (8), sonika (95)

Administrators: Oliver (6400), Nicky (3)