Forums / Extensions / Website Interface / How can I keep the same classes on two ezpublish websites?

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

eZ debug

Timing: Jan 29 2025 13:46:49
Script start
Timing: Jan 29 2025 13:46:49
Module start 'content'
Timing: Jan 29 2025 13:46:49
Module end 'content'
Timing: Jan 29 2025 13:46:49
Script end

Main resources:

Total runtime0.1294 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.0061 588.3438180.7266
Module start 'content' 0.00610.0061 769.0703103.1484
Module end 'content' 0.01220.1171 872.2188536.5156
Script end 0.1294  1,408.7344 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00342.6109200.0002
Check MTime0.00141.0507200.0001
Mysql Total
Database connection0.00060.489110.0006
Mysqli_queries0.085466.00761410.0006
Looping result0.00120.93151390.0000
Template Total0.116890.210.1168
Template load0.00080.596410.0008
Template processing0.116089.606310.1160
Override
Cache load0.00050.392510.0005
Sytem overhead
Fetch class attribute can translate value0.00060.486710.0006
XML
Image XML parsing0.00030.234110.0003
General
dbfile0.00675.1633200.0003
String conversion0.00000.004130.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