本文整理汇总了PHP中Page::onBeforeWrite方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::onBeforeWrite方法的具体用法?PHP Page::onBeforeWrite怎么用?PHP Page::onBeforeWrite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Page
的用法示例。
在下文中一共展示了Page::onBeforeWrite方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onBeforeWrite
public function onBeforeWrite()
{
parent::onBeforeWrite();
if (!$this->Content) {
$this->Content = '<p>$List</p>';
}
}
示例2: onBeforeWrite
/**
* Iterate through all the modules and add their content to the parent page, so it can be found in searches.
*/
public function onBeforeWrite()
{
$pageClass = get_called_class();
// Behaviour can be disabled via the config
$writeContent = Config::inst()->get($pageClass, 'write_content');
// If a custom config doesn't exist, check ModularPage
if (is_null($writeContent)) {
$writeContent = Config::inst()->get('ModularPage', 'write_content');
}
if ($writeContent) {
$classes = ClassInfo::subclassesFor(__CLASS__);
// Only run this code if we're on a valid instance of this class.
// Fixes bug when changaing page type via the CMS (e.g. ModularPage -> Page)
if (in_array($this->ClassName, $classes)) {
if ($this->Modules()->Count()) {
$searchBody = '';
foreach ($this->Modules() as $module) {
$searchBody .= $module->getSearchBody() . PHP_EOL;
}
$this->Content = $searchBody;
}
}
}
parent::onBeforeWrite();
}
示例3: onBeforeWrite
/**
* If no publish date is set, set the date to now.
**/
public function onBeforeWrite()
{
parent::onBeforeWrite();
if (!$this->PublishDate) {
$this->setCastedField("PublishDate", time());
}
}
示例4: onBeforeWrite
function onBeforeWrite()
{
parent::onBeforeWrite();
if ($this->ID) {
$this->RootFolder()->Title = $this->Title;
}
}
示例5: onBeforeWrite
public function onBeforeWrite()
{
if (!$this->ID) {
$this->isInsert = true;
}
parent::onBeforeWrite();
}
示例6: onBeforeWrite
/**
* Overwrites default behaviour onBeforeWrite
*
* This method sets the page name based on the selected MovieTitle. If no movie title exists,
* it will retain the existing page title (and navigation labels).
* It clears the URL Segment variable as the SiteTree::onBeforeWrite will determine a new url-segment
* based on the new page tile (which is the movie title).
*/
protected function onBeforeWrite()
{
if ($this->MovieTitle) {
$this->Title = $this->MovieTitle;
$this->URLSegment = '';
}
parent::onBeforeWrite();
}
示例7: onBeforeWrite
public function onBeforeWrite()
{
parent::onBeforeWrite();
$parent = $this->Parent();
if ($parent && $parent instanceof SummitPage && $parent->SummitID > 0) {
$this->SummitID = $parent->SummitID;
}
}
示例8: onBeforeWrite
function onBeforeWrite()
{
// Move to Photo Gallery Holder if created under something else
if ($this->Parent()->ClassName != "PhotoGalleryHolder" && PhotoGalleryHolder::get()->count() > 0) {
$this->ParentID = PhotoGalleryHolder::get()->first()->ID;
}
parent::onBeforeWrite();
}
示例9: onBeforeWrite
public function onBeforeWrite()
{
parent::onBeforeWrite();
// set the filing mode, now that it's being obsolete
if ($this->AutoFiling && !$this->FilingMode) {
$this->FilingMode = 'day';
$this->AutoFiling = false;
}
}
示例10: onBeforeWrite
/**
* Set firstWrite flag if this is the first time this Product is written.
*
* @see SiteTree::onBeforeWrite()
* @see Product::onAfterWrite()
*/
public function onBeforeWrite()
{
parent::onBeforeWrite();
if (!$this->ID) {
$this->firstWrite = true;
}
//Save in base currency
$shopConfig = ShopConfig::current_shop_config();
$this->Currency = $shopConfig->BaseCurrency;
}
示例11: onBeforeWrite
/**
* Creates a report template instance if one does not exist.
*/
protected function onBeforeWrite()
{
parent::onBeforeWrite();
if (!$this->ReportTemplateID && $this->ReportType && ClassInfo::exists($this->ReportType)) {
$template = Object::create($this->ReportType);
$template->Title = $this->Title;
$template->write();
$this->ReportTemplateID = $template->ID;
}
}
示例12: onBeforeWrite
/**
* When saving, check to see whether we should delete the
* listing source ID
*/
public function onBeforeWrite()
{
parent::onBeforeWrite();
if (!$this->ID) {
$this->Content = '$Listing';
}
if ($this->ClearSource) {
$this->ClearSource = false;
$this->ListingSourceID = 0;
}
}
示例13: onBeforeWrite
/**
* Make sure Geonetwork url ends with an /.
*/
function onBeforeWrite()
{
parent::onBeforeWrite();
$geoUrl = $this->GeonetworkBaseURL;
if (strlen($geoUrl) > 1) {
$geoUrlLen = strlen($geoUrl) - 1;
if ($geoUrl[$geoUrlLen] != '/') {
$this->GeonetworkBaseURL .= '/';
}
}
}
示例14: onBeforeWrite
/**
* The "default" structure used for this report when auto generating etc
*/
public function onBeforeWrite()
{
parent::onBeforeWrite();
if (!$this->ReportTemplateID && $this->ReportType && ClassInfo::exists($this->ReportType)) {
$template = Object::create($this->ReportType);
// create the template first. This is what all actual reports are based on when they're generated, either
// automatically or by the 'generate' button
$template->Title = $this->Title . ' Preview';
$template->write();
$this->ReportTemplateID = $template->ID;
}
}
示例15: onBeforeWrite
/**
* We have to change it to copy all the content from the original page first.
*/
function onBeforeWrite()
{
// Don't do this stuff when we're publishing
if (!$this->extension_instances['Versioned']->migratingVersion) {
if (isset($this->changed['CopyContentFromID']) && $this->changed['CopyContentFromID'] && $this->CopyContentFromID != 0 && $this instanceof VirtualPage) {
$source = DataObject::get_one("SiteTree", sprintf('`SiteTree`.`ID` = %d', $this->CopyContentFromID));
$this->copyFrom($source);
$this->URLSegment = $source->URLSegment . '-' . $this->ID;
}
}
parent::onBeforeWrite();
}