Wednesday, August 24, 2011

Partial Language Fallback Module Update


Today I pushed a small update to the Partial Language Fallback module which I introduced a while back. Check out this quick screencast below. For the full list of changes hit “read more”.
image

Included changes:
  • Instead of weird looking yellow valid bar that is meant to highlight a fallback field value is now deprecated in favor of a much better integrated label next to the field title:
image
  • Default configuration changes:
    • The “enableFallback” parameter on the "website" is now set to “true” by default
    • renderContentEditor pipeline changes for the grayed out label to work.
  • Fixed a problem with fallback values picked up from SV when fallback item had no versions (thanks Steve)
  • Misc code refactoring
  • Sitecore package for 6.4 is now included. Thanks Nick!
Enjoy!

26 comments:

Zac said...

Hey Alex,

I upgraded a sitecore instance with this new version. I however still see the yellow validation bar for fallback allongside the new format of fallback. How do I go about removing the old fallback yellow bar?

thanks,

Zac

Unknown said...

Hey Zac,

Thanks for trying it out.

You can get rid of it by deleting the following item from the master database (remove all links connected to it as well):
sitecore\system\Settings\Validation Rules\Field Rules\Fallback Value

Alex

Zac said...

Thanks Alex. That did the trick!

Marcia D said...

Alex,

We are using Sitecore 6.5 and have previously installed language fallback. It is fabulous! Now, we would like to apply this update. Are there any issues installing the package (since it's specifically 6.4) on 6.5? What about the DB serialization items? Thanks for this module and your help,
Marcia

Jamie said...

Hello Alex,

I have just installed the Fallback module on our Sitecore 6.5 envirnoment. After enabling the fallback on a template the Validator Bar for every field says '{*itemid*}[Item not found]' and when edditing an item based on this template I don't see the '[fallback value]' message next to an empty field.

Note: the fallback-mechanism itself does work.

Regards,

Jamie.

Elisabeth Pagels said...

This module really looks great!
When do you think this will be available in versjon 6.5?

Alinas cooking said...

Hi Alex,
Link for above video is broken.

Yaakov said...

I have reviewed your great customization about 10 times. I would like to implement a part of it ++ not the whole thing as I would like to keep as much as possible a vanilla copy of sitecore 6.5 -- in other words to use customization as an add on without touching the baseline. How would you recommend? I would simply like to per language specify ONCE per language which other language (or none) should be the fallback,....

Kumar Animesh said...

Hey Alex,

I am using SiteCore 6.4.1 with your Partial Language Fallback Module. While trying to edit a Presentation, I get an Object Reference Exception. Stacktrace for the same is reproduced verbatim below:

[NullReferenceException: Object reference not set to an instance of an object.]
Sitecore.SharedSource.PartialLanguageFallback.Shell.FallbackEditorFormatter.RenderLabel(Control parent, Field field, Item fieldType, Boolean readOnly) in C:\Projects\PartialLanguageFallback\Shell\EditorFormatter.cs:48
Sitecore.SharedSource.PartialLanguageFallback.Shell.FallbackEditorFormatter.RenderField(Control parent, Field field, Boolean readOnly) in C:\Projects\PartialLanguageFallback\Shell\EditorFormatter.cs:36
Sitecore.Shell.Applications.ContentEditor.EditorFormatter.RenderSection(Section section, Control parent, Boolean readOnly) +348
Sitecore.Shell.Applications.ContentEditor.EditorFormatter.RenderSections(Control parent, Sections sections, Boolean readOnly) +178
Sitecore.SharedSource.PartialLanguageFallback.Pipelines.RenderContentEditor.RenderStandardContentEditor.Process(RenderContentEditorArgs args) in C:\Projects\PartialLanguageFallback\Pipelines\RenderContentEditor\RenderContentEditor.cs:19
(Object , Object[] ) in C:\Projects\PartialLanguageFallback\Validators\FallbackValidator.cs:22
Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +190
Sitecore.Shell.Applications.ContentManager.Editor.Render(RenderContentEditorArgs args, Control parent) +533
Sitecore.Shell.Applications.ContentManager.FieldEditorForm.RenderEditor(Border parent) +304
Sitecore.Shell.Applications.ContentManager.FieldEditorForm.UpdateEditor() +162
Sitecore.Shell.Applications.ContentManager.FieldEditorForm.OnPreRendered(EventArgs e) +36

The error was specifically for the following URL:

http://sitecore/sitecore/shell/applications/field%20editor.aspx?mo=mini&hdl=8F9A1930BB524347BA574952C51BF117.

Can you provide any pointers on how to fix the same?

Thanks,
Animesh

Unknown said...

Animesh,

I reproduced it on the previous version but the latest from Shared Source lib seems to fix it.

Please try getting the latest and see if the issue goes away.

Unknown said...

Alex,
We've been having an issue with the fallback module. For some reason it stopped falling back in Web. We remember it working and now it's not.


I am running the PartialLanguageFallback from the source code because we were getting another issue with Logging. After the site runs a while it loses the reference to HttpContext.Current and when PartialLanguageFallback is checking for HttpContext.Current.IsDebuggingEnabled we were getting a "Object reference not set to an instance of an object" error online 10 of LogUtil.cs.

FYI, I changed this to:
private LogUtil() { Enabled = HttpContext.Current == null ? false : HttpContext.Current.IsDebuggingEnabled; })

But we are still unsure of the cause of the context error. We think it may have something to do with the Lucene index or another background process without context trying to access an items that's falling back. Though once it starts happening it happens until we restart IIS. But this is another issue.


When looking into it I noticed that in the FieldExtensions class when uses the method HasInnerFieldValue, it grabs the fields on the template field in question to see if "EnableFallbackIfConfigured" is set to "1".

When using the Content Editor on Master or viewing the site in Preview Mode the innerItem object (on line 25 of FieldExtensions.cs) has 13 fields associated with it, including "EnableFallbackIfConfigured" (referenced by GUID {705E1FF8-C1F6-4E90-A8B9-17EC5CC28365}). This is for the Spanish Version, as the English version doesn't call this code (because it doesn't fallback to anything on the Language item under System).

When using the Content Editor on Web or viewing the site in Live Mode the innerItem object (on line 25 of FieldExtensions.cs) has 3 fields associated with it, and doesn't include "EnableFallbackIfConfigured" (referenced by GUID {705E1FF8-C1F6-4E90-A8B9-17EC5CC28365}). This is for the Spanish Version. This is for the Spanish Version, as the English version doesn't call this code (because it doesn't fallback to anything on the Language item under System).

We ran the query that's behind "GetItem" from a SQL Profiler trace and it seems to be returning the same information whether I run it against Web or Master.

Then I noticed that on line 18 of FieldExtensions.cs we are passing the field.Language to the GetItem. I decided to test this method with different languages and on Master/Preview mode when passing English instead of Spanish to see what's returned. On Master it returns 13 and on Web it returns 13.

So to sum up:
Master/Preview Mode Spanish: 13 fields including "EnableFallbackIfConfigured"
Master/Preview Mode English: 13 fields including "EnableFallbackIfConfigured"
Web/Live Mode Spanish: 3 fields including "EnableFallbackIfConfigured"
Web/Live Mode English: 13 fields including "EnableFallbackIfConfigured"

I can't find any reason why the Web/Live Mode Spanish wouldn't return all the fields, especially since the data is the same (I did a comparison of VersionFields, UnversionedFields and SharedFields).

Let me know if you need anymore information. Thanks in advance for your help.

Unknown said...

Alex,
We've been having an issue with the fallback module. For some reason it stopped falling back in Web. We remember it working and now it's not.


I am running the PartialLanguageFallback from the source code because we were getting another issue with Logging. After the site runs a while it loses the reference to HttpContext.Current and when PartialLanguageFallback is checking for HttpContext.Current.IsDebuggingEnabled we were getting a "Object reference not set to an instance of an object" error online 10 of LogUtil.cs.

FYI, I changed this to:
private LogUtil() { Enabled = HttpContext.Current == null ? false : HttpContext.Current.IsDebuggingEnabled; })

But we are still unsure of the cause of the context error. We think it may have something to do with the Lucene index or another background process without context trying to access an items that's falling back. Though once it starts happening it happens until we restart IIS. But this is another issue.


When looking into it I noticed that in the FieldExtensions class when uses the method HasInnerFieldValue, it grabs the fields on the template field in question to see if "EnableFallbackIfConfigured" is set to "1".

When using the Content Editor on Master or viewing the site in Preview Mode the innerItem object (on line 25 of FieldExtensions.cs) has 13 fields associated with it, including "EnableFallbackIfConfigured" (referenced by GUID {705E1FF8-C1F6-4E90-A8B9-17EC5CC28365}). This is for the Spanish Version, as the English version doesn't call this code (because it doesn't fallback to anything on the Language item under System).

When using the Content Editor on Web or viewing the site in Live Mode the innerItem object (on line 25 of FieldExtensions.cs) has 3 fields associated with it, and doesn't include "EnableFallbackIfConfigured" (referenced by GUID {705E1FF8-C1F6-4E90-A8B9-17EC5CC28365}). This is for the Spanish Version. This is for the Spanish Version, as the English version doesn't call this code (because it doesn't fallback to anything on the Language item under System).

We ran the query that's behind "GetItem" from a SQL Profiler trace and it seems to be returning the same information whether I run it against Web or Master.

Then I noticed that on line 18 of FieldExtensions.cs we are passing the field.Language to the GetItem. I decided to test this method with different languages and on Master/Preview mode when passing English instead of Spanish to see what's returned. On Master it returns 13 and on Web it returns 13.

So to sum up:
Master/Preview Mode Spanish: 13 fields including "EnableFallbackIfConfigured"
Master/Preview Mode English: 13 fields including "EnableFallbackIfConfigured"
Web/Live Mode Spanish: 3 fields including "EnableFallbackIfConfigured"
Web/Live Mode English: 13 fields including "EnableFallbackIfConfigured"

I can't find any reason why the Web/Live Mode Spanish wouldn't return all the fields, especially since the data is the same (I did a comparison of VersionFields, UnversionedFields and SharedFields).

Let me know if you need anymore information. Thanks in advance for your help.

ren'a said...

Hi Alex.

Your module is really fine! I'm wondering if it would be possible to fallback the Layout Details with this module as well. We would like to have like two sites. The first one - a global one - will define the data as well as the presentation. These are some kind of defaults. The second one - site for specific market - will keep the translations and optionally the presentation data as well. The goal is to allow create a market specific presentation in the selected market site.
Of course, this approach requires to 'unshare' __Renderings field from the Standard Template. Then I would suppose by enabling fallback on this field we should rich the goal. Unfortunately, I couldn't accomplish this... The problem is that the __Renderings field always contains some value (even if it's 'empty'). Alex, should the fallback work for the __Renderings field as well? Thank you in advance,

rene

ma said...

Hi Alex,

Thanks for a great module!

I've found a problem in the FallbackLanguageProvider class affecting remote publishing.

The InitializeEventHandlers method binds the PublishEndRemoteEvent to ClearFallbackCaches with null as ItemUri. That causes a null exception and the cache doesn't clear properly on CD servers.

The code in ClearFallbackCaches should be something like this instead:

if (cache != null) {
  if (itemUri == null)
    cache.Clear();
  else
    cache.RemoveKeysContaining(itemUri.ItemID.ToString());
}
if (ignore_cache != null) {
  if (itemUri == null)
    ignore_cache.Clear();
  else
    ignore_cache.RemoveKeysContaining(itemUri.ItemID.ToString());
}

/ Mikael

Unknown said...

It appears no one has posted here in a while, but I don't see anywhere else to bring up this issue. We are using the PartialLanguageFallback module, and it works well, but is causing a failure about every day or two which requires an IIS recycle to remedy.

I am getting a System.NullReferenceException: Object reference not set to an instnace of an object error.

The stack trace shows:

[NullReferenceException: Object reference not set to an instance of an object.]
Sitecore.SharedSource.PartialLanguageFallback.Utilities.LogUtil..ctor() +66
Sitecore.SharedSource.PartialLanguageFallback.Utilities.LogUtil..cctor() +61

[TypeInitializationException: The type initializer for 'Sitecore.SharedSource.PartialLanguageFallback.Utilities.LogUtil' threw an exception.]
Sitecore.SharedSource.PartialLanguageFallback.Utilities.LogUtil.get_Instance() +0
Sitecore.SharedSource.PartialLanguageFallback.Providers.FallbackLanguageProvider.Initialize(String name, NameValueCollection config) +82
...

Not quite the same error that I see listed above. I have the shared source, so I can make a correction if needed. Has anyone run into this before? Our first global site in Sitecore is pushing out soon, and I would like to have this resolved before then. Thanks for any assistance.

-Anthony

Unknown said...

Hi Anthony,

I think you can safely remove the LogUtil and rebuild. Not sure why it throws null reference.

Let me know if it does not help.

Unknown said...

Thanks, Mikael.

Great catch. I will add this to the codebase.

Unknown said...

rene,

I realize this is too late to respond, but the story with the layout field unsharing is more complicated. PLF is not enough to solve this. I will be looking into this again soon, but for now I could not find a graceful solution. Consider leveraging personalization rules for the time being.

Unknown said...

Alex,

Thanks, I did rebuild the solution and the LogUtil error has stopped occurring. Now I have another issue. Although the config file lists master|web for Supported Databases, whenever I publish, it is not pushing the fallback fields to Web. Only items on the version that I have set manually. I'm sure I'm missing something simple, but I don't have much time to find it. Any ideas?

Unknown said...

Alex,

Thanks, I did rebuild the solution and the LogUtil error has stopped occurring. Now I have another issue. Although the config file lists master|web for Supported Databases, whenever I publish, it is not pushing the fallback fields to Web. Only items on the version that I have set manually. I'm sure I'm missing something simple, but I don't have much time to find it. Any ideas?

Unknown said...

First thing to double check if its the cache. Does iisreset help?
Then, are you running single server?

Unknown said...

The fallback values are not expected to be published.Also check if the values are resolved in CE by switching to web directly

Unknown said...

Alex,

Thanks for the quick response. The issue is the in CE, on Master, I create a new language version, the fields I set to fallback pre-populate, and I edit say 2 fields that need some change. When I save and publish that item, on the Web database, only the fields I changed show up. On the actually site, any of the fields were I was leaving the fallback values are left blank. Looking at the Web database in the CE confirms this.

Our setup is 1 CM server behind the firewall with 2 CD servers, all sharing the same SQL databases. There's also a DR CM/CD server in another location that the local CM server publishes to.

Amin J said...

Alex,

Were you able to resolve this issue. We are running into this issue now, and we can't figure out what's causing it. We have removed the LogUtil class from the FallbackProvider solution, and I am not seeing any other references that call LogUtil method, but for some reason our Sitecore installation (CE) site throws the same error as yours out of no where. If I reset the application pool or IIS in the server, everything goes back to normal. It's a very strange error that we don't know what's causing it, any help would be appreciated.

Amin J said...

Alex,

Were you able to resolve this issue. We are running into this issue now, and we can't figure out what's causing it. We have removed the LogUtil class from the FallbackProvider solution, and I am not seeing any other references that call LogUtil method, but for some reason our Sitecore installation (CE) site throws the same error as yours out of no where. If I reset the application pool or IIS in the server, everything goes back to normal. It's a very strange error that we don't know what's causing it, any help would be appreciated.

wpmt said...

I am setup up a site to demo this module, the aim is to have a common example.com domain with in this case 3 versions of english,
example.com/en
example.com/en-gb
example.com/en-au. I have use the module before with unique host names but never with the above setup. I have tried a few variations on the config without any luck, do you have a example you could post?