Forums / Developer / Workflow, or new datatype?

Workflow, or new datatype?

Author Message

nathaniel burbank

Tuesday 13 July 2004 9:21:31 am

Hi,

I am currently developing a site that is integrating PHPbb as its forum system. Basically, for each article, I want a comments link, that links to the appropriate topic in PHPbb.

Over the past weekend I wrote up a quick extension that adds a new templet operator, that accomplishes this functionality. It takes the node id number, queries the PHPbb database to see if there is already a topic for the article, and if there is not one, it creates it. It than returns the url of the topic along with a number of posts, so that I have something like "Comments [5]" once Ez Publish parses the template. The templet operator I wrote works fine, but it is not every efficient as it has to query the PHPbb database *everytime* the page is loaded.

What I want is for ez publish to create the new topic in PHPbb when an article is published, and than store the url to the topic in its own database. I am not sure wether I need to create some sort of new work flow, or wether I need a new data type to carry out this functionality perhaps some tweaking of the caching settings so Ez Publish stores the URL from the template operator I have already written?

Any advice would be much appreciated...

-Nathaniel

Paul Forsyth

Tuesday 13 July 2004 9:40:10 am

This sounds like a workflow. You need write a custome event for the content-publish-after trigger, which will activate when anything is published. You test to see what has been published and peform the necessary actions.

If, say, your article class has a url attribute, then when it is published your code can interface with phpBB, create the new topic, then you just need to store the new url in the url attribute and store it.

The docs on event creation might be your next step!

paul

--
http://www.visionwt.com

Paul Borgermans

Tuesday 13 July 2004 2:06:32 pm

Hi Paul, Nathaniel,

There is also the "onPublish" method which can be defined for a datatype. I think it is faster than workflows to do all kinds of weird or not-so-weird things. It can also access the other attributes as well is this method is called after storing.

hth

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

nathaniel burbank

Tuesday 13 July 2004 3:25:22 pm

Paul wrote:

"There is also the "onPublish" method which can be defined for a datatype. I think it is faster than workflows to do all kinds of weird or not-so-weird things. It can also access the other attributes as well is this method is called after storing."

This might be a stupid question, but how can assign a script or event for "onPublish" without using a work flow? Do I do this when I create the class? A search for "onPublish" on this site produced nothing in the docs... I would appreciate it if you could explain this a tad bit more.

Thanks,
Nathaniel

Paul Forsyth

Tuesday 13 July 2004 3:31:07 pm

Its the first i've heard of onPublish!

I had a quick look at the code and its part of a datatype:

Heres the code comment from kernel/classes/ezdatatype.php

    /*!
     Perfoms necessary actions with attribute data after object is published,
     it means that you have access to published nodes.
     \return True if the value was stored correctly.
     \note The method is entirely up to the datatype, for instance
           it could reuse the available types in the the attribute or
           store in a separate object.
    */

and docs: http://pubsvn.ez.no/doxygen/classeZDataType.html#a13

Basically this involves creating a new datatype, which could be a copy of ezurl. You could then add code to interface with phpBB. When you publish your article the attribute will be published which will trigger this code.

Workflows are a little neater than a new datatype. Though you could patch an existing datatype... Its cost/effort decision for implementing one over another.

paul

--
http://www.visionwt.com

Paul Borgermans

Wednesday 14 July 2004 4:28:03 am

Hi Paul

Yup, one of the hidden treasures :-)

I'm currently looking at this to integrate "foreign" data where I need to set a hook back to ez publish in a foreign database (Sybase) as well. So I "abuse" it for maintaining some kind of data integrity. I know this can also be done in workflows with some added benifit of error recovery (if the foreign database is down, the workflow simply defers to the next run). But I thought it is cool to have and try it out

Regards

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans