레이블이 CMS인 게시물을 표시합니다. 모든 게시물 표시
레이블이 CMS인 게시물을 표시합니다. 모든 게시물 표시

2018년 6월 18일 월요일

사이트코어 내의 URL 마스크 (Alias) 설정하기

사이트코어 CMS에는 많은 기능이 포함되어있다. 그 중의 하나가 바로 Alias. 이 기능은 흔희 말하는 URL Mask 또는 cloaked URL이라고 불리며, 원래의 URL 링크주소를 Mask하여 다른 이름으로 바꿔주는 것이다.

보통 이 기능은 웹서버  (Rewrite Module) 또는 프로그래밍 상에서 Redirect Method (C#)를 사용하여 URL을 변경하지만, 사이트코어의 Aliases 기능을 통하여 쉽게 변경할수가 있다.

"http(s)://yoursite/blog/2018/11/25/My-Blog"를 "http(s)://mysite/blog/My-Blog"으로 변경하는것을 예로 들어 순서대로 세팅을 해보겠다.

  1. 해당 URL은 사이트 홈 (시작페이지) 아래의 "Blog" 아이템에서 URL이 시작하므로, "Blog" 아이템을 선택한다.
  2. Content Editor의 Presentation 탭 또는 Experience Editor의 Advance 탬에서 "Aliases"를 클릭한다.
  3. Name 필드에 "/blog" 입력하고, "Add" 버턴을 눌러 Aliases를 추가한다.

  4. 이젠, "My-Blog" 아이템을 눌러주고 같은 방법으로 Name 필드에 "/blog/My-Blog"를 추가한다.

  5. 위 두개의 아이템의 Aliases를 세팅함으로써 "/sitecore/system/Aliases/"에 "blog/My-Blog" 라는 아이템이 Linked 아이템과 함께 생성되었다.

  6. 원래 생성한 아이템 페이지로 가서 Related Item과 함께 아이템을 Publish하면, Alias가 적용된 URL로 페이지를 렌더링 할 수가 있다.
    http(s)://mysite/blog/My-Blog


* 참고로, 사이트코어의 Alias 기능은 Temporary Redirection 으로써 보통 Major Search Engine의 검색 결과에서는 기존의 URL (http(s)://mysite/blog/2018/11/25/My-Blog)로 결과물이 나타난다.

* 이번 예제는 Multi-Site가 아닌, 사이코어내의 기본 사이트 세팅에만 적용되는것이며, 한 Instance에 Multiple 사이트가 존재한다면, 아래의 링크를 통하여 Pipeline을 업데이트하길 바란다.
How to configure site-specific aliases (https://kb.sitecore.net/articles/565325)







2015년 7월 30일 목요일

MVC Field Update in Page Editor (xEditor)

#HowTo #MVC #Ajax

 Sitecore CMS에는 Page Editor (xEditor) 그리고 Content Editor가 있다. CMS 사용자는 Page Editor에서 해당 페이지의 컨텐츠를 수정하며, 필요한 Rendering또는 Sublayout을 추가하는데, 사용자의 편의에 따라 Page Editor에서 해당 페이지의 템플릿 필드항목을 수정할때가 있다.

Sitecore는 XSLT extensions은 RenderField Pipeline를 기반으로 적용되지만, MVC에서는 "Sitecore.Web.UI.WebControls.FieldRenderer" 에서 "Render" 메써드를 지원하여, 이 메써드를 통하여, 템플릿을 Data Type을 내부적으로 캐치한다.

그러므로, MVC에서는 굳이 XSLT에서의 <sc:text ../>, <sc:image .../> 등등 Element를 선언할 필요가 없다.

아래의 코드는 Page Editor에 해당 Rendering Component의 체크박스 필드를  Droplist (Enabled/Disable options)로 구현하였으며, DropList에서 Enable이 선택되면 컴포넌트 아이템의 해당 체크박스 필드가 자동으로 체크가 되며, 반대로 Disable경우 해당 필드의 체크가 없어진다.

Model


public class ComponentModel : IRenderingModel
{
    public string Title { get; set; }
    public Item Item { get; set; }
    public Item PageItem { get; set; }
    public Sitecore.Data.Fields.CheckboxField chBox { get; set; }
    ... some other declared data types based on templates if you want ...

    public void Initialize(Sitecore.Mvc.Presentation.Rendering rendering)
    {
        Rendering = rendering;
        Item = rendering.Item;
        PageItem = Sitecore.Mvc.Presentation.PageContext.Current.Item;

        Title = FieldRenderer.Render(Item, "Title");
        ... more if you want ...
    }
}

Controller


public class Components : Controller
{
    //
    // POST: /Components/

    public ActionResult ComponentView(string changedValue, string fieldName)
    {

        ComponentModel ss = new ComponentModel();
        ss.Initialize(RenderingContext.Current.Rendering);
        Item item = ss.Item;

        if (!String.IsNullOrEmpty(changedValue) && !String.IsNullOrEmpty(fieldName))
        {
            ss.Item.Editing.BeginEdit();
            using (new SecurityDisabler())
            {
                switch (fieldName)
                {
                    ... conditions ...
                }
            }
            ss.Item.Editing.EndEdit();
        }
        return PartialView(ss);
    }
}

View


@model yournamespace.ComponentModel
@using Sitecore.Mvc

@if (Sitecore.Context.PageMode.IsPageEditor)
{  
    if (!@Sitecore.Data.ID.IsID(Model.Rendering.DataSource))
    {
        <div>No Associated Datasource.<br />Please Create New Datasource</div><br />
    }
    else
    {
        <div class="newdata">
            <h3>This is page editor</h3>
            Title: @Html.Raw(Model.Title) <br />

            DropList: <select name="list" id="fieldName" onclick="javascript:dlOnChangeUpdate('fieldName');">
                <option value="True" @Html.Raw((Model.chBox.Checked) ? "selected" : "")>Enable</option>
                <option value="False" @Html.Raw((!Model.chBox.Checked) ? "selected" : "")>Disable</option>
            </select><br />

            <script type="text/javascript">
                function dlOnChangeUpdate(fieldName)
                {
                    $("#" + fieldName).on('change', function () {
                        var changedValue = $("#" + fieldName).val();

                        $.ajax({
                            url: '@Url.Action("ComponentModel","Components")',
                            type: "POST",
                            data: { "changedValue": changedValue, "fieldName": fieldName },
                            context: this,
                            success: function (data) {
                                Sitecore.PageModes.PageEditor.postRequest('webedit:save()');
                                console.log("success", data);
                            },
                            error: function (data) {
                                alert('error: ' + data);
                                console.log("error", data);
                            }
                        });
                    });
                }
            </script>
        </div>
    }
}
else
{
    <div id="info">
        <h3>This is preview</h3>
    </div>
}

2014년 12월 8일 월요일

Sitecore 기본 설치법

Sitecore은 시험버전을 제공하지 않으며, 라이센스를 구입해야 이용할수있다.

설치전, Sitecore을 소규모 비지니스로 설치를 원한다면 하나의 서버에 Sitecore CMS와 데이타베이스를 설치할수 있지만, 중/대규모의 시스템을 구현하길 원한다면 각각의 시스템 딜리버리, 데이타베이스, CMS 서버를 따로 두는것을 권장한다.

현재 설치법은 Sitecore 7.0를 기준으로 하고있으면, 필수사항은 아래와 같다.
설치법은 여기 링크를 통화여 다운받는다.

  1. 설치전 반드시 알아야 할 사항은,

    윈도우 버전이 Vista/7인 경우, Sitecore을 설치하기전 관리자는 시스템의 사용자 계정 그룹정책을 받드시 "허용"으로 적용해야한다.

    영문판: User Account Control: Detect application installations and prompt for elevation -> Enable
    한글판: 사용자 계정 컨트롤: 응용 프로그램 설치할 때 권한 상승 확인 -> 사용 함


  2. 브라우저 호환 리스트
    Microsoft Internet Explorer 11 (CMS 7.0 Service Pack-1, originally released as 7.0 Update-5)
    Microsoft Internet Explorer 10
    Microsoft Internet Explorer 9
    Microsoft Internet Explorer 8
    Mozilla Firefox 17+ (latest supported version by Mozilla)
    Google Chrome 25+ (current supported version by Chrome)
    Apple Safari 6 for Mac OS (Windows is not supported by Apple)
    IE8 compatibility – not supported
    IE8 normal – supported
    IE9 compatibility – supported
    IE9 normal – supported
    IE10 compatibility – supported
    IE10 normal – supported