Personal tools


Blog example

From OrganicDesign

Jump to: navigation, search
Example broken: For Safari web browsers, this example is currently broken, probably due recent changes to Extension:SimpleForms.php


This SimpleForms example allows a user to edit any article's talk page dynamically. The talk page is transcluded and a form allows users to enter a heading, their name and a comment which is then dynamically appended to the talk page and the trancluded content updated via an Ajax request. An example of the source code is shown here, it is implemented in Template:BlogComments so it can be transcluded into any article. The layout and formatting of the posted comments is defined in Template:Blog.

== Comments ==
<div id='wgBlogComments'>{{Talk:{{PAGENAMEE}}}}</div>

{{#form:
{{#input:type=hidden|name=content|id=blogContent}}
{{#input:type=hidden|name=title|value=Talk:{{PAGENAMEE}}}}
{{#input:type=hidden|name=summary|id=blogSummary}}
{{#input:type=hidden|name=caction|value=append}}

Heading:   {{#input:type=text|id=blogTitle}}
Your name: {{#input:type=text|id=blogName}}
Comment:   {{#input:type=textarea|rows=2|id=blogBody}}

{{#input:type=ajax|value=Post comment|update=wgBlogComments|onClick=
var summary='comment posted by '+document.getElementById('blogName').value;
document.getElementById('blogContent').setAttribute('value',
'\n==='+document.getElementById('blogTitle').value+'===\n'+
  document.getElementById('blogBody').value+'\n:<i>'+summary+'</i>\n');
document.getElementById('blogSummary').setAttribute('value','Blog '+summary);}}

}}

The submit button looks rather complicated, this is because the content being appended to the talk page needs to be composed by the Javascript from the title, name and body inputs.


1 Comments

2 Troubleshooting

For this technique to work you need to allow anonymous talk. Have a look at these links:


2.1 Testing article creation

Hello!

--comment posted by Mr Foo (23:41, 27 August 2007 (NZST))

2.2 foo

baz

--comment posted by bar (00:57, 30 August 2007 (NZST))

2.3 cor

Just looking, neat... so many things to put into a new wiki these days

--comment posted by Nibb (01:07, 13 September 2007 (NZST))

2.4 cor

Just looking, neat... so many things to put into a new wiki these days

--comment posted by Nibb (01:07, 13 September 2007 (NZST))

2.5 Cabecera

Comentario

--comment posted by nombre (22:35, 17 September 2007 (NZST))

2.6 Jakub

mz comment

--comment posted by Gorn (05:16, 23 September 2007 (NZST))

2.7 Jakub

mz comment

--comment posted by Gorn (05:16, 23 September 2007 (NZST))

2.8 Jakub

mz comment

--comment posted by Gorn (05:16, 23 September 2007 (NZST))

2.9 Sa sa

Nice

--comment posted by sasa (00:32, 3 October 2007 (NZST))

2.10 Gil123

fdsf fds fds fsd

--comment posted by Gil R (00:36, 3 October 2007 (NZST))

3 zxzxz

zxxxxxxxxxxxxxxxxx

4 zzzz

zzzzzzz

Heading: Your name: Comment: