Surendra Sharma

Surendra Sharma

Search This Blog

Thursday, September 21, 2017

Fixing Sitecore PowerShell post installation issues

I was trying to install Sitecore PowerShell on my Sitecore 8.2 instance by downloading “Full 4.6 release for Sitecore 8”. After successful installation, when I started PowerShell console, I hit with error

"Could not load file or assembly 'System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified."

As my laptop running on Windows 7 (Yes, it’s still on WIN 7) on 64-bit processor, so I fixed this by downloading and installing "Windows Management Framework 4.0" having setup file name "Windows6.1-KB2819745-x64-MultiPkg.msu" from https://www.microsoft.com/en-us/download/details.aspx?id=40855

Note - You must need to restart your machine after this setup.

After restarting machine, login to Sitecore instance and open PowerShell Console. It was started but received pop up note that "Elevated session state is required to run the script." and Sitecore asking for current Sitecore logged-in user password. This pop up will raise when you open any PowerShell window with every Sitecore login time.

To fix this 

Open "include\Cognifide.PowerShell.config" file and make entry as "allow" in below keys

<token name="Default" expiration="00:00:00" elevationAction="Allow"/>
<token name="Console" expiration="00:05:00" elevationAction="Allow"/>
<token name="ISE" expiration="00:05:00" elevationAction="Allow"/>
<token name="ItemSave" expiration="00:05:00" elevationAction="Allow"/>    

Please note, this configuration changes are only for local development environment. Don’t make it on Production environment.

After this my PowerShell started working fine on my new Sitecore 8.2 instance.

Please leave your comments or share this trick if it’s useful for you.

References

Sunday, September 3, 2017

Another way to render WFFM Form



WFFM is a nice module to capture details from visitors. But when developers try to render WFFM forms in web page, then she has to face CSS and JS conflict with webpage. However this is good for testers and QA team as they will able to find lots of cosmetic issues ;)

Most of the time, WFFM’s CSS and JS stop or change the UI and functionality of the web page.
However there is an alternative way to render WFFM form – Iframe.

Follow below steps use it
* Create WFFM form
* Create item having separate page layout and MVC rendering for WFFM form only.
* Create one parameter rendering IFrame with three field - IFrame Url, Width and Height as shown below

WFFM form via IFRAME
WFFM form via IFRAME


Specify relative path of above item page rendering path in IFrame URL field

Specify below line in Iframe.cshtml as 

<iframe src="@Model.Url" width="@Model.Width" height="@Model.Height" scrolling="auto" frameborder="0" align="left" name=""></iframe>


When you render web page, your WFFM form will be rendered in IFRAME and all WFFM form CSS and JS are also load into IFRAME. In this way we separated CSS and JS of web page with WFFM form CSS and JS. So they will never conflict.

However there are two issues that I encountered with this approach

* If your website is running on HTTPS and you have entered the WFFM item path as HTTP then you will face issue. To fix it, instead of using full URL, you must use relative path.

* How to handle multi lingual WFFM forms? Let’s suppose your page is in French and now if you try to render your WFFM form with relative path then it try to render by default in English language. To fix it specify your relative path with language query string as "/wffm-forms/contact-form?sc_lang=fr-fr"

That’s it. 

I hope you will try this alternative approach. Stay tuned for more Sitecore related articles.

Till that happy Sitecoring :)

Please leave your comments or share this trick if it’s useful for you.