On Wed, 2002-10-30 at 14:15, Tobias Roth wrote:
> Hi
Greetings!
> In the fast few days I have installed midgard and converted a rather
> simple website to the midgard engine. Everything worked flawlessly and
> pretty straight forward.
Sounds good.
> Now I'd like to build a simple CMS for my website and I am wondering
> what would be the best approach. The site structure is pretty simple,
> no styles or pages will have to be modified. The only thing that needs
> to be possible is to add/delete/modify subtopics, articles and subpages
> with a given style. The admin site should look similar to the main site,
> but with the ability to change content. And before the content is
> actually changed, I would like some sort of preview.
This is very easy to do. Midgard hosts can share a style and page
hierarchy.
Create a new host, for example to port :8001 or to another hostname
using same root page and style as your web site.
Then go to your pages and add a check on if we're running on the
"admin" host (for example, if port is 8001), and add the "Add new
news item" or "Modify this topic" buttons to appropriate pages.
Next you need to create the forms for updating content.
Something like this:
<?php
/*
Full code for displaying and editing an article
add code for getting article based on URL, should
be used on an active page.
Also handles previewing before saving
*/
if ($save) {
$article->title = $title;
$article->content = $content;
$article->update();
} elseif ($edit || $preview) {
if ($edit) {
$title = $article->title;
$content = $article->content;
}
?><form>
<p>Title: <input type="text" name="title" value="&(title);">
<p>Content:
<textarea name="content">&(content);</textarea>
<p><input type="submit" <?php
if ($preview) {
echo "name=\"save\"";
} else {
echo "name=\"preview\"";
}
?>>
</form>
<?php
} else {
?>
<h1>&(article.title);</h1>
&(article.content:f);
<?php
// Add link to article editor
$host = mgd_get_host($midgard->host);
if ($host->port == "8001" && $midgard->user) {
?><p align="right"><a href="?edit=1">Modify article</a></p><?php
}
} ?>
Please note that I didn't run that code, so there
might be typos.
If you want to provide your users with something nicer
than simple forms, you can try the Xopus WYSIWYG editor.
Contact me for instructions on how to use that with
Midgard.
/Bergie
--
Henri Bergius [EMAIL PROTECTED]
Consultant Partner Tel: +358-20-198 6032
Nemein Oy http://www.nemein.com/
Nemein.Net - Project tracking solution for consulting companies
http://www.nemein.com/Nemein.Net/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]