Tuesday, March 26, 2019

Sitecore 9.1 admin password is no longer 'b'?

Hi,

            I'm going to share my issue experience in getting admin default password in sitecore 9.1 installation.

Today i installed sitecore xp 9.1 and noted one important thing,that is default admin password is no longer 'b'.

Then i had one question "If no longer 'b' then what the default password is ?"
                           
                 After locating from installation guide,the default admin password is set to "SIF-Default" in XP0-SingleDeveloper file in the SitecoreAdminPassword parameter which means SIF generates a "Random Password" for you at the end of the script execution.






After reading this, you must have another question if i want to change back to 'b' what i need to do ?
                       
              Answer is simple , you can edit the SitecoreAdminPassword  before installation. or  you can simply copy the random password generated by SIF and change to what you want using user manager.









I hope you've enjoyed with this post. Thanks :)

Monday, March 25, 2019

Insert image to item field in MVC controller

Hi,

I'm going to share my issue experience here..

Issue:

While a time ago, 
i've ended up with one requirement "need to set image to item field in controller"

i searched in google and tried so many methods for this but not working.

After lot of research finally i found the work around.

Solution:
  
   imageField.SetAttribute("Src", imageItem.MediaPath);    

Src - Field name
imageItem.MediaPath - your image item

Thanks :)

"Got a No Service Error" from sitecore Rocks in VS

Hi,

I'm going to share my issue experience while using sitecore rocks in visual studio.

Issue :
  • I've installed sitecore rocks in my system then i'm going to create a connection to my sitecore instance.
  • During connection creation i've faced the below issue













Solution:
  • After investigation we found the reason for the issue.
  • It's an Permission Issue.

The below URL is helped me to quickly locate the issue
https://sitecore.stackexchange.com/questions/9659/create-connection-for-sitecore-9-instance-with-sitecore-rocks

we need to add the below line to Web.config to overcome the issue
<location path="sitecore/shell/WebService">
    <system.web>
        <authorization>
            <allow users="?,*" />
        </authorization>
    </system.web>
</location>
Thanks :)

Refused to get "Unsafe Header - Location" while getting response header in item service

Hi,
     
        Today i'm going to share my issue experience while creating item using item service in sitecore.services.client.


REST API is one of the key features in sitecore.

Sitecore provides two ways to use REST API
.
1. Item Service
2. Entitiy Service

If you want more explanation please refer the below url
https://doc.sitecore.com/developers/90/sitecore-experience-management/en/the-restful-api-for-the-itemservice.html

Issue: 
         
I'm trying to create an item using ItemService in Sitecore.Services.Client.
Item creation is working fine and response looks like this:
201 (Created).
Location: /item/0727f965-2338-43cc-bd88-5071ad3f7a12?database=master
My need is to get this location in the response header.
During that I'm facing this issue:
refused to get unsafe header "Location" Error
my code sample:
 request.setRequestHeader('Access-Control-Expose-Headers', 'Location');
            request.onreadystatechange = function () {
                if (this.readyState == 4) {
                    console.log(this.status); 
                    console.log(this.getResponseHeader('Location'));                                       
                }
            };
Solution:
I found the solution by adding the below line in web.config.
<httpProtocol>
      <customHeaders>
        <add name="Access-Control-Expose-Headers" value="*"/>
        <remove name="X-Powered-By" />
      </customHeaders>
 </httpProtocol>

Sitecore Tab is not appearing after installing sitecore rocks

Hi,

          Today i am going to share my issue experience while installing sitecore rocks.


why developer need sitecore rocks ?
  • Sitecore rocks brings the most of the content management functionality directly in visual studio will make developers happy.
  • It's open source.we can install  it from VS2017 extensions and updates.
  • Minimize the switch between browser and visual studio..

Issue:


I installed 

sitecore rocks from extensions and updates
. After i restarted my system.
  After i've checked in VS2017 , sitecore tab is not appearing.

 Solution:
     After so much of investigation finally i find the work around
 Steps to solve the issue :
  • uninstall Rocks
  • delete C:\Users\User\AppData\Local\Microsoft\VisualStudio\15.0_c2d19173\privateregistry.bin and privateregistry.user.bin file (please backup them first)
  • reinstall Rocks
  • start Visual Studio and problem should be solved

Thanks :)

Sunday, November 25, 2018

Templates in Sitecore

Hi friends, in this post we will see about templates in sitecore.

Let's Go,

Everything in Sitecore is an item. The same is true for templates.

Every piece of content(Pages or Components) in a sitecore needs a template to define what it is.
A template in Sitecore is an item,
  •  Which defines the type of item to be created.
  •   Determines the field sections,field names,and field types that make up an item.

All Content is based on Items. 


Steps to create a new template


Step 1: Right click Sitecore/Templates/ and create new template folders that contains all your templates that make up your site.



Step 2: Click on the folder and select the Base Template(Template that contains common fields which is shared across all the templates.by default all templates inherited from standard template) ,create a new template .



Step 3: Now the templates has been created.please make a note before creating templates you need to prepare a list of sections and fields involved.



Note : Field with the same section name results merged section and same field name duplicated.

DataSource- Here you can provide Data Source for the Field

Unversioned vs. Shared

A field in a template can be defined as Unversioned or Shared. The Unversioned field has the same value across all the versions within the language. The Shared field always has one valid value for all versions in all languages.


Difference between OOPS and Sitecore

(i) Object  => Item
(ii) Class => Template
(iii) Attribute => Field


Difference between Class and Templates

 (i) Data Types => Field Types
 (ii) Any number of instances can be created based on a class, similarly we can create any number of I items based on a Single Template.
 (iii)Inheritance is also available in templates.

To find the template that your item is based on? Answer is QuickInfo section.





Standard Field Values:

In Sitecore we can provide default values to fields via two ways,
                           1. Static.
                           2. Tokens-Replace token with values at the time of Item Creation.
   Some tokens:
$name => The name for the new item entered by the user.
$id => The ID of the newly created Item.
$Parentid => The ID of the parent of the new item.
$date => The system date in yyyyMMdd format.
$time => HHmmss Format.
$now => The system date and time in yyyyMMddTHHmmss format.


Types of Templates

Sitecore have three types
1.Data Template-Data Templates are the Schema for the sitecore content. Sitecore associates a                                          data template with each item.
2.Branch Template-allows you to create set of items rather that a single item at a time.
3.Command Template- defines a class and method to be called during an insert operation. whenever we try to crate an item from this template, it associate a class  would be executed.



Recommanded practices when creating a template:

1.Provide user friendly name.
2.Set Icon.
3.Limit use of rich text editor.
4.Provide default values.
5.Avoid duplicate names.
6.Use inheritance whenever possible.


 That' all. please share this with your friends. Happy Coding :)

Workflows in sitecore and Content approval using Workflows

Hi All, welcome back, In this post we will see about workflows in sitecore and content approval using workflows.

Let's Move,
  • Workflows are used to restrict your content author to create right items for your sites.
  • Basically workflow is a series of steps that an item version goes through from it’s creation to it’s publication.


It has three basic parts

1. States

  • The basic building blocks of the workflow. The workflow states represent the different stages in your content creation process.
  • State must have(One initial State and one or final states)

2. Commands

  •  Transition of content items from one workflow state to another that is defined in the command item.

3. Actions

  •  An automatic side-effect of a command or entering a site. 


Example of content approval using Workflows and mail the details: 


Step 1: Create a Workflow from a path /sitecore/system/Workflows/ and name this as TestWorkflow.




Step 2: Create three states named as Initial,Editing and Approved.




Step 3: Create a one command under initial state named as Created
            And create two commands named Approved,Reject Under Editing
 Copy the auto publish item to Approved state from the example workflow




  

Click the TestWokflow and provide initial state to Inital state field
For ex.



And also click the created command item and set next state to Editing and click the approved command item and set next state to Approved ,and in the reject command item set Inital state in the next state field.
For ex.



Click the Approved state and check the mark as final field(this the last state that your item goes).



Create a mail Template based on a Template Sitecore/Templates/System/workflow/Email action in the Approved state.

Step 4: fill the necessary fields that you want and put your custom class path that have logic to send mail in the Type field







Step 5: In the class,using WorkflowPipelineArgs, I have rendered all fields and sent mail to provided email.






Step 6: Create a template named as test, Create standard values for that template,and assign your workflow in the default workflow field from workflows tab(Don’t forget to enable Standard fields in the view tab.because it enables workflow options in the the standard values item)



Step 7: Create a item based on the template and check above the qucik info section(Item is not published because it is not in workflow state)

Step 8: To move your item to the next state
on the Review tab,find your command(created) ,clicking on this ,will move this item to next state.After final state is reached the item is auto published(because we included the auto publish item at final state and mail sent to the provided mail in the mail action item)







  

Advantages of workflows:

1.Acquire content approval
2.Prevent unwanted publishing

All now set,Please share with your friends Happy coding :)

Check the users Logged into the sitecore backend

Hi, Today I'm going to discuss about " how to check the concurrent users logged into the sitecore backend ? ". For this ...