How can I keep the same classes on two ezpublish websites?

Author Message

florian bellenger

Thursday 18 December 2008 4:20:18 am

Good afternoon,

I have two ezpublish websites.They both have their own files and their own database.

But they have the same classes.

When I create/publish a new class within the website interface of the first website, I would like it to be automatically created within the website interface of the second website.(I am doing it by hand but it takes time and I could make a mistake.)

When I modify an existing class within the website interface of the first website, I would like it to be automatically modified within the website interface of the second website.

Is there any existing solution for that kind of problem?

Florian.

Patrick Kaiser

Thursday 18 December 2008 5:02:27 am

why do you use two databases for your websites? if you have the same classes and you want to share content between your sites you should consider using only one database.


Best regards,

Patrick

florian bellenger

Thursday 18 December 2008 5:17:22 am

In fact, the content are not the same between the two databases.

I also use the first website (and its database) to test new extensions or new templates.

So, if I have a problem with the database of the first website, I don't want the second one to be concerned.

Florian.

 

Bin LIU

Wednesday 20 May 2009 5:39:23 am

create an extension cronjob export->import

=== Lagardère Active ===

Fetch random
http://projects.ez.no/la_fetch_random
LA Static Cache
http://projects.ez.no/lastaticcache
LA Bookmarks (jquery)
http://projects.ez.no/labookmark
LA Calendar (jquery)
http://projects.ez.no/lacalendar

My site ez
http://lingping.info

Bin LIU

Wednesday 20 May 2009 5:40:26 am

or create a workflow after published to syncro

=== Lagardère Active ===

Fetch random
http://projects.ez.no/la_fetch_random
LA Static Cache
http://projects.ez.no/lastaticcache
LA Bookmarks (jquery)
http://projects.ez.no/labookmark
LA Calendar (jquery)
http://projects.ez.no/lacalendar

My site ez
http://lingping.info

Gaetano Giunta

Wednesday 20 May 2009 6:14:23 am

This cronjob creates a package for every class, automatically bumping up the version only when classes are updated:

<?php
/**
 * Cronjob that will export all classes definition as a package file.
 * Will only update the package if classes have been modified since last version
 *
 * @author G. Giunta
 * @version $Id$
 * @copyright 2009
 *
 * @todo add an ini file to get the parameters from
 */

$packagename = 'classes_mysite';
$packagesummary = 'Export of all the classes of the website';
$packagecreatorname = 'eZ Publish';
$packagecreatoremail = 'gg@ez.no';
$packageexportdir = '';


// create or open existing package
$package = eZPackage::fetch( $packagename );
if ( !$package )
{
    if ( !$isQuiet )
        $cli->output( 'Creating package ' . $packagename );
    $package = eZPackage::create( $packagename,
                                  array( 'summary' => $packagesummary ),
                                  false, false );
    $package->setAttribute( 'install_type', 'install' );
    $package->setAttribute( 'type', 'contentclass' );
    $package->appendChange( $packagecreatorname, $packagecreatoremail, 'Package created' );

    $lastsavedate = 0;
    $packageversion = '1.0';
}
else
{
    $lastsavedate = $package->attribute( 'release-timestamp' );
    $packageversion = $package->attribute( 'version-number' );
}

// find date of last modification of classes
$classes = eZContentClass::fetchList( eZContentClass::VERSION_STATUS_DEFINED, true );
$lastmodification = 0;
foreach( $classes as $class )
{
    if ( $class->attribute( 'modified' ) > $lastmodification )
    {
        $lastmodification = $class->attribute( 'modified' );
    }
    if ( $class->attribute( 'created' ) > $lastmodification )
    {
        $lastmodification = $class->attribute( 'created' );
    }
}

// if no class has changed since last release, quit
if ( $lastmodification <= $lastsavedate && $lastsavedate > 0 )
{
    if ( !$isQuiet )
        $cli->output( 'No class has been modified since last package save. Aborting' );
}
else
{
    if ( $lastsavedate > 0 )
    {
        if ( !$isQuiet )
            $cli->output( 'Updating package ' . $packagename );
    }

    // we always increment the minor version
    $major = substr( $packageversion , 0, strpos( $packageversion, '.' ) );
    $packageversion = substr( $packageversion , strpos( $packageversion, '.' ) + 1 );
    $packageversion = $major . '.' . ( $packageversion + 1 );
    // the release date is set to last date of modification of classes
    $package->setRelease( $packageversion, '1', $lastmodification );

    $handler = $package->packageHandler( 'ezcontentclass' );
    $classlist = array();
    foreach( $classes as $class )
    {
        if ( $class->attribute( 'modified' ) > $lastsavedate ||  $class->attribute( 'created' ) > $lastsavedate )
        {
            $classlist[] = $class->attribute( 'identifier' );
            $parameters = $handler->handleAddParameters( 'ezcontentclass', $package, $cli, array( $class->attribute( 'identifier' ) ) );
            $handler->add( 'ezcontentclass', $package, $cli, $parameters );
        }
    }
    $classlist = implode( ', ', $classlist );
    $package->appendChange( $packagecreatorname, $packagecreatoremail, 'Added classes ' . $classlist );
    $package->store();
    //$cli->output( 'Added classes ' . $classlist );

    $outputfilename = $packageexportdir . eZSys::fileSeparator() . $package->exportName();
    $package->exportToArchive( $outputfilename );
    if ( !$isQuiet )
        $cli->output( 'Saved file ' . $outputfilename );
}

?>

Principal Consultant International Business
Member of the Community Project Board

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 18 2025 03:00:28
Script start
Timing: Jan 18 2025 03:00:28
Module start 'layout'
Timing: Jan 18 2025 03:00:28
Module start 'content'
Timing: Jan 18 2025 03:00:28
Module end 'content'
Timing: Jan 18 2025 03:00:28
Script end

Main resources:

Total runtime0.1296 sec
Peak memory usage4,096.0000 KB
Database Queries72

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0047 588.4375152.6875
Module start 'layout' 0.00470.0031 741.125039.5234
Module start 'content' 0.00780.1202 780.6484668.1953
Module end 'content' 0.12800.0015 1,448.843820.0703
Script end 0.1295  1,468.9141 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00312.3866160.0002
Check MTime0.00130.9673160.0001
Mysql Total
Database connection0.00060.501110.0006
Mysqli_queries0.072756.1438720.0010
Looping result0.00060.4523700.0000
Template Total0.101978.620.0509
Template load0.00201.575320.0010
Template processing0.099877.029220.0499
Template load and register function0.00010.093310.0001
states
state_id_array0.00070.550210.0007
state_identifier_array0.00100.771020.0005
Override
Cache load0.00181.3666290.0001
Sytem overhead
Fetch class attribute can translate value0.00070.541040.0002
Fetch class attribute name0.00080.640790.0001
XML
Image XML parsing0.00241.861440.0006
class_abstraction
Instantiating content class attribute0.00000.0109100.0000
General
dbfile0.00221.7341270.0001
String conversion0.00000.006140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 19
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs