Sunday, 26 June 2022

Upgrade Angular project to Latest version

After UpgradeBefore Upgrade

1.    Make sure you have upgraded node js to the LTS version and then follow the below.

2.    Go to your project folder and open the terminal and run the below commands:


>npm uninstall --save-dev angular/cli

>npm i -g npm-check-updates

>ncu -u

ERROR (if the below error occurs follow the below link to fix in node js config): 

npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead


>npm install

>npm uninstall @angular-devkit/build-angular

>npm install --save-dev @angular-devkit/build-angular
 
>npm install --save --legacy-peer-deps

Sunday, 2 January 2022

Sitecore rich text field in page editor is not editable when it contains HTML formatting

This is a known issue when you put an editable rich text inside a <p> tag.

There are plenty of html tags which are not allowed inside a <p> tag. That why your browser closes <p> tag and break the functionality of editable rich text.

Remove <p> tag which is around the @Editable.

Tuesday, 7 September 2021

How to get for loop index in SXA scriban

 

Adding something to the first item in a loop. As an example, below adding the active class to a bootstrap element, useful for tabs, menus, carousels, modals etc.

{{if for.first == true}} active{{end}}

Also, from the same artist:

  • `{{for.index}}` The current index of the for loop

  • `{{for.rindex}}` The current index of the for loop starting from the end of the list

  • `{{for.first}}` A boolean indicating whether this is the first step in the loop

  • `{{for.last}}` A boolean indicating whether this is the last step in the loop

  • `{{for.even}}` A boolean indicating whether this is an even row in the loop

  • `{{for.odd}}` A boolean indicating whether this is an odd row in the loop


 click here for more details


Tuesday, 3 August 2021

Glass-mapper-ienumerableguid-to-ienumerableobject

 Glass Mapper IEnumerable<Guid> to IEnumerable <Object>

You can set a custom type on your multi-list field that will be used during code generation by setting the "Custom Data" property of the field in TDS:

Custom Data.

In your case, if you set this to "generic=Namespace.OtherSitecoreTemplate" the stock code generation templates for TDS will generate as IEnumerable<OtherSitecoreTemplate>

As an aside, this is where you'd set the type for Link fields. If you use the string "type=OtherSitecoreTemplate" it will strongly type the field to the value provided.

Thursday, 17 June 2021

Trim item field text to max 48 chars in SXA Scribban code

 


{{

strText="";

if ((sc_raw i_item "Title Override" | string.size) > 0)

strText = sc_raw i_item "Title Override"

else

strText = sc_raw article "Title"

if ((strText | string.size) > 45)

strText = (strText | string.truncate 48)

end

end

}}

Monday, 5 April 2021

Enable and configure the Asset Optimizer in SXA - how to fix min files loading issue

  • Enable the Asset Optimizer globally

    To enable the optimizer globally: In the Content Editor, navigate to /sitecore/system/Settings/Foundation/Experience Accelerator/Theming/Optimiser and for both Scripts and Styles select Concatenate and Minify to minify all files and concatenate them into one file. Note Changes take effect immediately after the item is saved. Anonymous users might not see the changes until you publish. If you are using ES6, this back-end optimization is not compatible. Instead, use ECMAScript 6+.
  • Change the optimization settings for a specific site

    To change the optimization settings for a specific site: In the Content Editor, navigate to sitecore/content/Tenant/Site/Presentation/Page Designs. In the Asset Optimization section, in the Styles Optimizing Enabled and Scripts Optimizing Enabled fields, to override styles and scripts optimization settings, select: Default – to inherit global settings Yes – to always enable optimization for this site. No – to always disable optimization for this site.

Extracting Nupkg files using command line

Rename it to zip first then extract files as below 1.     Rename-Item -Path A_Package.nupkg -NewName A_Package.zip 2.     Make sure to repla...