|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
Idea for comments.phpSome people (may) like to add some JavaScript pre-checking (e.g. useful for
AJAX) to their plugins (contact forms, wherever the "blog reader" has to interact with the blog). Currently you have to "hack" comments.php a little but what about a filter-based solution? So plugin coders can very easy add their JavaScript to a onsubmit and onreset "stub". I you don't know what I mean please let me know it. :-) Roland -- (GNU) PGP ID: 0x8C8859B9 Weblog: http://blog.mxchange.org _______________________________________________ wp-hackers mailing list wp-hackers@... http://lists.automattic.com/mailman/listinfo/wp-hackers |
|
|
Re: Idea for comments.phpOn 10/2/06, Roland Haeder <webmaster@...> wrote:
> Some people (may) like to add some JavaScript pre-checking (e.g. useful for > AJAX) to their plugins (contact forms, wherever the "blog reader" has to > interact with the blog). > > Currently you have to "hack" comments.php a little but what about a > filter-based solution? So plugin coders can very easy add their JavaScript to > a onsubmit and onreset "stub". Why not put the JavaScript in the header, via the wp_head action hook? _______________________________________________ wp-hackers mailing list wp-hackers@... http://lists.automattic.com/mailman/listinfo/wp-hackers |
|
|
Re: Idea for comments.phpOn Tuesday, 3. October 2006 00:52, Austin Matzko wrote:
> On 10/2/06, Roland Haeder <webmaster@...> wrote: > > Some people (may) like to add some JavaScript pre-checking (e.g. useful > > for AJAX) to their plugins (contact forms, wherever the "blog reader" has > > to interact with the blog). > > > > Currently you have to "hack" comments.php a little but what about a > > filter-based solution? So plugin coders can very easy add their > > JavaScript to a onsubmit and onreset "stub". > > Why not put the JavaScript in the header, via the wp_head action hook? <!-- Somewhere in the a-tag: //--> onSubmit="return submitHook();" onReset="return resetHook();" Now we "just" need to add something like this inside of the <form></form> comtainer and everyone is happy: <?php wp_javascript(); ?> Inside wp_javascript() we must check if the user wants to submit a comment or something else. Just an idea. :-) -- (GNU) PGP ID: 0x8C8859B9 Weblog: http://blog.mxchange.org _______________________________________________ wp-hackers mailing list wp-hackers@... http://lists.automattic.com/mailman/listinfo/wp-hackers |
|
|
Re: Idea for comments.phpRoland Haeder wrote:
>> Why not put the JavaScript in the header, via the wp_head action hook? > The reason for this is that some want to pre-check via this code: > > <!-- Somewhere in the a-tag: //--> > onSubmit="return submitHook();" onReset="return resetHook();" Include a reference to prototype or a prototype-like library in wp_head, and add an event observer: Event.observe(window, 'load', function(e) { $('commentform').appendChild(Builder.node("input", { type: "hidden", name: "myfield", value: 'foo'}); // Or whatever }); > Now we "just" need to add something like this inside of the <form></form> > comtainer and everyone is happy: > > <?php wp_javascript(); ?> Dumping javascript into the page to run as it's downloaded might not be the best idea, especially since I've provided an example of how to do it well, but here you go: add_action('comment_form', 'my_php_function', 1); function my_php_function($postid) { echo "Post ID: {$postid}"; } This hook is already in the default theme's template code. See comments.php. Owen _______________________________________________ wp-hackers mailing list wp-hackers@... http://lists.automattic.com/mailman/listinfo/wp-hackers |
|
|
Re: Idea for comments.phpOn Tuesday, 3. October 2006 01:15, Owen Winkler wrote:
> Dumping javascript into the page to run as it's downloaded might not be > the best idea, especially since I've provided an example of how to do it > well, but here you go: > > > add_action('comment_form', 'my_php_function', 1); > > function my_php_function($postid) { > echo "Post ID: {$postid}"; > } > > > This hook is already in the default theme's template code. See > comments.php. <form <?php do_action('comment_form_tag', $post->ID); ?> action=".......> So everyone can choose to add onSubmit and/or onReset to it or not. :-) Roland -- (GNU) PGP ID: 0x8C8859B9 Weblog: http://blog.mxchange.org _______________________________________________ wp-hackers mailing list wp-hackers@... http://lists.automattic.com/mailman/listinfo/wp-hackers |
|
|
Re: Idea for comments.phpRoland Haeder wrote:
> I mean a hook inside the <form> tag itself like: > > <form <?php do_action('comment_form_tag', $post->ID); ?> action=".......> > > So everyone can choose to add onSubmit and/or onReset to it or not. :-) Event.observe($('commentform'), 'submit', function(e) { // The submit event code goes here. }); Don't try to force PHP to do what you can already do more easily with javascript. Owen _______________________________________________ wp-hackers mailing list wp-hackers@... http://lists.automattic.com/mailman/listinfo/wp-hackers |
|
|
Re: Idea for comments.phpIt's actually not supposed to be good practice to include JS in the HTML
tags. This is why libraries such as Prototype, which Owen mentioned above, exist. Using events and DOM insertion, you can put the attributes in, with a script that was included in the <head>. On 10/2/06, Roland Haeder <webmaster@...> wrote: > > On Tuesday, 3. October 2006 01:15, Owen Winkler wrote: > > Dumping javascript into the page to run as it's downloaded might not be > > the best idea, especially since I've provided an example of how to do it > > well, but here you go: > > > > > > add_action('comment_form', 'my_php_function', 1); > > > > function my_php_function($postid) { > > echo "Post ID: {$postid}"; > > } > > > > > > This hook is already in the default theme's template code. See > > comments.php. > I mean a hook inside the <form> tag itself like: > > <form <?php do_action('comment_form_tag', $post->ID); ?> action=".......> > > So everyone can choose to add onSubmit and/or onReset to it or not. :-) > > Roland > > -- > (GNU) PGP ID: 0x8C8859B9 > > Weblog: > http://blog.mxchange.org > _______________________________________________ > wp-hackers mailing list > wp-hackers@... > http://lists.automattic.com/mailman/listinfo/wp-hackers > wp-hackers mailing list wp-hackers@... http://lists.automattic.com/mailman/listinfo/wp-hackers |
| Free embeddable forum powered by Nabble | Forum Help |