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

eZ debug

Timing: Jan 31 2025 04:14:23
Script start
Timing: Jan 31 2025 04:14:23
Module start 'content'
Timing: Jan 31 2025 04:14:23
Module end 'content'
Timing: Jan 31 2025 04:14:24
Script end

Main resources:

Total runtime0.1180 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 587.9297180.8359
Module start 'content' 0.00560.0062 768.7656101.9922
Module end 'content' 0.01180.1062 870.7578531.0234
Script end 0.1179  1,401.7813 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00302.5167200.0001
Check MTime0.00131.0892200.0001
Mysql Total
Database connection0.00090.729510.0009
Mysqli_queries0.075964.34011410.0005
Looping result0.00100.81961390.0000
Template Total0.105889.710.1058
Template load0.00090.758410.0009
Template processing0.104988.897710.1049
Override
Cache load0.00070.566910.0007
Sytem overhead
Fetch class attribute can translate value0.00040.326110.0004
XML
Image XML parsing0.00020.157610.0002
General
dbfile0.01058.8599200.0005
String conversion0.00000.003830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs