Get item by Displayname using fast query in Sitecore 8.1 - sitecore

I have created a vanilla sitecore 8.1 MVC instance and trying to get home item by displayname using fast query but getting null value:
Do I need to do any configuration settings in web.config.I am passing "Home" in this function.
I have set useDisplayName="true" attribute in <LinkManager> element in Sitecore.config file also.
Thanks

You may need to query the field by its name with a lowercase "n":
fast:/sitecore/content//*[#__Display name='{0}']

Related

Odoo 14 : element '<xpath expr="//*[hasclass('o_footer_copyright_name')]">' cannot be located in the parent view

I migrate from odoo 13 to odoo 14, but when I import all this; My website has an error like :
load could not load template
ValueError: The element '<xpath expr="//*[hasclass('o_footer_copyright_name')]">' could not be located in the parent view
View name: Footer Language Selector
Error context:
view: ir.ui.view(3822,)
view.parent: ir.ui.view(2094,)
Template: 1816
Path: /t/t
An error occurred while rendering template 1816
I didn't edited this view btw.
If anyone has a solution I'm interested!
Thanks by advance !
I experienced the same issue while upgrading from Odoo Enterprise 13 to 14.
Note the following points:
The Release Notes (https://www.odoo.com/odoo-14-release-notes) state:
"Add the language selector in the header and customize the layout."
There is a new view added called 'Footer Language Selector' (Key:
portal.footer_language_selector). This appears to be added while
running the Odoo DB upgrade 13 > 14.
The 'Footer Language Selector' view is not created when setting up a new
Odoo 14 database!
To resolve your issue, you need to disable the 'Footer Language Selector' view. This can be done in one of two ways:
If you are logged in to your Odoo instance, enable Developer Mode, and go to Settings > Technical > User Interface > Views and search for 'Footer Language Selector'. Select the view, and then select the menu option to 'Archive'
If you are not logged in/not able to log in, you need to disable the view in the database directly. Here is the command that will disable the view: UPDATE public.ir_ui_view SET active = false WHERE id = 3822; NOTE: the 'id = 3822' value must match the view number in the error: ir.ui.view(3822,)
I hope this helps you resolve the issue which appears to be a bug introduced by the Odoo DB update tool.

How to correctly insert managed metadata term id using spservices updatelistitems

I have a sharepoint 2013 site that uses a managed metadata term set for navigation. Documents can be tagged with the managed metadata so they appear in whatever category or categories is appropriate for the document. I need to allow documents to be saved as favorites. I created a custom list that saves the file name and path but I can't get the managed metadata settings to save correctly. I am using spservices.UpdateListItems via javascript and pass the ids and terms in the valuepairs property of the call like so ;#. Although the method saves the record, it either does not save the term or it saves one completely unrelated. Does anyone have any further advice on how to do this?
$().SPServices({
operation: "UpdateListItems",
async: true,
batchCmd: "New",
listName: "UserFavorites",
valuepairs: [["Title", title], ["DocumentId", itemid],["AssetCategory", assetCategoriesString]],
completefunc: function (xData, Status) {
alert(Status + " -- " + xData.responseText);
}
});
Example of the assetCategoriesString variable contents:
"fc8d083a-fc5e-4525-8fef-04ba982d1633;#Print Publications"

Magento2 : Update category, URL key already exists error

I have created a new category and its not visible in navigation menu as of now.
I am adding products to it via code and its working.
Now i am editing the category to show in navigation menu, it throws error as "URL key for specified store already exists".
I tried to:
Unassigned products, throws same error.
Changed URL, left blank or changed value of URL.
Please let me know.
Clear db table url_rewrite but! for categories only. otherwise it will mess with CMS pages links.
After doing this error should be gone.
1) delete records from "url_rewrite" where entity_type is "category"
2) run php bin/magento php bin/magento indexer:reindex
1) Going your Database
2) Search the url_rewrite and "category" entity_type is Remove
3) And Finally run this command, php bin/magento indexer:reindex
I had the same problem.
Temporarily rename the category URL to something else, clear the cache and rename it to the original URL you had before.

How to disable Sitecore WFFM custom fields caching

I have a custom field SomeCustomFieldType in Sitecore WFFM that shows on the left side of the Form Editor a property which is a dropdown with a list of choices.
[VisualProperty("Choose value", 99),
VisualCategory("Custom Properties"),
VisualFieldType(typeof(CountryBasedListChoiceField))]
public string ChosenValue { get; set; }
Instead of using the out-of-the-box ListChoiceField, I wrote my own CountryBasedListChoiceField, which, based on some condition, figures out which choice items need to be displayed in the property dropdown:
public CountryBasedListChoiceField()
: base(((object) HtmlTextWriterTag.Select).ToString())
{
string formID = Sitecore.Context.Request.GetQueryString("formid");
Language formLanguage = Language.Parse(Sitecore.Context.Request.GetQueryString("la"));
Item formItem = Sitecore.Context.ContentDatabase.GetItem(formID, formLanguage);
string countryName = SitecoreUtility.GetCurrentCountryISOCode(formItem, formLanguage);
string choicesRootPath = CountryConfigurationManager.GetCountrySite(countryName).Metadata.FormsStylesheetsItemPath;
Item choicesRootItem = Sitecore.Context.ContentDatabase.GetItem(choicesRootPath, formLanguage);
ChoicesRoot = choicesRootItem.ID.ToString();
}
It really doesn't matter how the above code works, since it works just fine.
The problem I am having is that the code above is executed only once, the very first time that the user opens a form in the form editor and clicks on a field that is of type SomeCustomFieldType.
After that, the list of choices to be displayed must be cached because this code is never being hit anymore. Even closing the browser and reopening it is not enough to clear that cache -- iisreset obviously clears that cache.
I would like to know if there is a way to stop this caching from happening.
Thanks in advance!
Firstly, you should check to ensure that it the rendering is not cached found here: '/sitecore/layout/Renderings/Modules/Web Forms for Marketers/Form' (the version of WFFM I have open right now it is NOT the default). Also check to ensure that any renderings it is contained within are also not cached.
Looking at the forms code, the form item and field containers are constructed every time. I also checked the .ascx that is called and it has no default output cache. You can start by looking deeper in Sitecore.Forms.Core.dll at the class 'Sitecore.Form.Web.UI.Controls.SitecoreSimpleFormAscx', but I would try the simple first.

Get the item matching a URL in Sitecore

In a site I'm building, I'm trying to use the referer to verify AJAX requests are coming from the correct URLs.
To do this I'd like to get Sitecore to resolve a URL to an Item. For example,
http://www.mysite.com/abc/def
might resolve to the item at the path
sitecore/Content/MySite/Home/abc/def
What's the recommended way to go about this in my code?
Thanks for all the answers but none of them did everything I needed. This worked for me.
var url = new Uri(...);
// Obtain a SiteContext for the host and virtual path
var siteContext = SiteContextFactory.GetSiteContext(url.Host, url.PathAndQuery);
// Get the path to the Home item
var homePath = siteContext.StartPath;
if (!homePath.EndsWith("/"))
homePath += "/";
// Get the path to the item, removing virtual path if any
var itemPath = MainUtil.DecodeName(url.AbsolutePath);
if (itemPath.StartsWith(siteContext.VirtualFolder))
itemPath = itemPath.Remove(0,siteContext.VirtualFolder.Length);
// Obtain the item
var fullPath = homePath + itemPath;
var item = siteContext.Database.GetItem(fullPath);
This answer is more for other visitors hitting this SO question. In case of Sitecore 8 you could do this:
new Sitecore.Data.ItemResolvers.ContentItemPathResolver().ResolveItem(<string path>)
Where <string path> is like any local path (or relative url, if you will) string that sitecore would be able to generate for you. When using displayname values instead of item names (possibly the case if you have a multilingual site), this is very handy to actually retrieve the corresponding Item from database.
In my case I use this to show a valid breadcrumb where the parent paths DO have the context language item version added, but the requested page has no context language version to render. Sitecore.Context.Database.GetItem(<string path>) couldn't resolve the displayname-based path, while the ResolveItem method does... searched a day for a good answer on this case.
Questioning myself now, why this isn't used much...?
Maybe it is an expensive query for a site with a big tree. That is something to consider yourself.
Don't really get what you're trying to do (with your AJAX request and such), but if you want http://www.mysite.com/abc/def to resolve the item sitecore/content/MySite/Home/abc/def, you need to configure your <site> in the web.config like this:
<site name="MySite" hostName="www.mysite.com" rootPath="/sitecore/content/MySite" startItem="/Home" *other attributes here* />
You can use the method ItemManager.GetItem(itemPath, language, version, database, securityCheck) To resolve an item based on it's (full)path.