Forums / Developer / API Questions

API Questions

Author Message

Matt McLaughlin

Monday 31 August 2009 6:50:00 pm

My company is looking for a CMS tool we can use to manage multiple languages for our content. What attracted us to eZ is the possibility of using the API. We use a cake framework to power the rest of our site and would like to use the API to import content in the correct language. Does this sound like something the eZ publish API is capable of doing? I'm looking through the API Docs but I'm not finding a good jumping off point.

Any help would be appreciated, thanks!

Lazaro Ferreira

Tuesday 01 September 2009 1:33:41 am

Hi,

You can import your content into ezpublish from csv files running

bin/php/ezcsvimport.php

 

from command line,

if you need to do it your way, you can look at this script code, to see how ezpublish content attribute API is used to import , i.e:

$attribute->fromString( $dataString );

Also there are some contributions at projects.ez.no, that implement more avanced import funcionalities

Regards

Lazaro
http://www.mzbusiness.com

Matt McLaughlin

Tuesday 01 September 2009 10:13:07 am

Well, it wasn't getting the content into eZ Publish, it was getting it out of. What we're looking to do is have eZ Publish manage our content and it's various languages then use cakephp as the view layer via the API.

However this might be useful with some of our existing content.

Matt McLaughlin

Tuesday 08 September 2009 2:09:08 pm

Any information at all would be helpful. To describe what we're doing again is trying to use eZ Publish to manage our versions, translations, and management of our content but would like to use the API to extract the content in our own pre-existing system/templating engine.

I see you can write cli scripts is there something similar but for the web side of things?

Gaetano Giunta

Wednesday 09 September 2009 1:04:31 am

I'm afraid there is no real explicit (documented) support for doing what you want.

It is technically possible, of course, but the whole 'framework' is designed the other way round: it is easier to extended by including/wrapping 3rd party code rather than by including it.

Some points that have to be taken care of:
- the autoload system used as php class loader is a little piece of code that has grown already complex because it caters to both eZPublish and eZComponents classes
- using any php class of eZPublish means bootstrapping at least the configuration system - which will in turn load the debug system (both quite heavy)
- you always need to define a 'siteaccess' to be used while you are operating
- everything works best if started from the eZPublish root dir. It might not work otherwise

The best way to gain enough knowledge about how to embed eZP within another script is to look at the existing controller code, and then try and experiment writing your own minimal bootstrapping code that can be safely included within an external app:
- index.php
- soap.php
- the ezcli and ezscript classes, used by all command line scripts

Principal Consultant International Business
Member of the Community Project Board

Gaetano Giunta

Wednesday 09 September 2009 1:08:48 am

PS: if what you want is not "live" integration, there are a thousand possibilities for exporting content / content-views from eZPublish and import them in your application:
- eZPublish packages (created via admin interface)
- export scripts (look at exportcsv as an example)
- rss feeds (managed via admin interface)
- xml/json templates of content (look at the ggxmlview extension)
- webservice calls (native soap controller or a lot of extensions, from ezrest to ggwebservices to ezcore)

Principal Consultant International Business
Member of the Community Project Board

Matt McLaughlin

Wednesday 09 September 2009 10:24:01 am

I wish we could just do it all in ez Publish, haha, but we have templates for our forum in vBulliten, and our main sites in cakephp. No matter which way we go from here, it's going to be a lot of work.

I am successful in extracting data via a web script, the only issue now is breaking it out from the ezpublish folder itself. This may not be entirely possible, but, with some routing rules we may be able to fake it enough ;)

Thank you for your fast response. I realize this is NOT how ez Publish intended it's framework to operate, lol, but it will actually make our site much easier to maintain.

eZ debug

Timing: Jan 18 2025 11:16:50
Script start
Timing: Jan 18 2025 11:16:50
Module start 'content'
Timing: Jan 18 2025 11:16:50
Module end 'content'
Timing: Jan 18 2025 11:16:50
Script end

Main resources:

Total runtime0.0153 sec
Peak memory usage4,096.0000 KB
Database Queries4

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0069 587.7422180.8516
Module start 'content' 0.00690.0044 768.5938101.9375
Module end 'content' 0.01130.0039 870.531378.7031
Script end 0.0153  949.2344 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002617.1578120.0002
Check MTime0.00117.4602120.0001
Mysql Total
Database connection0.00074.424810.0007
Mysqli_queries0.002818.128640.0007
Looping result0.00000.196020.0000
Template Total0.003623.610.0036
Template load0.00095.716210.0009
Template processing0.002717.879710.0027
Override
Cache load0.00063.707610.0006
General
dbfile0.00031.9059100.0000
String conversion0.00000.054530.0000
Note: percentages do not add up to 100% because some accumulators overlap

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