Friday, May 20, 2016

Sitecore MVC Call Controller Action on Radio Button Click

Hi All,

 In my current working project I faces a issue, because I am new in sitecore and for MVC as well so I spend lot's of my time to know , how call controller on radio button click.
After a long search I found a article which is very useful that you can found here.
But for my need I need some more for that I am calling the Sitecore MVC controller on radio button click by below code.

 @using (Html.BeginRouteForm(Sitecore.Mvc.Configuration.MvcSettings.SitecoreRouteName, FormMethod.Post))
                        {
                            @Html.Sitecore().FormHandler("FeedbackResult", "Feedback")
                            <label class="radio-inline">
                                <input type="radio" name="inlineRadioOptions" id="inlineRadio1" value="yes" onclick="this.form.submit();">
                                @Translate.Text("frontend-components-feedbackbox-was-the-information-helpful-yes")
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="inlineRadioOptions" id="inlineRadio2" value="no" onclick="this.form.submit();">
                                @Translate.Text("frontend-components-feedbackbox-was-the-information-helpful-no")
                            </label>
                        }


By using "onclick="this.form.submit();" I just commit my form and "@Html.Sitecore().FormHandler("FeedbackResult", "Feedback")" Call the controller Action. It take two parameter first is Controller name & second is Controller Action Result name.
In controller we are also able to use value of selected radio button by Id as below:

public ActionResult Feedback(String inlineRadioOptions)

        { ....}

Hope that is helpful. Keep doing coding.

Thanks
Arun Sharma


Sitecore Extensions version 1.0 released

Hi All,
  I hope all is well, So today I am discussing about the Sitecore Extensions version 1.0 for google chrome.
Might be some of you know about that earlier but who don't know that must have to know , this is Google chrome web browser extension that may enhance the 
productivity of developer. This extension provide some handy commands that help the developer to achieve their goals.
You can download that extension from here.
Press Ctrl + Space to call Launcher and have fun.

Features:

Launcher

With Launcher you can easily navigate to various locations. Launcher is available always in Sitecore context.
You can feel the great power of Launcher when you are using it in Content Editor. Forget about jumping from one tab to another. Use intelligent fuzzy search engine and execute any command from the Ribbon.
Note: If you go to the "Content editor" mode via "Desktop" then this is not working so from launchpad select "Content Editor" for use extension.

Information: Each command defines whether it can be executed or not. So on particular page you will see only those commands that can be successfully invoked.

Section Switches


Easily open/close all item sections with just one click

Context database name

Current database name will be displayed in the Sitecore header.

‘Database Color’

Depending on your current database Sitecore header will change its color to warn you.



Thursday, May 5, 2016

TFS use in Daily Development

Some Best Practices for TFS Daily  Development:
  1. What Should Be Checked In
  2. The Right Way To Check In
  3. Things To Watch Out For

1.What should be checked in?

This may seem obvious but there are some things that you may not think of checking in that you should:

File on those you work

Checked in all files on those you worked or you want to commit your changes on TFS server.

Solution/Project Files

your *.sln and *.csproj (and others) contain the list of every file that is in your solution/project.  If you just check in a folder of files on your screen it may look fine but when someone else goes to get your code they won’t see these files.

Nuget Packages

If you are not familiar with NuGet packages yet it’s well worth your time to look it up.  This was more of an issue with previous versions of Visual Studio but since they are not visible in the solution explorer and contain binary files (*.dlls) inexperienced developers may ignore them not realizing that these should be checked in.

2.The Right Way to Check In

Get Latest Before Checking In

It may seem minor but it is very important to get the latest version before attempting to check code in. If you are working on a team with other developers, you need to assume that someone else has either made changes to the same source files or has made changes that impact your code. You should consider it your responsibility to merge your changes with any that others may have made.

Get Latest Before Checking in Again

This was more of an issue with the previous versions of Visual Studio that has been taken care of with later versions. Getting latest from within Source Explorer will get the latest version of all files that the solution and associated projects know about.
I already mentioned that *.sln and *.csproj (and other project types) keep a list of what projects and files are within the solution. Getting the latest analyzes your current copy of this solution and project definitions and gets updates of all files based on that list (including the solution and project definitions themselves). The issue arises when you add a new file to a project or a new project to a solution because Visual Studio won’t know about the new files until after the first check when the definitions are updated. After getting the updated definitions, getting the latest again will get the new items this time around.
Even though newer versions of Visual Studio seem to be smart enough to take care of this on their own, I still get latest twice just to be sure because it doesn’t hurt to be sure.

Conflict Resolution

When you get latest to a resource that has been modified and checked in by someone else first, you then need to resolve the differences and merge them into one up to date file. Many times, Visual Studio can take care of this on its own but sometimes the changes are too close to one another. When that happens, you’ll go through each change and ensure that the changes don’t conflict with one another. And even after resolving changes, it’s a good idea to test your code again to ensure that it still works as intended. This is an ideal situation for Unit Tests which leads to my next point.

Check In Working Code

It may seem obvious but TFS or any other source control platform is for storing working versions of code. All of the previous steps boil down to the same thing, getting the latest version of all code and testing the changes either automatically via unit tests or manually to make sure what you ultimately check in is as close to working as possible. Bugs always happen but at the very least make sure your code compiles, make sure unit tests all pass, and if for some reason that isn’t possible (most likely because you need help addressing an issue), be sure to log the issue appropriately so it is known.

3.Things To Watch Out For

Ignoring Solution and Project Files

I’ve mentioned this in both previous parts but it’s important enough to mention it one last time, make sure you check in the solution (*.sln) and project (*.csproj for C# Projects) definition files. This is mostly an issue with developers that are not as experienced with TFS because they are making changes to code and when they go to check in, these strange files that they never touched have pending changes so they don’t check them in.

Not Providing Comments with your Check-Ins

Always proper comment while checked in because It is incredibly invaluable aid when trying to track back what was going on with code several months back. Even something as simple as “Fixed Bugs” may seem like it’s not worth the effort but it can help separate bug fixes from enhancements that went wrong.

Hope this is helpful for you. Please give suggestion and feedback both are welcome.

Regards

Custom Setting for Email reminder subject and default text

Hi All,
In my current project i faces issue regards Email Reminder Configuration. I am able to set the Reminder Text, Recipients & time as described in doc below:
But I face issue to configure the Subject of email & also Reminder default text.
So in email subject comes by default "Reminder from Sitecore" & in reminder text default text come as "This is a reminder from Sitecore regarding the item: '{item}' in the database '{database}". The leading text to use for email reminders. Custom text will be appended.
So after some R&D I found that by using patch config we can update those things. Patch show as below:

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <settings>
      <!-- TASKS - EMAIL REMINDER SUBJECT The subject to use for email reminders.Default value: Reminder from Sitecore -->
      <setting name="Tasks.EmailReminderSubject" value="Custom Reminder by CustomEmailReminder.Config" />
      <!-- TASKS - EMAIL REMINDER STANDARD TEXT The leading text to use for email reminders. Custom text will be appended. Default value: This is a reminder from Sitecore regarding the item: '{item}' in the database '{database}'
-->
      <setting name="Tasks.EmailReminderText" value="This is a test reminder from Sitecore regarding the item: '{item}' in the database '{database}'" />
    </settings>
  </sitecore>
</configuration> 
Hope this is helpful for you. Please give suggestion and feedback both are welcome.
Regards

Experience Editor Context Item Issue

Hi All,
Currently I am working on a project task & found a wearied issue might be some of my colleague are aware from it. Issue is that when I am getting context item using
"Sitecore.Context.Item". It's work fine for normal mode & I am capable to perform my custom logic on context item but when I saw in Experience editor It always take home item when i call "Sitecore.Context.Item", I try to debug the code & found in normal mode I am getting the context item(On which item i visited or current item) but in Experience mode it always take the Home Item. 
So I look into the issue & try to resolve that & found that "Sitecore.Context.Item" not getting the context item in Experience mode so I found very good solution for that I just show the code which is useful for getting the context item in both mode(normal & Experience Editor mode). Code are below:
public Item GetContextItem()
        {
            Item item = null;
            if (Sitecore.Context.PageMode.IsExperienceEditor
 || Sitecore.Context.PageMode.IsExperienceEditorEditing
 || Sitecore.Context.PageMode.IsPreview)
            {
                if (Request.UrlReferrer != null)
                {
                    UrlString url = new Sitecore.Text.UrlString(Request.UrlReferrer.ToString());
                    var id = url.Parameters["sc_itemid"];
                    item = Sitecore.Context.Item;
                    // if a query string ID was found, get the item for page editor and front-end preview mode
                    if (!string.IsNullOrEmpty(id))
                    {
                        item = Sitecore.Context.Database.GetItem(id);
                    }
                }
            }
            else
            {
                item = Sitecore.Context.Item;
            }
            return item;
        }
Hope this is helpful for you. Please give suggestion and feedback both are welcome.

Regards

Remove Html tab from rich text editor for certain users

Hi All,
In previous I am working on JIRA & their is one ticket is related to how we remove the HTML tab from rich text editor for cetain user.
My colleague Hümmer, Christopher (init) also provide me a supported document that help me a lot. That you can found here:
By getting help from this url I found the solution that are below mentioned how we can achieve this requirement :
For remove HTML tab from RT for certain user ,just navigate to:
"/sitecore/system/Settings/Html Editor Profiles/profile you want/buttons/HTML view". and deny read-access on that for your users.


Hope this is helpful for you. Please give suggestion and feedback both are welcome.