Friday, October 18, 2019

How to hide the Richtext Editor Buttons in sitecore 9.1

Sometimes your authors are messing up the RichText Editor Buttons.then if your Product owners are come up with a solution to disable the particular feature.in our case HTML access and hide the tables.
to do that

You have to find out which RTE you are using on the Templates. RichText Editor are 5 types. Find out if anything configured on the Template field (such as any path), you can read my article here.
If nothing configured default is standard RTE.so it’s better to create a role,in my case “Restricted access Role”. once you create the role go to Core database:
On the security Editor and perform the following steps.

1) hide Edit Html: Deny read access on the above Role to Edit Html on below path




/sitecore/system/Field types/Simple Types/Rich Text/Menu/Edit Html


2) 1)      Hide Design and HTML:
  
deny the read access to /sitecore/system/Settings/Html Editor Profiles/Rich Text Standard/Buttons/HTML View.



You can hide any other components on the RTE, I have hide the Insert Table as below:

/sitecore/system/Settings/Html Editor Profiles/Rich Text Standard/Toolbar 1/Insert Table





Thursday, September 12, 2019

How to Hide/show specific Buttons to the specific users in sitecore

Did you ever get situation like you have to hide some buttons to specific content authors.
There are chances of misusing the functionality of buttons,In our case Detach button on the file need to hide from content authors.The issue are detaching the media file,but they forgot to attach again. because of this issue our media file URL's are throwing 404 errors.So finally we decided to hide the detach button from content authors.they can only see the attach and download on the file.With attach button they can achieve the detach functionality in a efficient way, like if they want to detach they need to attach

if you want to update the media file and to avoid the broken links simply use the Attach/detach functionality.so it's better instead of deleting the Whole file and remove the links,upload new file.

To Hide the Attach/detach buttons Switch to Core database and

ClickàAccess VieweràSecurity EditoràAccountàselect User X/Role X then 
 navigate to the path: /sitecore/system/Field types/System Types/Attachment/Menu/detach
àassignàDeny the Read access.It will look like below.


so once the User X login to the sitecore navigate to the files(medialibrary,files) he will not see the Deatach button.his view looks like below.


Like above you can Hide the EditHtml button also on the path:/sitecore/system/Field types/Simple Types/Rich Text/Menu/Edit Html.

Some users publish the site by clicking the Publish--Publishsite button.if yoiu want to hide publish site button for specific users goto access Viewer for user "X" and navigate to below path on the security editor
/sitecore/content/Applications/Content Editor/Menues/Publish/Publish Site deny the read access.


final his view:


Monday, September 9, 2019

How to add the Field validation rules in sitecore and make it fatal Error


In Sitecore Validation will avoid man made mistakes.
you can control output entering into the field and make particular field is required.
We have Various validation types like Item,Field,Field Types,Global.you can find the validation rules on the path :/sitecore/system/Settings/Validation Rules

so we are talking about the field validation over here:
on the field validation there are 4 types of validations based on the message you are displaying.

Quick action bar-- Runs in the bar to the left of the content tree
Validation Button: whenever you click on the Validation Button, you will see the message on the validation Rules.Navigation path:Select the ItemàReviewàValidationàValidation Rules
Validator Bar: There is a red solid line will display at the field
Workflow: this is for the workflow

Whatever the field on a template you want to make required go to that field in sitecore and expand the validation Rules àQuick Action Bar à add Required,do for all if you want to see error messages on all 4 places.
If you wanna make error level more critical without satisfying the field they can’t save the item.the highest level is FatalError Result=FatalError.

these are the error levels in sitecore, you can find more on sitecore documentation

  • Valid (green) – no action is needed.
  • Suggestion (yellow) – look into the issue and decide if an action is needed.
  • Warning (orange) – act on the issue.
  • Error (red) – this is an error.
  • CriticalError (red) – the warning appears before you save the changes.
  • FatalError (red) – you cannot save the item before the error is corrected.

after you implemented the above steps the fatal error looks like below.whenever you are trying to save the item


How to make Admins can only edit a field in sitecore 9.1

Did you ever get a situation where admins can only edit the field on a item in sitecore. there is a simple solution for that.if you are aware of the roles in sitecore then you should know about Everyone role.


How to make a field Admin Can only edit on the item:

 If you are admin then you will edit the field on the item by Deny the Field Write and Allow the Administrator on the Everyone role. This means you are making a field write by admin. for non-admin users that field is grayed out they cannot edit, but they can only see.


Thursday, August 15, 2019

Rich text Editors in sitecore


Most of the people know about this concept already,this is for people don't know about Rich text editor types in sitecore.

In sitecore there are 4 types of Rich text editors, please find below rich text editors and their screenshots. 4th and the 1st one doesn’t have the H1 options at all.

1)Rich Text Default:
Template field to update: /sitecore/system/Settings/Html Editor Profiles/Rich Text Default




2)Rich Text Full
    
Template field to update:   /sitecore/system/Settings/Html Editor Profiles/Rich Text Full



    3) Rich Text IDE

    Template field to update:  /sitecore/system/Settings/Html Editor Profiles/Rich Text IDE




    4) Rich Text Medium

    Template field to update: /sitecore/system/Settings/Html Editor Profiles/Rich Text Medium



    you can configure the rich text editor on your template field like below


    Wednesday, August 14, 2019

    Writing a power shell script update the Url's the environment you are on

    Scenario:
    whenever you will get the latest content from Prod to QA.you will see some Url's still pointing to Prod.
    below powershell script will find the particular Url and replace the Url of your current environment
    it will traverse through all child items and replace the text wherever it is.it's time consuming if you have a big site.running the script by folder by folder,will be faster.

    Using the bulk update below is the final script
    $path="/sitecore/content/SomeSite/Home";
    $findField="*http://www.Illinoiindinas.com*";
    $originalText="http://www.Illinoiindinas.com";
    $replaceWith="http://SitecoreQa.illinoindians.com";
    $count=0;
    $items=Get-ChildItem -Path $path -Recurse
    New-UsingBlock (New-Object Sitecore.Data.BulkUpdateContext) {
    foreach($item in $items){
        foreach($field in $item.Fields){
        if($field -like $findField)
        {
            $newValue= $field -Replace($originalText,$replaceWith)
            $item.Editing.BeginEdit()
            $field.Value=$newValue;
            $item.Editing.EndEdit() > $null
            $count=$count+1
            $StringToDisplay=[string]::format("Items updated {0} with fields {1}",$item.ID,$field.Name)
            Write-Host $StringToDisplay
        }
    }
    }
     Write-Host "Number Of Fields Updated:" $count
    }


    the above script is using the BulkUpdateContext,it will useful whenever you want to update the bulk content.and also you can add the security disabler. Sitecore.SecurityModel.SecurityDisabler

    Point to Note:
            It's not always most efficient to operate on items by traversing the tree using Get-ChildItem
    you can use the Sitecore QUery and Fast query as well,whenever working with the bulk items

    Based on

    Running a Powershell Script by scheduled Task

    Sitecore version:8.2.

    You can find lot of articles online,for my reference posting this article.
    Running powershell script for scheduled task is not that complex,you can create a powershell script and run schedule basis.the below script is for clearing the cache on a schedule basis, best practice is not to clear the cache often,it will effect to your site performance.

    Basic script:
    ForEach($site in [Sitecore.Configuration.Factory]::GetSiteNames()) {
        $siteInfo = [Sitecore.Configuration.Factory]::GetSiteInfo($site)
        if($siteInfo -ne $null) {
             $siteInfo.HtmlCache.Clear()  
             $logEntry = [string]::Format("mahe through Scheduled Task your HtmlCache.Clear() invoked for {0}", $siteInfo.Name)
             Write-Log $logEntry
             Write-Host $logEntry
        }
    }
    1)      Write above script in your powershell ISE and excute if it’s working fine save as [some name] PowerShellHtmlCacheClearTask
    2)      /sitecore/system/Modules/PowerShell/Script Library/Task Management/Content Editor/Insert Item/PowerShellHtmlCacheClearTask








     Creating the Scheduled Task
    1.  Goto /sitecore/system/Tasks/Schedules
    2.  Click on the Schedules and insert PowerShell Scripted Task Schedule




    1     Give the name SchedulePowerShellScript
    2     Select the Powershell task you created in 1st step
           Click on the create



    Select the timings when you want to run and how often it should run



    You will see on the SPElogs your task running



    Wednesday, July 3, 2019

    Saving WFFM Data to Sql Server Sitecore 8.0 or above

    Saving WFFM Data to Sql Server Sitecore 8.0 or above

    Here we are focusing on Save the WFFM Data to the Sql server.
    After installing the WFFM package in sitecore,Create the database,adding connection string name "wffm",

    1) update the formsDataProvider setting to sqlFormsProvider in the sitecore.wffm.Dependencies.config under the AppConfig folder.


    2) Make sure your connection string name matches the above connection string name connectionstrings.config




    3) Make sure the connection string name is same as above name "wffm" in sitecore.forms.config

    4) make sure the check box "Save Form data to storage" checked on the form.
    5) Submit the form you will see the data in the sql server db mentioned in connection string.
    you will see the data in the Two tables:1) FormData, 2)FieldData.