Old content and published date

Author Message

Bruce Morrison

Monday 07 April 2003 12:29:54 am

We are developing a number of sites using ezpublish where we are taking an existing web site and it's content and converting it to an ezpublish solution. The problem is that there is many content types that have a published date that is required to be displayed and in most cases this needs to be set in the past.

To accomidate this we have created a content class with a published attribute. The trouble is that we can't order a list of content by an attribute. This can only be done using the meta data associated with a given node.

One of the metadata attributes is 'published' I am thinking of creating some workflow to set the metadata "published' attribute to the node published attribute.

Does anyone else have this issue and have come up with a solution?

Am I on the right track with a workflow solution?

Thanks
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Sergiy Pushchin

Monday 07 April 2003 3:00:15 am

Yes I think the workflow solution is ok for it, but you should assume that you need to connect that workflow to after publish trigger. Another problem here is that we have not tested a lot post operation triggers, but it should work fine.

Conrad Decker

Monday 17 January 2011 8:21:11 am

I'm currently attempting to accomplish the same thing where we're importing content from an older site and for display purposes, the publish dates need to be set to a date in the past. Is this possible?

It doesn't seem to be so using the createAndPublishObject methods, but I'm hoping there's an easy way to do this with the API nowadays?

Any and all help is extremely appreciated.

Thanks!

Peter Keung

Monday 17 January 2011 9:10:55 am

Our import logic (from data_import extension; sqliimport extension might have similar logic too) usually creates the object, then runs these as necessary:

// Set the created date if the source handler has implemented logic for it
        $createdDate = $this->source_handler->getCreatedDate();
        if( $createdDate !== false )
        {
            $this->current_eZ_object->setAttribute( 'published', $createdDate );
  }
        
        // Set the modified date if the source handler has implemented logic for it
        $modifiedDate = $this->source_handler->getModifiedDate();
        if( $modifiedDate !== false )
        {
            $this->current_eZ_object->setAttribute( 'modified', $modifiedDate );
        }

Then, we store the object and publish the node.

http://www.mugo.ca
Mugo Web, eZ Partner in Vancouver, Canada

Conrad Decker

Monday 24 January 2011 3:30:12 pm

Thanks for the info Peter.

I ended up having to dig a little further to figure this one out, but found some similar code in the cronjobs/rssimport.php file. For anyone that's interested, here's what I ended up with. Would be curious if anyone sees anything wrong with this, or if there's a better way to accomplish it.

So, after my initial createAndPublishObject call, I proceeded with this:

$contentObject = eZContentFunctions::createAndPublishObject( $params );<span> </span>

$db = eZDB::instance();            
$db->begin();                        

$object  = eZContentObject::fetch( $contentObject->attribute('id') );            
$version = $object->attribute('current');
           
$object->setAttribute( 'published', strtotime($date) );            
$version->setAttribute( 'created', strtotime($date) );

$object->setAttribute( 'modified', strtotime($date) );            
$version->setAttribute( 'modified', strtotime($date) );
          
$version->store();            
$object->store();                       

$db->commit();

Hopefully this will save someone some time down the road...

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 04:07:18
Script start
Timing: Jan 18 2025 04:07:18
Module start 'layout'
Timing: Jan 18 2025 04:07:18
Module start 'content'
Timing: Jan 18 2025 04:07:19
Module end 'content'
Timing: Jan 18 2025 04:07:19
Script end

Main resources:

Total runtime0.8061 sec
Peak memory usage4,096.0000 KB
Database Queries67

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0049 587.9141152.6250
Module start 'layout' 0.00490.0023 740.539139.4609
Module start 'content' 0.00720.7972 780.0000660.1563
Module end 'content' 0.80440.0016 1,440.156316.1641
Script end 0.8060  1,456.3203 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.3830160.0002
Check MTime0.00130.1568160.0001
Mysql Total
Database connection0.00060.076910.0006
Mysqli_queries0.741992.0358670.0111
Looping result0.00070.0830650.0000
Template Total0.773896.020.3869
Template load0.00200.249620.0010
Template processing0.771795.738520.3859
Template load and register function0.00010.014610.0001
states
state_id_array0.00170.217010.0017
state_identifier_array0.00150.189720.0008
Override
Cache load0.00170.2067320.0001
Sytem overhead
Fetch class attribute can translate value0.00050.065340.0001
Fetch class attribute name0.00260.321190.0003
XML
Image XML parsing0.00200.249240.0005
class_abstraction
Instantiating content class attribute0.00000.0022100.0000
General
dbfile0.00140.1716350.0000
String conversion0.00000.001040.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
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/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: 23
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs