How to get Content out of the DB with a Datatype

Author Message

Daniel Scheiner

Tuesday 03 October 2006 11:12:03 am

Hi!

I want to write a new Datatype (is there a good HowTo out there?).
My problem is that I need the datatype to get some content-values and send those via a HTTP-Request to a server designated through the URL supplied to the datatype (it will be a textline-sort of datatype that is given a url).

Can anyone help me out with this? Thanks!!! =)

Damien Pobel

Tuesday 03 October 2006 11:54:40 am

Hi Daniel,

As I understand, you need to fill a form with some fields plus one field with a URL and then send them to a URL ?

It looks like to a trackback system ! You should have a look the eZTrackback extension [1]. This extension defines a workflow that sends some data (title, begin of the text, ...) to some URLs when the user writes a blog entry and click on "Send for publishing".

[1] http://ez.no/community/contribs/applications/ez_trackback

Damien
Planet eZ Publish.fr : http://www.planet-ezpublish.fr
Certification : http://auth.ez.no/certification/verify/372448
Publications about eZ Publish : http://pwet.fr/tags/keywords/weblog/ez_publish

Daniel Scheiner

Wednesday 04 October 2006 12:10:57 am

Hi Damien,

First of all: Thanks!

BUT: well, I would look at that but
a) it isn't working
b) I want it a lot simpler.

So I need to know how I can write a Datatype and add a action that is executed when the datatype-variable is submitted via the "send"-button.

Ɓukasz Serwatka

Wednesday 04 October 2006 12:49:01 am

Hi Daniel,

Here is tutorial how to build new datatype:
http://ez.no/products/ez_publish/documentation/development/extensions/datatypes/new_datatype

You can also generate one using Setup->RAD in admin interface. Of course code from RAD is just a base which you need to extend. Take a look at this topic for information how to connect to ex. database.

http://ez.no/community/forum/developer/using_external_db_in_extension_causes_problems

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Paul Borgermans

Wednesday 04 October 2006 4:17:35 am

Hi

You may want to use the onPublish method for a datatype to have an action executed upon publishing. You can start with an existing datatype for your new datatype which just implements this post-publish action as the difference.

This is also the way to create simple workflows (and it is easier to debug than the ezp workflow mechanism). It's one of the little (undocumented) features which are so useful in certain situations.

hth

Paul

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

Paul Borgermans

Wednesday 04 October 2006 4:51:01 am

Or a custom edit handler: check out the nice article by Lukazs:

http://serwatka.net/index.php/en/blog/ez_publish_3_8_new_custom_edit_handler

Paul

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

Daniel Scheiner

Wednesday 04 October 2006 5:36:25 am

Thanks Paul!
the onPublish method for a datatype sounds neat! is there an example somewhere?
And which onPublish method is the right one?
eZDataType::onPublish?
eZContentObjectAttribute::onPublish?

Paul Borgermans

Wednesday 04 October 2006 6:14:36 am

Hi Daniel

The datatype (class attribute level)

Here is an example:

http://pubsvn.ez.no/community/trunk/extension/personlist/datatypes/sckpersonlist/

But the custom edit handler is more appropriate if you want to do things with existing datatypes/classes

hth

Paul

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

Daniel Scheiner

Wednesday 04 October 2006 9:07:25 am

Thanks!!!

one small question on the side:
what is "(class attribute level)" ?

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 06:27:37
Script start
Timing: Jan 31 2025 06:27:37
Module start 'layout'
Timing: Jan 31 2025 06:27:37
Module start 'content'
Timing: Jan 31 2025 06:27:37
Module end 'content'
Timing: Jan 31 2025 06:27:37
Script end

Main resources:

Total runtime0.0117 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0043 588.2656151.2266
Module start 'layout' 0.00430.0025 739.492236.6797
Module start 'content' 0.00680.0039 776.1719102.1875
Module end 'content' 0.01070.0010 878.359441.9922
Script end 0.0117  920.3516 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002117.5070140.0001
Check MTime0.00108.1812140.0001
Mysql Total
Database connection0.00097.445210.0009
Mysqli_queries0.002017.344430.0007
Looping result0.00000.197210.0000
Template Total0.00087.010.0008
Template load0.00064.989210.0006
Template processing0.00021.943610.0002
Override
Cache load0.00043.478610.0004
General
dbfile0.00076.072980.0001
String conversion0.00000.052940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_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