3070 Posts in 869 Topics by 651 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1901 Views |
-
_live table not updating from table in CMS

8 May 2009 at 11:12pm
I have a 1 - many relationship defined allowing me to associated multiple objects with my home page ('featured items' functionality). When I check or uncheck the objects in the CMS and then Save and Publish the associations are not correctly updated. Looking at the underlying tables I see that the core table has updated (in my case BookPage) but not the live table (in my case BookPage_Live).
Any idea what could be causing this?
-
Re: _live table not updating from table in CMS

22 October 2009 at 10:52pm
Did you fix this ?
I'm experiencing the exact same problem at the moment...
-
Re: _live table not updating from table in CMS

14 November 2009 at 10:04am
I have the same problem. Changes I make on saving page, which occur with raw sql statement in
function onBeforeWrite() {
// call parent first
parent::onBeforeWrite();
// check if MainStory is true
if( $this->IsMainStory ){
// if yes, make sure no other story is main-story
// we use a raw sql query here to set all IsMainStory to 0
DB::query('UPDATE ' . $this->ClassName . ' SET IsMainStory=0');DB::query('UPDATE ' . $this . ' SET IsMainStory=1 WHERE ID=' . $this->ID);
}
Are not reflected in Live database but are in core? Anyone know why?
-
Re: _live table not updating from table in CMS

15 November 2009 at 11:15pm Last edited: 15 November 2009 11:16pm
I unfortunately still haven't figured this out! I hoped the Silverstripe book may elucidate the usage of the version tables but as excellent as it is I haven't yet found the clues I needed to solve this problem. Maybe v 2.4 will sort it out. I'll post any progress that I make...
-
Re: _live table not updating from table in CMS

16 November 2009 at 11:31am
In my case the problem was that I was using raw sql update a table. I found out that
"
you should never update directly to the live tables since it will lead to syncing problems when you re-publish a page and erase your data...
"so found out how to update table another way in following function.... not sure if this will help but thought I'd let you know.
see this thread
http://silverstripe.org/general-questions/show/273211?start=8#post273347
-
Re: _live table not updating from table in CMS

16 November 2009 at 9:46pm
Unfortunately , I'm not using raw SQL commands to update a table but alter everything through a default "has_many" relationshop (exactly the same problem as TS). Any ideas ?
-
Re: _live table not updating from table in CMS

2 April 2010 at 12:19am
I have discovered at the reason for this problem is that when using a HasManyComplexTableField the changes are not published when the page containing the HasManyComplexTableField is published. What is required is to force the publication of the page objects on the 'many' side of the relationship in the onBeforeWrite event: something like this
public function onBeforeWrite()
{
$hasManyPages = DataObject::get("MyHasManyPage");
if($hasManyPages )
{
foreach($hasManyPage as $page) {
$page->writeToStage('Stage');
$page->publish('Stage', 'Live');
$page->flushCache();
}
}
parent::onBeforeWrite();
} -
Re: _live table not updating from table in CMS

2 April 2010 at 12:32am
Hey... thanks for figuring that out !
It seems so logical once you know.. But we could not not figure this one out ... ;-)
| 1901 Views | ||
|
Page:
1
|
Go to Top |



