Friday, 7 July 2017

Finding Sitecore Item by field value| only text value

Greeting of the day,


Today I'm going to write a post on finding sitecore Item by field value.
Sometime client requirements is like :

We have a text value, now tell me from which sitecore item it's coming?


So to find the sitecore item I will suggest you two methods:

Method.1:

From Sitecore ContentEditor:
when we have text value and we know from which field it's coming then we will follow this method.
Let me show you that how we can check:

Go to any item from content Editor





click on search:
1.
        custom:<fieldname>|value




2.   or click on down arrow and select "Search filter"
        


    and after that click on Seach by Field Value




   and now search field by value but this time you will get sitecore intellisense like



Method.2:

From SQL DB:

but if you trying to find the text value with sql query on each table then it will headache, the best way i found that

There is a tool who will search the text value/database object on all the table, we don't have to worry about Query.


What we have to do just install Free tool: ApexSearchTool 
now open SQL Server Management Studio,


a. Go to Database
b. Right click on the database and select search by text value
c. fill the input data.


Congrats you find the sitecore item where this value exist.

Have a Good day!!!

Thursday, 6 July 2017

To check Sitecore item has presentation or not?

To do this from code behind,
First we should aware of that SitecoreItem should be of Page Template type Item, because Presentation generally applied on Page Item.
And Second thing is Page Template Item should have Standard Value So that in future If you are going to create a Page related to that Item then Page will have some default presentation applied from Standard Value.


So For Now we are checking only Page have Presentation or not:

private bool HasPresentationDetails(Item item)
{
return item.Fields[Sitecore.FieldIDs.LayoutField] != null
  && !String.IsNullOrEmpty(item.Fields[Sitecore.FieldIDs.LayoutField].Value);
}


It will check the layout field's value of that page Item.
If page item's layout field is not empty then presentation is applied to that Item else not.