Surendra Sharma

Surendra Sharma

Search This Blog

Monday, May 15, 2017

Best way of installing Sitecore modules in the central database



Most of the time team members are working on central database in Sitecore development environment. This is great as everybody have the same state of the database. 

But what will happen if any developer installed a Sitecore module?

Lets take the example of WFFM module. One of the team member installed on local instance where database is central and everybody using this database. After installation complete, a Sitecore instance run perfectly on that one developer machine and other team members will started to get errors. What’s the cause of their error?

WFFM items will be installed on central database but DLL and other files are installed only on our single developer machine. When any developer launched Sitecore in browser, it starts to look the required DLLs and the files. As they are not available on other developer’s machine, they all started to get the error.

How to fix this?

There are two option that I know to fix this

·         Unzip Sitecore ZIP module, copy only the files and paste into the relevant location. This seems to be a straight forward option, but believe me you have to do this on each developer machine and all files must be pasted at the correct folders.

Extract files from package zip
Extract files from package zip 


·         Second option need some preparation but provide a solid option to the team.
o    Open Sitecore desktop -> Development Tools -> Package Designer.
o    Click on down arrow of “New -> From existing package” in Package Designer screen.

Load existing package
Load existing package


o    Upload and select your package. For example we have WFFM package here.
o    Select a Sitecore item listed in left site metadata section one by one and click on “Remove source” button.
This will delete all the Sitecore entry and you will get only files in last that we need.
Now click on “Save” or “Save as” option under “Package” Tab.

Remove items from package
Remove items from source package


You can also click on “Preview” button, just to verify you are getting a list of required files only. If you find any Sitecore item entry in the list then delete it from package designer screen.


Package Preview Screen
Package Preview Screen



That’s it. Now share this package with other developers and they will installed the package on their local Sitecore environment and get the required files on correct folder path as per Sitecore items in central database.

One last thing, you should also check the size of new package. It must be smaller than the source package size.

I hope you like this Sitecore article. Stay tuned for more Sitecore related articles.

Till that happy Sitecoring :)

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

Friday, May 12, 2017

How to apply custom CSS to particular WFFM form in Sitecore


WFFM forms is one the most useful module in Sitecore. By default Sitecore render WFFM form in vertical position. But what if you want to change its default CSS and make the form rendering customized.


WFFM form uses "Website\Views\Form\Index.cshtml" view for rendering the form. In this rendering "bootstrap.min.css" is one the CSS file for changing form look and feel.

Default CSS of WFFM form
Default CSS of WFFM form


But what if you want to apply some other CSS instead of this? One way is that change this CSS file with our custom file but the new CSS file reflect changes on all the WFFM forms.

How to change this CSS for any particular form only?

For this I just change the below line in "Website\Views\Form\Index.cshtml" view as

@using Sitecore.Forms.Mvc
@using Sitecore.Forms.Mvc.Html
@model Sitecore.Forms.Mvc.ViewModels.FormViewModel

@{
    ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = Model.ClientId;

    var main = string.Format("{0}main.js", Constants.ScriptsBaseUrl);
    var requirejs = string.Format("{0}require-2.1.15.js", Constants.ScriptsBaseUrl);
    var bootstrap = @Model.Item.ID.ToString().Equals("{B822847C-035B-48C9-BBDC-1DE3B96115E4}") ? "mybootstarp.css" : string.Format("{0}content/bootstrap.min.css", Constants.ScriptsBaseUrl);
   
As you can notice in yellow highlighted code part that I am comparing Model Item Id with my Sitecore form item id. If it matches, then I will render my CSS “mybootstarp.css” otherwise for rest of the forms default CSS "bootstrap.min.css" will used.

Custom CSS for particular WFFM form
Custom CSS for particular WFFM form

Remember that “index.cshtml” is just a view, so we can write any custom logic in this view. 

I hope you like this Sitecore article. Stay tuned for more Sitecore related articles.

Till that happy Sitecoring :)

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