I had an interesting idea about the whole editing-in-midgard thing...

What if we could have "embedded" editing, much in the spirit of edit-this-
page stuff (hereafter referred to as ETP), without having to rewrite every 
single part of a midgard site, or go out  of our way to add the functionality?

What I mean is, that some sort of conditions can be defined (such as a user 
being logged in, or somesuch), which causes all the parts of the currently 
displayed page to be editable.

What this would mean for the user, would be that they could click "edit",
 and the page would reload - except that all the content in the page from 
an article would be replaced with a textbox. They could also choose to "edit 
this template", and edit the actual page.

I can think of a couple of possible approaches to do this.

        1. Write custom code in each form. Of course, this is a pain, and likely 
to cause code maintenance hell. (such as the admin pages are... shudder)

        2. Replace the contents of article records with <input> tags, and add the 
necessary <form> and </form> tags. This is simple, from the midgard site 
creator, and fairly simple from the midgard coder perspective, too. (if(editmode){ 
-put input tags around the data returned- } else { return }). But it tends 
to break the PHP stuff people create.

        3. Provide a "display macro" - whenever someone displays data they wish 
to allow people to edit,they would say something like "mgd_wrap(type,id,
field, [value])" - this would either return the appropriate value, or an 
input tag. There would probably need to be a "mgd_wrap_begin" and "mgd_wrap_end",
 too, for the form tags. Theses would be present in the page, and there 
would also be a "mgd_wrap_page", and a "mgd_wrap_style()" These would be 
placed at the beginning of the style + page, respectively, and would provide 
a form to handle all this. If we were going for a fully php approach, then 
a mgd_wrap_handle would need to be present at the top of the style, too. 
Otherwise, it should be built into the midgard handlers.

Quite frankly, I think I like the third best. Could you tell? :)

This might actually be an excellent bit of code to write as a library of 
PHP functions (in PHP), rather than as part of mgd itself.

The nice part about all this is that it makes it possible to convert a page 
from non-editable to editable very quickly. You just go through and find 
eveywhere you -display- a variable from an article or topic, and replace 
the direct reference to the variable to an indirect reference via the mgd_wrap. 
Since the value of the "wrapped" variable is given, no extra lookups are 
incurred (unless value isn't given, and then its probably their own fault,
 although I can see cases where being able to say "Parent topic is <? mgd_wrap("topic",
$topic->up, "name"); ?>" could be nice ;).

Any thoughts?

Ben Garney
LHS Webmaster
http://www.lincolnhs.pps.k12.or.us/



IMPORTANT NOTICE:  If you are not using HushMail, this message could have been read 
easily by the many people who have access to your open personal email messages.
Get your FREE, totally secure email address at http://www.hushmail.com.




--
This is The Midgard Project's mailing list. For more information,
please visit the project's web site at http://www.midgard-project.org

To unsubscribe the list, send an empty email message to address
[EMAIL PROTECTED]

Reply via email to