Sitecore GetItemUrl() resolving to alias - sitecore

I've created an alias (basically a virtual (or alternative) path in Sitecore) for an item that was also re-named. My custom redirect handler is then determining the item ID for the old link correctly.
But when I call LinkManager.GetItemUrl(item, urlOptions) the resulting URL is for the alias, not the actual Sitecore item that exists in the content tree.
Is this Sitecore's default behavior for LinkManager.GetItemURL() to resolve to an item's alias, if one exists?

Here's a possibly related question with a solution.
Can you ensure you're not using a custom LinkProvider, e.g. the custom LinkProvider on the shared source? If you are using that, part of its behavior is to apply aliases for item links.
Another thing would be to look at your HTML output caching and ensure that's not the issue (as referenced in the above link for the other question).
Also, what version of Sitecore are you using?

Related

How do you do preloading of components

I would like to know how do you do pre-loading of components in sitecore 7.1?
What I tried so far:
Create a standard value for the page.
Then modify the presentation details of the standard value.
Then add components that I want preloaded in the page.
Then create a Branch for the page.
Use the Branch to create the page.
This works fine except when I add new components in the page's standard value, all existing page is affected with my changes.
What I need to know - is there away that the old page is not affected by my changes in the standard value?
Is there a way only the new page that I create is affected when I modify the pre-loading of components in my page?
Your input is appreciated.
There are few things one should consider:
If there current Sitecore installation is upgraded from 6.4 or prior version to your current version; the item's layout deltas might be an issue. You will have to check the raw values of the Layout details field and figure it out.
Any changes made on the Layout Details on Standard Values do get cascaded down to the items created from that specific Template.
If you don't want these changes to get inherited try multiple inheritance. And change the template of those items created.
Lastly, if the above doesn't work, try creating a new template with the changes you want and change the Template of those items created.
Hope the above helps. Share any further questions you might have or even if the above haven't answered your questions.
Happy Sitecoring!
The main purpose of __Standard Values is automatic update of existing items.
In this case, you should not configure the item's layout in the __Standard Values.
You need to use Branch and configure layout in the Page item instead of __Standard Values.

Sitecore global find and replace path?

Is there a way to globally replace a path to an item which has moved? For instance, if I have a module located at home/moldule/oldlocation and I move it to home/module/newlocation but, I know the oldlocation is used in 100 places, can I essentially do a find a replace?
It depends on how the item is being referenced. If those 100+ places reference it as an internal link (from within the WYSIWYG editor), or in reference fields (Treelist, Droplink, Droptree, etc.), then you don't have to find and replace anything. When using these types of links, Sitecore stores the item's GUID, and therefore the paths will be automatically updated when you move the target item.
There are a few cases in which you would need to update the paths, such as using a non-reference based field type (such as a Droplist), an external link entered into the WYSIWYG editor, or in a presentation component's Datasource field. In these cases, you can use the Search and Replace module and/or Sitecore Rocks to handle the searching and replacing.
You might want to have a look at using Sitecore Rocks Search and Replace functionality. You can refine the fields and templates to make the search really targeted.
There are some more details here
http://www.sitecore.net/unitedkingdom/Community/Technical-Blogs/Trevor-Campbell/Posts/2013/02/28-Days-of-Sitecore-Rocks-Hidden-Gems-Part-2.aspx

Search tags/facets in Sitecore Item Buckets

I'm looking to use the Sitecore Item Buckets package from Shared Source since I needed faceted search functionality and it makes sense to use the built in functionality rather than writing by own Lucene.Net search.
Sitecore Item Buckets
I'm having trouble with the search, or maybe I am reading the documentation wrong.
According to the documentation in section 2.2.3 & 3.1.3 I just need to mark a field as "Is Facet" and my filter will show in the search results.
I've also defined a tag field on the template and changed the Tag Parent field in "/sitecore/system/Modules/Item Buckets/Item Buckets Settings" to point to correct folder. This is working correctly, I can apply a set of tags to an item and search from the Bucket UI using "tag:CSharp" and it brings back the correct results, but again there is no filter shown in the list. I've rebuilt the bucket indexes in all cases.
Am I missing something? Should these show up in the list automatically, do I need to change some settings or provide my own implementation?
Screenshot
This is all within the Buckets Client UI, I haven't started writing any code yet, and on a clean install of Sitecore 6.5 (update-5/rev. 120706).
I'm not sure the documentation wording around this is entirely clear at the points I've mentioned. If you read further down the document though, section 4.3:
Item Buckets ships with 5 different types of faceting.
Templates
Fields
Dates
Locations
Authors
If you would like to introduce your own faceting categories then you only need to implement the IFacet interface.
There is an example of IFacet implementation in the documentation, or use dotPeek to look at the implementations of the existing Facets.
You also need to add an item to Sitecore: /sitecore/system/Modules/Item Buckets/Facets

Sitecore LinkManager.GetItemUrl() resolving to alias

I've created aliases for the home page of one of the local sites (and it's child pages) in my national website - and I can't figure out how this is happening.
When someone lands on a local page, I have a control (cs file) that creates the local links (to the child pages) on the left hand side of the local web page. These links are derived from the Sitecore context (current item's content path).
After I created the aliases for all of the pages in a local site, that's when I noticed this problem. If the URL is a Sitecore alias, the navigational links are built for the child aliases - otherwise they are resolved by the Sitecore LinkManager, just as they were before the aliases were created. However, when I hit a page for the original local item (not the alias), the links are being rendered for the alias:
childLink.NavigateUrl = LinkManager.GetItemUrl(child);
And I've verified that the child item is valid. Does anyone have any suggestions as to why the LinkManager would be rendering the links for the aliases - and how this can be avoided?
Sitecore.Links.LinkManager.GetItemUrl(item) returns the path to the original item, not the alias path. If you have special logic to identify aliases, for example by using the Sitecore.Context.RawUrl property, you may be running into an issue with output caching, which could be causing the alias version of the control to be displayed when you navigate to the original item.
Update: I'm pretty sure you are running into an output caching issue. I was able to reproduce this behavior by creating a test control, which displays a timestamp and the RawUrl, and by turning on output caching for the control in Presentation Details.
The first time the control is displayed, whether it is for the item or the alias, the output is cached, and this cached output is displayed each time the control is viewed, either for the original item or the alias. Even if you switch on "Vary By Data", the effect is the same, because "Vary By Data" is driven by the Data Source item, not the URL.
To fix this behavior, you need to add the cached state to the output of the GetCachingId property:
protected override string GetCachingID()
{
return this.GetType().Name + (IsAlias() ? "Alias": "Item");
}
private bool IsAlias()
{
return Sitecore.Context.Database.Aliases.Exists(Sitecore.Context.RawUrl);
}
Props to this answer for the IsAlias logic.
In this case, wheter or not the Alias will be given relies on a setting in the web.config.
If the LinkManager has the option "ApplyAliases" (Whether or not to check for and apply aliases when possible) set to true, the LinkManager will return aliases when possible.
You can read more about configuring your LinkManager, and overriding certain settings in codebehind on this blog page written by John West.
Good luck!

How to look up the document library in its local sub site where used, rather than in the root site?

I have a content type that has a lookup field for a document library in its sub site. The content type is declared a site collection root level but I want the look up field to look up the document library in its local sub site where used. I deploy the content types using PowerShell and have used an event receiver to add the look up field. I can't however get it to reference the correct list, it only ever references the list at the root site collection.
How can I overwrite the look up list?
I avoid setting the List attribute in the Field element. I have had problems saving the site as a template when a custom Field has the List attribute set. But the other problem is that these properties are write-once. Better to leave it blank in the definition and then set it in the instance programmatically using SPFieldLookup.LookupWebId and SPFieldLookup.LookupList.