Giter Site home page Giter Site logo

Fatal error: Call to a member function getURLPrefix() on null in /var/www/html/languageprefix/code/LanguagePrefix.php on line 203 about silverstripe-languageprefix HOT 8 CLOSED

martimiz avatar martimiz commented on August 14, 2024
Fatal error: Call to a member function getURLPrefix() on null in /var/www/html/languageprefix/code/LanguagePrefix.php on line 203

from silverstripe-languageprefix.

Comments (8)

Martimiz avatar Martimiz commented on August 14, 2024 1

Ok - can't look at it right away but will try this weekend

from silverstripe-languageprefix.

Martimiz avatar Martimiz commented on August 14, 2024

Hmm that shouldn't happen. Can you tell me which versions of CMS, Translatable and LanguagePrefix you are using?

from silverstripe-languageprefix.

tscole avatar tscole commented on August 14, 2024

Language Prefix 2.0
Translatable 2.2
CMS 3.5.0

prefixconfig:
locale_prefix_map:
'en_US': us
'en_GB': uk
'es_ES': es
'en_ZA': za
'en_AU': au
enable_duplicate_urlsegments: true
disable_prefix_for_default_lang: false

from silverstripe-languageprefix.

Martimiz avatar Martimiz commented on August 14, 2024

OK, just had a look anyway, but I couldn't reproduce it:

silverstripe 3.5.0
translatable 2.2.3
languageprefix tagged versions v2.0.0 Γ‘nd v3.0.0 (preferred)
mysql 5.6.35
php 5.6.30

I did: default site en_US
Went to settings, created translation en_UK.
Then back to pages, created translation en_UK for home.
Jumped back and forth, no issues...

from silverstripe-languageprefix.

tscole avatar tscole commented on August 14, 2024

My default translation in en_GB incase that matters?
Could be something in my database or site config extension?

`class CustomConfig extends DataExtension {

private static $db = array(
    'FormattedSiteName' => 'HTMLText',
    'Contact_Email' => 'Varchar(250)',
    'CdnUrl' => 'Varchar(250)',
    'TwitterID' => 'Varchar(250)',
    'FacebookLink' => 'Varchar(250)',
    'YoutubeID' => 'Varchar(250)',
    'InstagramID' => 'Varchar(250)',
    'InstagramAccountNumber' => 'Varchar(250)',
    'InstagramAccessToken' => 'Varchar(250)',
    'SpotifyID' => 'Varchar(250)',
    'FooterSocial' => 'Varchar(250)',
    'EmailNotification' => 'Varchar(100)',
    'LicensingLink' => 'Varchar(100)',
    'FooterText' => 'HTMLText',
    'CopyrightLine' => 'Varchar(250)',
    'AutoTranslateContent' => 'Boolean',
    'TimeZoneOffsetType' => 'Enum("Disabled,Ahead,Behind","Disabled")',
    'TimeZoneOffsetValue' => 'Varchar(10)'
);

private static $has_one = array(
    'SiteLogo' => 'Image',
    'FooterLogo' => 'Image'
);

public function updateCMSFields(FieldList $fields) {
    $fields->addFieldToTab("Root.Main", new TextField("FormattedSiteName", "Site name with formatting (wrap alternate words with <span> tags)"));
    $fields->addFieldToTab("Root.Main", new TextField("Contact_Email", "Contact Email"));
    $fields->addFieldToTab("Root.Main", new TextField("EmailNotification", "Email for comment notifications"));
    $fields->addFieldToTab("Root.Main", new TextField("LicensingLink", "Link for licensing enquiries"));
    $fields->addFieldToTab("Root.SocialMedia", new TextField("TwitterID", "Twitter ID"));
    $fields->addFieldToTab("Root.SocialMedia", new TextField("FacebookLink", "Facebook Link"));
    $fields->addFieldToTab("Root.SocialMedia", new TextField("YoutubeID", "Youtube ID"));
    $fields->addFieldToTab("Root.SocialMedia", new TextField("InstagramID", "Instagram ID"));
    $fields->addFieldToTab("Root.SocialMedia", new TextField("InstagramAccountNumber", "Instagram Account Number (this is not the same as user id)"));
    $fields->addFieldToTab("Root.SocialMedia", new TextField("InstagramAccessToken", "Instagram Access Token (this must be generated from Instagram API)"));
    $fields->addFieldToTab("Root.SocialMedia", new TextField("SpotifyID", "Spotify ID"));
    $fields->addFieldToTab("Root.SocialMedia", new TextField("FooterSocial", "Footer Social Label"));
    $fields->addFieldToTab("Root.Main", new TextField("CdnUrl", "Content Delivery Network URL"));

    $fields->addFieldToTab('Root.Main', new DropdownField(
		  'TimeZoneOffsetType',
		  'Time Zone Relative to UTC',
		  singleton('SiteConfig')->dbObject('TimeZoneOffsetType')->enumValues()
			));
		$fields->addFieldToTab("Root.Main", new TextField("TimeZoneOffsetValue", "Time Zone Offset from UTC in HH:MM format (e.g. 8:30)"));

    $fields->addFieldToTab("Root.Main", new TextField("CopyrightLine", "Site Copyright Line (Do not include &copy;)"));
    $fields->addFieldToTab("Root.Main", new HTMLEditorField("FooterText", "Links to terms, conditions, privacy policy and other legal documents."));
    $fields->addFieldToTab("Root.Main", new CheckboxField("AutoTranslateContent", "Automatically translate content via Google Translate"));

    $fields->addFieldToTab('Root.Main', $siteLogoUploadField = new UploadField('SiteLogo','Site Logo'));
    $fields->addFieldToTab('Root.Main', $footerLogoUploadField = new UploadField('FooterLogo','Footer Logo'));

    $config = SiteConfig::get()->filter('Locale', Translatable::get_current_locale())->first();

    $siteLogoUploadField->setFolderName('themes/' . $config->Theme . '/' . str_replace('_', '-', Translatable::get_current_locale()) . '/');
    $siteLogoUploadField->getValidator()->setAllowedExtensions(array('jpg', 'png', 'jpeg', 'gif'));

    $footerLogoUploadField->setFolderName('themes/' . $config->Theme . '/' . str_replace('_', '-', Translatable::get_current_locale()) . '/');
    $footerLogoUploadField->getValidator()->setAllowedExtensions(array('jpg', 'png', 'jpeg', 'gif'));

}

}`

from silverstripe-languageprefix.

Martimiz avatar Martimiz commented on August 14, 2024

Did you possibly add LanguagePrefix as an extension to SiteConfig? Because that would give that error, and you shouldn't have to do that anyway...

from silverstripe-languageprefix.

tscole avatar tscole commented on August 14, 2024

Yes, looks like I have:

SiteConfig: extensions: - LanguagePrefix - CustomConfig

I will try removing that. Wonder why I did it... :)

from silverstripe-languageprefix.

tscole avatar tscole commented on August 14, 2024

Yep - you got it! Removed that and things seem to be working. I guess it's possible that crept in there by mistake during a merge conflict or something.

Many thanks for you help!

from silverstripe-languageprefix.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.