[pmwiki-users] best way to change editform per view?

Dominique Faure dominique.faure.1 at free.fr
Fri Aug 19 00:41:48 CDT 2005


At Friday, August 19, 2005 4:53 AM [GMT+1=CET], Patrick R. Michaud wrote:

> On Thu, Aug 18, 2005 at 02:54:59PM -0700, H. Fox wrote:
>> On 8/18/05, Bronwyn Boltwood <arndis at gmail.com> wrote:
>>> Another thing that I really want is that when I hit preview on the
>>> editform, PmWiki will jump to the preview section for me.  How can I
>>> arrange that?
>>
>> That would be nice, but I don't think it can be done.
>
> Thinking about it some more, there might be a couple of ways
> to do it, but they're a bit icky and tricky.
>
> The basic problem is that the preview button has to be a submit button
> for the edit form, and the url that the browser goes to is in the
> <form> element (which would therefore have to have the #preview
> anchor at the time the preview button is pressed).  Unfortunately,
> we don't always want the browser to jump to a preview section
> whenever the form is submitted;  save+edit and simultaneous
> edit conflicts should probably not jump to the preview.
>
> So, we need some trickery here.  I have three ideas:
>
> 1.  "Jumping anchors."  In this case the url in the <form> tag
> always has an anchor in it (e.g., "...wiki/Group/PageName#focus"),
> so the browser will always jump to the #focus anchor, but on
> each submit the #focus anchor moves around depending on where
> the browser focus should be after the submit.
>
> 2.  "Javascript window positioning."  I think there's a way in
> Javascript to tell a browser to position its scrollbar at a certain
> anchor, so we just have the preview output include some javascript
> that moves directly to the preview section.
>
> 3.  "Submit button mangling."  We might be able to add an
> "onclick=" attribute to the preview button that changes the
> target of the <form> to include an anchor just before submitting.
>
> None of these are terribly pretty, but they're the best I can come
> up with so far.
>
> Pm
>

My own 2c. solution is to have the preview at the top of the page and an 
anchors jumping to the edit form itself when required:


===8<---[Site.EditForm]---
(:if e_preview:)
>>float=right bgcolor=#fff7cb border='1px solid #ffad80' padding=2px 
>>center<<
'''$[Preview]'''\\
%red%[[#edit | &#9660; $[Edit] &#9660;]]%%
>><<
(:e_preview:)
----(:if:)[[#edit]]
!$[Editing {$FullName}] %block class=wikiaction% \
[-[=[=][[Rename -> {$FullName}?action=rename]][=]=]-] \
[-[=[=][[Delete -> {$FullName}?action=delete]][=]=]-]

(:messages:)
(:div id='wikiedit':)
(:input e_form:)[[#top]](:e_guibuttons:)\\
(:input e_textarea:)\\
$[Summary]: (:input e_changesummary:)\\
$[Author]: (:input e_author:) (:input e_minorcheckbox:) $[This is a minor 
edit]\\
(:input e_savebutton:) (:input e_saveeditbutton:) (:input e_previewbutton:) 
(:input e_cancelbutton:)
(:input end:)
(:divend:)
(:include $[{$SiteGroup}/EditQuickReference]:)
===8<------

Regards,
Dom





More information about the pmwiki-users mailing list