Forums / Developer / How to get Content out of the DB with a Datatype

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)" ?

eZ debug

Timing: Jan 31 2025 03:42:21
Script start
Timing: Jan 31 2025 03:42:21
Module start 'content'
Timing: Jan 31 2025 03:42:21
Module end 'content'
Timing: Jan 31 2025 03:42:21
Script end

Main resources:

Total runtime0.3074 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0096 588.0625370.2734
Module start 'content' 0.00960.0155 958.33591,013.5781
Module end 'content' 0.02510.2822 1,971.91413,901.9141
Script end 0.3074  5,873.8281 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00431.3935200.0002
Check MTime0.00140.4406200.0001
Mysql Total
Database connection0.00060.179810.0006
Mysqli_queries0.211268.70731410.0015
Looping result0.00140.46341390.0000
Template Total0.281891.610.2818
Template load0.00100.325610.0010
Template processing0.280891.320510.2808
Override
Cache load0.00070.219910.0007
Sytem overhead
Fetch class attribute can translate value0.00160.531110.0016
XML
Image XML parsing0.00020.063410.0002
General
dbfile0.00892.9097200.0004
String conversion0.00000.002930.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.0002 secs