本文整理汇总了PHP中RootURLController::get_default_homepage_link方法的典型用法代码示例。如果您正苦于以下问题:PHP RootURLController::get_default_homepage_link方法的具体用法?PHP RootURLController::get_default_homepage_link怎么用?PHP RootURLController::get_default_homepage_link使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RootURLController
的用法示例。
在下文中一共展示了RootURLController::get_default_homepage_link方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getHomepageCurrLang
public function getHomepageCurrLang()
{
// @TODO: make this translatable compatible;
//return $this->owner->get_homepage_link_by_locale($this->owner->get_current_locale());
return SiteTree::get_by_link(RootURLController::get_default_homepage_link());
}
示例2: get_homepage_link_by_locale
/**
* Get the RelativeLink value for a home page in another locale. This is found by searching for the default home
* page in the default language, then returning the link to the translated version (if one exists).
*
* @return string
*/
public static function get_homepage_link_by_locale($locale)
{
$originalLocale = self::get_current_locale();
self::set_current_locale(self::default_locale());
$original = SiteTree::get_by_link(RootURLController::get_default_homepage_link());
self::set_current_locale($originalLocale);
if ($original) {
if ($translation = $original->getTranslation($locale)) {
return trim($translation->RelativeLink(true), '/');
}
}
}
示例3: get_homepage_link_by_locale
/**
* Get the RelativeLink value for a home page in another locale. This is found by searching for the default home
* page in the default language, then returning the link to the translated version (if one exists).
*
* @return string
*/
public static function get_homepage_link_by_locale($locale)
{
$deflink = RootURLController::get_default_homepage_link();
if ($locale == Translatable::default_locale()) {
return $deflink;
}
$original = SiteTree::get_by_link($deflink);
if (!empty($original)) {
$homepage = $original->getTranslation($locale);
if (empty($homepage)) {
$homepage = SiteTree::get()->filter(array('Locale' => $locale))->First();
}
if (!empty($homepage)) {
return $homepage->URLSegment;
}
}
return '';
}
示例4: updateCMSFields
/**
* standard SS method
* @var Array
**/
public function updateCMSFields(FieldList $fields)
{
//separate MetaTitle
if (Config::inst()->get("MetaTagsContentControllerEXT", "use_separate_metatitle") == 1) {
$fields->addFieldToTab('Root.Main.Metadata', $allowField0 = new TextField('MetaTitle', _t('SiteTree.METATITLE', 'Meta Title')), "MetaDescription");
$allowField0->setRightTitle(_t("SiteTree.METATITLE_EXPLANATION", "Leave this empty to use the page title"));
}
//info about automation
$fields->addFieldToTab('Root.Main.Metadata', $allowField1 = new CheckboxField('AutomateMetatags', _t('MetaManager.UPDATEMETA', 'Automatically update Meta Description and Navigation Label? ')));
$automatedFields = $this->updatedFieldsArray();
$updatedFieldString = "";
if (count($automatedFields)) {
$updatedFieldString = "" . _t("MetaManager.UPDATED_EXTERNALLY", "Based on your current settings, the following fields will be automatically updated at all times") . ": <em>" . implode("</em>, <em>", $automatedFields) . "</em>.";
foreach ($automatedFields as $fieldName => $fieldTitle) {
$oldField = $fields->dataFieldByName($fieldName);
if ($oldField) {
$newField = $oldField->performReadonlyTransformation();
//$newField->setTitle($newField->Title());
$newField->setRightTitle(_t("MetaTags.AUTOMATICALLY_UPDATED", "Automatically updated when you save this page (see metadata settings)."));
$fields->replaceField($fieldName, $newField);
}
}
}
$fields->removeByName('ExtraMeta');
$linkToManager = Config::inst()->get("MetaTagCMSControlPages", "url_segment") . '/';
$fields->addFieldToTab('Root.Main.Metadata', new LiteralField("LinkToManagerHeader", "<blockquote style='padding-left: 12px;'>\n\t\t\t\t\t<p>\n\t\t\t\t\t\tOpen the Meta Tag Manager to\n\t\t\t\t\t\t<a href=\"{$linkToManager}\" target=\"_blank\">Review and Edit</a>\n\t\t\t\t\t\tthe Meta Data for all pages on this site.\n\t\t\t\t\t\tAlso make sure to review the general settings for\n\t\t\t\t\t\t<a href=\"/admin/settings/\">Search Engines</a>. {$updatedFieldString}\n\t\t\t\t\t</p>\n\t\t\t\t</blockquote>"));
if ($this->owner->URLSegment == RootURLController::get_default_homepage_link()) {
$newField = $fields->dataFieldByName('URLSegment');
$newField->setRightTitle("Careful: changing the URL from 'home' to anything else means that this page will no longer be the home page");
$fields->replaceField('URLSegment', $newField);
}
return $fields;
}
示例5: requireDefaultRecords
/**
* Add default records to database.
*
* This function is called whenever the database is built, after the
* database tables have all been created. Overload this to add default
* records when the database is built, but make sure you call
* parent::requireDefaultRecords().
*/
function requireDefaultRecords() {
parent::requireDefaultRecords();
// default pages
if($this->class == 'SiteTree' && self::get_create_default_pages()) {
if(!SiteTree::get_by_link(RootURLController::get_default_homepage_link())) {
$homepage = new Page();
$homepage->Title = _t('SiteTree.DEFAULTHOMETITLE', 'Home');
$homepage->Content = _t('SiteTree.DEFAULTHOMECONTENT', '<p>Welcome to SilverStripe! This is the default homepage. You can edit this page by opening <a href="admin/">the CMS</a>. You can now access the <a href="http://doc.silverstripe.org">developer documentation</a>, or begin <a href="http://doc.silverstripe.org/doku.php?id=tutorials">the tutorials.</a></p>');
$homepage->URLSegment = RootURLController::get_default_homepage_link();
$homepage->Sort = 1;
$homepage->write();
$homepage->publish('Stage', 'Live');
$homepage->flushCache();
DB::alteration_message('Home page created', 'created');
}
if(DB::query("SELECT COUNT(*) FROM \"SiteTree\"")->value() == 1) {
$aboutus = new Page();
$aboutus->Title = _t('SiteTree.DEFAULTABOUTTITLE', 'About Us');
$aboutus->Content = _t('SiteTree.DEFAULTABOUTCONTENT', '<p>You can fill this page out with your own content, or delete it and create your own pages.<br /></p>');
$aboutus->Sort = 2;
$aboutus->write();
$aboutus->publish('Stage', 'Live');
$aboutus->flushCache();
DB::alteration_message('About Us page created', 'created');
$contactus = new Page();
$contactus->Title = _t('SiteTree.DEFAULTCONTACTTITLE', 'Contact Us');
$contactus->Content = _t('SiteTree.DEFAULTCONTACTCONTENT', '<p>You can fill this page out with your own content, or delete it and create your own pages.<br /></p>');
$contactus->Sort = 3;
$contactus->write();
$contactus->publish('Stage', 'Live');
$contactus->flushCache();
DB::alteration_message('Contact Us page created', 'created');
}
}
// schema migration
// @todo Move to migration task once infrastructure is implemented
if($this->class == 'SiteTree') {
$conn = DB::getConn();
// only execute command if fields haven't been renamed to _obsolete_<fieldname> already by the task
if(array_key_exists('Viewers', $conn->fieldList('SiteTree'))) {
$task = new UpgradeSiteTreePermissionSchemaTask();
$task->run(new SS_HTTPRequest('GET','/'));
}
}
}
示例6: updateRelativeLink
public function updateRelativeLink(&$base, &$action)
{
if ($base == RootURLController::get_default_homepage_link()) {
$base = '';
}
}