开发者

Automatically generate SiteTree translation in Silverstripe

Is there a way, to (automatically) generate, or "duplicate", the site tre开发者_开发问答e for a translation into another language? For example via an url command or something like that.

Best regards, Benedikt


you probably already found a solution by now ... but for future reference, SilverStripe user drx has created a batch action for translations as discussed here: http://silverstripe.org/customising-the-cms/show/7318


Tip:

->createTranslation() only creates a live-record even if you call this on a stage-object created with:

$a = Versioned::get_one_by_stage($this->ClassName, 'Stage', $this->ClassName.".ID = ".$this->ID);

To create Stage and Live-Pages you have to:

$translation_GB = $this->createTranslation('en_GB');
$translation_GB->doRestoreToStage();

Saving is done automatically in both cases.


You wouldn't duplicate the site tree to create a translation. SilverStripe supports multi-lingual sites. You can read up on it here: http://doc.silverstripe.org/sapphire/en/topics/translation

If you're wanting a way to automate this there's no native support but it wouldn't be hard to do. By URL would just be a matter of adding a function to your Page_Controller or, even better, you could write a simple module if it's something you're going to be doing regularly (just look at the googlesitemaps module for an example as it loops through pages as you'd need to). You can get all pages by calling:

Versioned::get_by_stage('SiteTree', 'Live', $filter);

Then you'd create your translation(s) as you looped through. You could also do this via commandline by using SilverStripe's CMDline utility "sake": http://doc.silverstripe.org/sapphire/en/topics/commandline

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜