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

And finally!

We're almost there. The final step is simply to give our site visitors a link to get to the FAQ module. I did this by editing [eZ publish_root]/ezarticle/user/templates/phppoint/menubox.tpl to include:

<tr>                      
<td class="menuitem">                      
<a href="{www_dir}{index}/faq/faqlist/">PHP FAQs</a>                      
</td>                      
</tr>

The allows you to access the eZ faq module using a URL such as:

http://localhost/public/ezpublish_2_2_6/index.php/faq/faqlist/

If you do the same, don't forget to clear out the eZ article cache after doing so.

As an alternative, you might choose to place the link within [eZ publish_root]/sitedesign/phppoint/frame.php as we saw in part 2 of this series.

Zipping Up

So, to summarize what we've done:

  • We first designed our module, sketching the user interface, defining a database schema, and listing the "events" that the module should be able to respond to.
  • Next we built the "logic" classes that are responsible for transforming data from the database into a form the module can use to respond to events.
  • Then we built datasupplier.php, the "traffic cop" of our module, which directs "events" to the correct PHP scripts.
  • Next, we wrote the presentation scripts, which access our logic classes and use them to "populate" XHTML templates.

We now have a fully functional eZ publish module!

Phew!

If you got this far, congratulations! Here's that ZIP file I've been promising...

Now you may be feeling pretty overwhelmed if you just read this whole article in one go. Don't dismay! The first thing to do is add the eZFaq module to your eZ publish installation (I've included a README file containing quick installation instructions in the ZIP). Have a look at the code and review the article as you do so, to check it makes sense.

If you come across any problems or anything you don't understand, feel free to post in the SitePointForums from the link at the end of this article.

Of course, this tutorial wouldn't be complete without some homework...

Homework

Here are some ideas to help you put what you've learnt about eZ publish into practice. One general tip -- if you're ever stuck, have a look at the code of the other eZ publish modules (more or less every common problem has already been solved somewhere).

  • When categories, headings and FAQs are created, right now the results are displayed using a simple print() statement. This means administrators have to navigate back to the point where they began editing (and it will no doubt drive them crazy). Update this using template blocks (you'll see what I mean once you try it).
  • Right now, eZFaq has one big problem: if an administrator deletes a heading or a category, eZFaq has no means to either delete related FAQs/headings or re-assign FAQs/Headings that have lost their "parents". Something must be done!
  • When an administrator creates FAQs, right now they're POSTing "plain text", perhaps with some HTML thrown in. As you know, the eZ article module has it's own tags to allow for simple markup of pages, without requiring the user to know anything about HTML. Wouldn't it be great if eZFaq could use the tags as well? Have a look at how the eZ article module achieves this...
  • eZ publish has a user and groups authentication system. It would be nice, especially for big FAQs, if eZFaq could take advantage of these, so that phpPoint administrators could be assigned to maintain a single category?
  • phpPoint gets an email from another Webmaster saying they want to use the FAQs. Create an XML-RPC server interface to the FAQs, as an alternative to the XHTML interface. Note that eZ publish comes with an XML-RPC class.

Otherwise, head over to the PHP section at Hotscripts, where there's a whole of bunch of applications just crying out to be eZ publish modules. For example, eZ publish doesn't have a Shoutbox or graph creation tool. Other people, such as the phpBB team, are talking about integration with eZ publish, too...

Wrap Up

In part 1 of this article series, I introduced you to eZ publish, and showed how to install it. Then, in part 2 we created a fictional Website called phpPoint as a means to discover how to apply our own design to eZ publish. And in this final part of the series, we saw how to create our own eZ publish modules, and learned a bit more about object orientation in PHP in the process. You now have all you need to get started building enterprise level Websites with eZ publish!

Overall, when you consider what eZ systems has accomplished so far, it's hard not to be extremely impressed. Not only have they put together a solid class library for solving all sorts of common problems that Web developers like you and I encounter on a daily basis, but they've also built a complete framework around it -- and a series of enterprise level applications to make it possible to build anything from building a simple news site, to a corporate intranet or even an ecommerce portal.

And they're not stopping there! Looking at http://sdk.ez.no/, a software developers' kit is in progress that could benefit PHP developers everywhere!

So, in my opinion, "eZ publish is PHP's killer application". What do you think?

If this article has given you a taste for object oriented PHP, please do drop by SitePoint's Advanced PHP Forum, where you'll find plenty of information and people to help you explore the topic further. I'd personally like to thank voostind, author of the Eclipse PHP Library and regular at the SitePointForums, whose insightful posts are indirectly responsible for this article.

There may be one more surprise in store (I'll leave you guessing -- check back next week!) but otherwise, may all your publishing be eZ!

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

Sponsored Links

Rate This Article

  • 1
    Poor
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
    Great

Comment on This Article

Have something to say?

Post A Comment

You need to be a member of the SitePoint Forums to comment on this post. Sign Up

Already a member? Post using your SitePoint Forums account: