Forums / Setup & design / Old content and published date

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...

eZ debug

Timing: Jan 18 2025 01:14:37
Script start
Timing: Jan 18 2025 01:14:37
Module start 'content'
Timing: Jan 18 2025 01:14:38
Module end 'content'
Timing: Jan 18 2025 01:14:38
Script end

Main resources:

Total runtime1.2896 sec
Peak memory usage4,096.0000 KB
Database Queries204

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0067 587.7266180.8359
Module start 'content' 0.00671.1062 768.5625663.3125
Module end 'content' 1.11290.1766 1,431.8750341.0938
Script end 1.2895  1,772.9688 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.3093210.0002
Check MTime0.00150.1161210.0001
Mysql Total
Database connection0.00070.051610.0007
Mysqli_queries1.199192.98522040.0059
Looping result0.00290.22242020.0000
Template Total1.257097.520.6285
Template load0.00210.166220.0011
Template processing1.254897.304720.6274
Template load and register function0.00010.007810.0001
states
state_id_array0.00120.094910.0012
state_identifier_array0.00170.132420.0009
Override
Cache load0.00180.1380320.0001
Sytem overhead
Fetch class attribute can translate value0.00160.122850.0003
Fetch class attribute name0.00160.122990.0002
XML
Image XML parsing0.00360.282150.0007
class_abstraction
Instantiating content class attribute0.00000.0016100.0000
General
dbfile0.00550.4267460.0001
String conversion0.00000.000530.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
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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 23
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs