Showing posts with label Issues. Show all posts
Showing posts with label Issues. Show all posts

Wednesday, December 08, 2010

Treelist Not Registering Links in Sitecore


Greetings,

If you work with the Treelist field extensively like I do, you may notice that it is not registering links under certain conditions. You may experience this when search is not coming back with results, when working with Link Database, etc. Also the issue is happening when you have a complex source parameter passed to your treelist field on the template:

DataSource=/sitecore/content/Home&IncludeTemplatesForDisplay=PrimaryPage

Luckly, there are two solutions from our brilliant tech support.

1st option:
Add “databasename=master” attribute to every treelist field source:
DataSource=/sitecore/content/Home&IncludeTemplatesForDisplay=PrimaryPage&databasename=master

2nd option:
Override the Sitecore.Data.Fields.MultilistField class:

    1) Compile the following class and put the built assembly to the “/bin” folder:

public class MultilistField : MultilistField
{
    public MultilistField(Field innerField) : base(innerField) { }

    private Database GetDatabase()
    {
        string source = base.InnerField.Source;
        if (!string.IsNullOrEmpty(source))
        {
            if (!LookupSources.IsComplex(source))
            {
                return base.InnerField.Database;
            }
            Database database = LookupSources.GetDatabase(source);
            if (database != null)
            {
                return database;
            }
        }
        return base.InnerField.Database;
    }

    public override void ValidateLinks(LinksValidationResult result)
    {
        Database database = this.GetDatabase();
        if (database != null)
        {
            foreach (string str in base.Items)
            {
                if (ID.IsID(str))
                {
                    ID id = ID.Parse(str);
                    if (!ItemUtil.IsNull(id) && !id.IsNull)
                    {
                        Item targetItem = database.GetItem(id);
                        if (targetItem != null)
                        {
                            result.AddValidLink(targetItem, base.Value);
                        }
                        else
                        {
                            result.AddBrokenLink(base.Value);
                        }
                    }
                }
            }
        }
    }
}

2) Modify the \App_Config\FieldTypes.config file, specifically the Treelist field type definition:

<fieldType name="Treelist" type="Custom.MultilistField,Custom" />

Enjoy!

Monday, October 25, 2010

Undefined text in Page Editor when clearing field


Greetings!

You may be experiencing an issue with Page Editor in Sitecore 6.1/6.2 releases when clearing a field results in “Undefined” text being written back to your item.

To work this around, follow these 3 easy steps.

1. Locate the following file: <web root>\sitecore\shell\Applications\WebEdit\WebEditElement.js
Create a backup copy of it.

2. Find the following function: Sitecore.WebEdit.Element.prototype.load = function() and replace it with this:

Sitecore.WebEdit.Element.prototype.load = function() {
  if (this.element.getAttribute("scWatermark") == "true") {
    this.element.removeAttribute("scWatermark");
    this.watermarkHTML = this.element.innerHTML;
  }else
  {
  this.watermarkHTML = "[No text in field]";
  }
this.buttons.select(".scWebEditFrameButtonIcon").each(function(icon) {
    icon.observe("dragstart", function(e) { e.stop(); });
  });
  this.element.observe("click", this.onClick.bind(this));
  this.element.observe("blur", this.onBlur.bind(this));
}

3. Then locate this function: Sitecore.WebEdit.Element.prototype.isWatermark = function() {
and replace it with this:

Sitecore.WebEdit.Element.prototype.isWatermark = function() {
  fl=false;
  if((this.watermarkHTML == this.element.innerHTML)||(this.element.innerHTML=="[No text in field]"))
               {
               fl=true;
               }
  return fl;
}

Quick disclaimer: this proved working on my local 6.2.0 (rev. 100831) installation, however, this is not a fully tested solution, so there may be conflicts depending on exact version of your Sitecore instance and level of customization.

Thanks goes to Sitecore Customer Service for quick solution!

Wednesday, January 27, 2010

No such host is known


Real quick tip. Such error may appear when you DNS is down or unreachable. To fix this, add your hostname that is in the bindings for IIS website to the hosts file under C:\Windows\System32\drivers\etc, point it to the local IP and that that should help till the issue with DNS is resolved:
127.0.0.1      yoursite.com

Thursday, August 27, 2009

Favorites and Links not working


Just noticed a minor issue in 6.1 with Favorites and Links buttons from the Navigate tab not working.
To fix that, simply go to the “core” database and clear our the “command” field for both items:
/sitecore/content/Applications/Content Editor/Ribbons/Chunks/Navigate/Links
/sitecore/content/Applications/Content Editor/Ribbons/Chunks/Navigate/Favorites

Good that everything is so (re)configurable in Sitecore ;-)

Thursday, January 08, 2009

jQuery conflicts with PageEditor


There is such problem, indeed. It is caused by the conflict with Prototype.js that most of Page Editor, including designer and debugger uses. It can be simply worked around by overriding the $-function by calling "jQuery.noConflict()".
<script type="text/javascript" src="/js/jquery-1.2.6.js"></script>
 
<script type="text/javascript">
 
var $j = jQuery.noConflict();
 
      $j(document).ready(function() {
 
      });
 
</script>
More about that on the jQuery website.