Article

eZ publish: PHP's Killer App - Parts 1-3

Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 Next

A Static Page

phpPoint.com is now almost ready! All you're missing is the two final links on the menu for "Contact" and "About Us". Beginning with the last first, I'll make the "About Us" page, that tells visitors what the site is, and who's running it etc. To do this I'll make use of a "static page".

First, head to the eZ publish back end administration and go to the eZ article module (on the far left). The default view is the "Article Archive" -- in here you should see five categories (unless you changed them while you did your homework): Standard, Intranet, Trade, News and Static Pages.

First things first! So that your site looks right, rename the first four to "Design", "Develop", "Deploy" and "Reviews", respectively.

Next, edit the Static Pages category -- notice that "Exclude from search" is selected. This prevents any pages put here from turning up in eZ publish searches, which is what's required.

Now click on "New Article" and create an article called "About phpPoint". Make sure the category is set to "Static Pages" and that "Publish" is checked. Enter some text in the Content box, using the eZ article tags you taught yourself about. For those who haven't done their homework, here's some text for you to use:

<header 1>About phpPoint</header>            
           
phpPoint is a delivers high quality articles on PHP            
to developers looking to take their expertise to            
the next level. Favourite topics include:            
           
<bullet>            
Object Orientation            
N-Tier Design            
Application Integration            
And much, much more...</bullet>

Once you've created the page, click on its name within the Article Archive and see what ID it's been assigned in the URL -- the number at the end is what you're interested in. For example, in the URL "index_admin.php/article/articlepreview/12/" the article ID is 12.

Now, edit site.ini:

URLTranslationKeyword=section-phppoint;aboutus

Head to the URLTranslator in the admin section and click "New". Enter the source URL: /aboutus and destination URL of /article/articlestatic/12 (assuming your article ID was 12). Notice the URL I've entered there -- that makes use of the "articlestatic" element within the eZ article module, as opposed to a normal "dynamic" article URL like /article/articleview/12.

You can now place a link to this page from frame.php like this:

<a href="<? print $GlobalSiteIni->            
WWWDir; ?>/index.php/aboutus">About Us</a>

And with that, our first static page is created!

Using eZ form

There's just one page (the Contact page) to go before phpPoint is finished!

First things first. Let's create another static article called "Thank You" and insert this content:

<header 1>Thank you for your feedback!</header>            
           
An email has been sent to the phpPoint staff. We'll get            
back to you shortly.

As before, note the ID of this article.

Next, head to the eZ form admin tool and your default view will be the Form List -- click "Create Form" here. Enter your email address in "Send form to:" and "Your e-mail address:" Then, for "Show this page on completion:" enter "/article/articlestatic/13" (or whatever your ID was), then click OK. Now select the name of the form in the form list and click "New Element". The eZ form tool takes a little getting used to, but it allows you to build all the parts of a normal HTML form. In eZ form terms, the following element types correspond to these HTML form elements:

Textline: <input type="text" />            
Textarea: <textarea />            
Radiobox: <input type="radio" />            
Multiple Select: <select multiple />            
Dropdown: <select />            
Checkbox: <input type="checkbox" />

Note also that "Breaks" adds a <br /> after element, so that the next one appears on a new line. "Size" determines the length for certain fields (like Textlines) and "Required" forces this field to be completed. Use "Update" to add elements or change their settings.

Now, our mission is to build a form that has these fields:

[Field Name] [Type] [Size] [<br />] [Required]            
[Your Name:] [Textline] [20] [Yes] [Yes]            
[Your Email:] [Textline] [30] [Yes] [Yes]            
[Message:] [Textline] [n/a] [n/a] [Yes]

When you're done, head back to the eZ article admin and create another static page called "Contact". In the Content field place simply the tag <form>, then at the bottom click "Add Item", making sure "Form" rather than "Images" is selected when you do so.
Now select the form called "Contact". Assuming this article has an ID of 14, you can add the following link to frame.php:
<a href="<? print $GlobalSiteIni->            
WWWDir; ?>/index.php/article/articlestatic/14/">Contact</a>

Now visitors will see the form when they click on the "Contact" link. Completing the form will send them to the "Thank You" page you just made.

The ZIP File

As mentioned, I've done all the hard graft for you, so you can just copy and paste all the template files etc. to the right places in your eZ publish installation. It's all stored in the phpPoint ZIP.

Just so you know, the ZIP contains only those files I've modified, and I've stored them in a directory structure that mirrors the eZ publish directory structure, to help you copy them to the right places. For safety's sake, it's best to extract the ZIP to a temporary directory, rather than straight into the eZ publish directory, and then copy the files across manually.

phpPoint Finished!

Congratulations! You're now the proud owner of an eZ publish site! Are you starting to see why they call it "eZ"?

One final thing remains, which is to enable page caching again for the eZ article module, now that you're finished updating the design. And of course, you know how to do that yourself now!

The site you created was very simple, using only the eZ article module, but it already allows you to collaborate with a team of writers to publish anything you like with images, flash etc. etc. Now imagine all the things you can do with eZ trade, eZ forum, eZ filemanager, eZ newsfeed and all the other eZ publish modules..!

With eZ publish, we're talking state-of-the-art Websites. Even better is the fact that eZ publish doesn't require that its users know irritating details like HTML. As you've seen using the eZ article admin module, a non-technical person could update the site, once they'd been trained to use eZ publish. Better yet, they could use eZ publish Desktop Edition to write articles on their own machine, and then update the site directly (unknowingly making use of XML-RPC) without risking the site going down at the moment they try to add update their document, which would of course see them lose all their work.

So if you're happy with the existing modules, you now have all you need to get building with eZ publish. But if you really want it all, the third part of this series will show you how to write your own eZ publish modules in PHP, allowing you to take advantage of the framework to rapidly develop and deploy your own applications.

Until then, may all your publishing be eZ! (Did I use that gag already?)

If you liked this article, share the love:
Print-Friendly Version Suggest an Article

Sponsored Links