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 Related Topics
Suggestion for insert_cform() to return rather than echo.
Tags: ***
February 18, 2013
5:33 pm
Cas
Guest

The template tag insert_cform() is a great tool when it comes to inserting a form into a page template. However, its use is rather limited, because it echoes a result instead of just returning it—which makes it unusable within i.e. filter or action functions.

@Oliver: I guess you've heard this before, so let me just add my 2 cents to the queue. ;) You could do something like this:

### this is insert_cform() renamed and returned instead of echoed
function get_cform($no='',$custom='',$c='') {
    global $post;

   $pid = cfget_pid();

   if( !is_numeric($no) )
      $no = check_form_name( $no );

   if ( !$pid )
      return cforms($custom,$no.$c);
   else
      return check_for_taf($no,$pid)?cforms($custom,$no.$c):'';
}

### insert_cform() still echoes (ensures backward compatibility)
function insert_cform($no='',$custom='',$c='') {

   echo get_insert_cform($no,$custom,$c);

}

If I missed a function that already fulfills the same purpose, please ignore the suggestion and fill me in!

February 18, 2013
5:36 pm
Cas
Guest

Should have been get_cform in the second function, too. Please feel free to correct.

Forum Timezone: Europe/Berlin

Most Users Ever Online: 959

Currently Online:
26 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)