小编Mar*_*idy的帖子

使用Sitecore页面编辑器进行Jquery

我需要在一行中的第一个单词周围放置span标签.我使用下面的Jquery,它在sitecore标准模式下工作正常.

$("body").has(".widget h2").addClass("standard-mode");
$("body").has(".scLoadingIndicatorInner").removeClass("standard-mode").addClass("page-edit");


$('.standard-mode .widget h2').html(function(i, html){
    return html.replace(/(\w+\s)/, '<span>$1</span>')
})
Run Code Online (Sandbox Code Playgroud)

当我第一次加载页面编辑器时,这也可以正常工作(不插入span标签),但是当我创建一个多变量测试时,使用箭头标记在A/B之间切换显示就像插入不应该设想的span标签一样在页面编辑模式下执行,但它确实打破了html,如下所示.

<h2>
        &lt;<span>input </span>id="fld_D26C954B73BE4C62B6F25BE191A86F18_7B55B5E5EDD84D4E88B16C6E073495A5_en_1_0e80a9c63ab6419f8135b70511e892f1_16487" class="scFieldValue" name="fld_D26C954B73BE4C62B6F25BE191A86F18_7B55B5E5EDD84D4E88B16C6E073495A5_en_1_0e80a9c63ab6419f8135b70511e892f1_16487" type="hidden" value="Badger Cull"&gt;<span class="scChromeData">{"commands":[{"click":"chrome:common:edititem({command:\"webedit:open\"})","header":"Edit the related item","icon":"/temp/IconCache/SoftwareV2/16x16/cubes_blue.png","disabledIcon":"/temp/cubes_blue_disabled16x16.png","isDivider":false,"tooltip":"Edit this item in the Content Editor.","type":"common"},{"click":"chrome:rendering:personalize({command:\"webedit:personalize\"})","header":"Personalize","icon":"/temp/IconCache/PeopleV2/16x16/users3_edit.png","disabledIcon":"/temp/users3_edit_disabled16x16.png","isDivider":false,"tooltip":"Personalize component.","type":"sticky"},{"click":"javascript:Sitecore.PageModes.PageEditor.postRequest('ActiveISPageEditor:publish(id={D26C954B-73BE-4C62-B6F2-5BE191A86F18})',null,false)","header":"Publish the related item","icon":"/temp/IconCache/Network/16x16/download.png","disabledIcon":"/temp/download_disabled16x16.png","isDivider":false,"tooltip":"Publish this item.","type":"common"},{"click":"chrome:rendering:editvariations({command:\"webedit:editvariations\"})","header":"Edit variations","icon":"/temp/IconCache/SoftwareV2/16x16/breakpoints.png","disabledIcon":"/temp/breakpoints_disabled16x16.png","isDivider":false,"tooltip":"Edit the variations.","type":"sticky"}],"contextItemUri":"sitecore://master/{D26C954B-73BE-4C62-B6F2-5BE191A86F18}?lang=en&amp;ver=1","custom":{},"displayName":"Header Text","expandedDisplayName":null}</span><span scfieldtype="single-line text" sc_parameters="prevent-line-break=true" contenteditable="false" class="scWebEditInput scEnabledChrome" id="fld_D26C954B73BE4C62B6F25BE191A86F18_7B55B5E5EDD84D4E88B16C6E073495A5_en_1_0e80a9c63ab6419f8135b70511e892f1_16487_edit" sc-part-of="field">Badger Cull</span>
    </h2>
Run Code Online (Sandbox Code Playgroud)

任何建议都会有所帮助.

javascript jquery sitecore sitecore-dms page-editor

8
推荐指数
1
解决办法
1900
查看次数

TermQuery不会返回已知的搜索词,但WildcardQuery会这样做

我希望有足够洞察Lucene内部运作的人可能能够指出我正确的方向=)

我将跳过大部分周围的相关代码,并切入正确的追逐.我有一个Lucene索引,我将以下字段添加到索引中(变量由其文字值替换):

document.Add( new Field("Typenummer", "E5CEB501A244410EB1FFC4761F79E7B7", 
                        Field.Store.YES , Field.Index.UN_TOKENIZED));
Run Code Online (Sandbox Code Playgroud)

稍后,当我搜索我的索引(使用其他类型的查询)时,我能够验证该字段确实出现在我的索引中 - 比如循环遍历Document.GetFields()返回的所有Fields

Field: Typenummer, Value: E5CEB501A244410EB1FFC4761F79E7B7
Run Code Online (Sandbox Code Playgroud)

到现在为止还挺好 :-)

现在真正的问题是 - 为什么我不能使用TermQuery来搜索这个值并实际获得结果.

此代码产生0次点击:

// Returns 0 hits
bq.Add( new TermQuery( new Term( "Typenummer", 
        "E5CEB501A244410EB1FFC4761F79E7B7" ) ), BooleanClause.Occur.MUST );
Run Code Online (Sandbox Code Playgroud)

但是,如果我将其切换为WildcardQuery(没有通配符),我会得到我期望的1点击.

// returns the 1 hit I expect
bq.Add( new WildcardQuery( new Term( "Typenummer", 
        "E5CEB501A244410EB1FFC4761F79E7B7" ) ), BooleanClause.Occur.MUST );
Run Code Online (Sandbox Code Playgroud)

我检查了字段长度,我已经检查过我使用相同的分析仪等等,我仍然在方块1上为什么会这样.

任何人都可以指出我应该看的方向吗?

lucene lucene.net sitecore sitecore6

7
推荐指数
1
解决办法
1661
查看次数

在WCF服务中调用Sitecore Database.Templates []时出现NullReferenceException

我是Sitecore开发的新手,所以如果这个问题是基本的,我很抱歉.我创建了一个代理(计划任务)和一个WCF服务,并将它们都添加到我的SiteCore项目中.代理调用WCF服务代码调用的相同代码.

我遇到的问题是,当我调用Database.Template[ID template]传递我想要处理的项目的相应模板的ID容器时,它在代理任务内部工作,但不在WCF服务内部.

Database.Template[ID id]对WCF服务内部的任何调用都给了我一个NullReferenceException,但是代理内部的完全相同的调用正确地收集了模板.

这是由于某些结构性原因依赖于调用应用程序是网页而不是Web服务?

编辑#1:我有svc作为允许的扩展,我已经尝试过两者

Sitecore.Configuration.Factory.GetDatabase("master") 
Run Code Online (Sandbox Code Playgroud)

var siteContext = Sitecore.Configuration.Factory.GetSite("websiteMaster");
siteContext.Database.Template[]; 
Run Code Online (Sandbox Code Playgroud)

两者都返回NullReferenceException.

我也可以成功获取一个Item,GetItem但是当我尝试访问该项的Template属性时,我得到了一个NullReferenceException.

c# wcf sitecore

7
推荐指数
1
解决办法
4436
查看次数

跟踪sitecore中的NullReferenceExceptions

我正在尝试跟踪在加载任何网页时出现在sitecore 6.5上的NullReferenceException:

[NullReferenceException: Object reference not set to an instance of an object.]
   Sitecore.Diagnostics.Log.Error(String message, Exception exception, Type ownerType) +133
   Sitecore.Diagnostics.Log.Error(String message, Type ownerType) +45
   Sitecore.Configuration.Factory.LoadAutoIncludeFiles(ConfigPatcher patcher, String folder) +680
   Sitecore.Configuration.Factory.LoadAutoIncludeFiles(XmlNode element) +63
   Sitecore.Configuration.Factory.GetConfiguration() +347
   Sitecore.Diagnostics.LoggerFactory..cctor() +67

[TypeInitializationException: The type initializer for 'Sitecore.Diagnostics.LoggerFactory' threw an exception.]
   Sitecore.Diagnostics.LoggerFactory.GetLogger(Type type) +17
   Sitecore.Diagnostics.Log.Error(String message, Exception exception, Type ownerType) +93
   Sitecore.Diagnostics.Log.Error(String message, Type ownerType) +45
   Sitecore.Configuration.Factory.LoadAutoIncludeFiles(ConfigPatcher patcher, String folder) +680
   Sitecore.Configuration.Factory.LoadAutoIncludeFiles(XmlNode element) +63
   Sitecore.Configuration.Factory.GetConfiguration() +347
   Sitecore.Configuration.Factory.GetConfigNode(String xpath, Boolean assert) +82
   Sitecore.Configuration.Factory.GetConfigNode(String xpath) +29
   Sitecore.Resources.Media.UploadWatcher.InitializeIgnoreList() …
Run Code Online (Sandbox Code Playgroud)

iis-7 sitecore visual-studio-2010 sitecore6 slowcheetah

6
推荐指数
1
解决办法
6976
查看次数

以特定语言以编程方式创建sitecore项目

我试图以编程方式创建一个sitecore项目.一切顺利.但我创建的项目是使用语言"EN-GB",但创建的新项目是使用语言"EN".有没有办法在创建项目时设置语言值.

var currentDatabase = Sitecore.Configuration.Factory.GetDatabase(selectedItem.Database.Name);

    if (currentDatabase != null)
    {
        var rootItem = currentDatabase.GetItem(RootItemPath);

        if (rootItem != null)
        {
            //Create new item
            var item = rootItem.Add(selectedItem.Name, CommunityProjectTemplateId);

            if (item != null)
            {
                item.Fields.ReadAll();
                item.Editing.BeginEdit();

                try
                {
                    //Add values for the fields
                    item.Fields["Overview Body Content"].Value = selectedItem.GetStringField("ProjectOverview");
                }
                catch (Exception)
                {
                    item.Editing.EndEdit();
                }
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

c# sitecore sitecore6

3
推荐指数
2
解决办法
6586
查看次数

Sitecore:其他数据库中的参考项(源字段)

我正在使用Sitecore 8 Update 2.我已经在用户配置文件中添加了额外的字段,并且有一些静态项目,我想用它来填充下拉列表字段.

但是,用户配置文件的模板位于核心数据库中,我想用来填充下拉列表字段的项目位于主/ Web数据库中.

有没有办法将物品送到源场?

c# sitecore

0
推荐指数
1
解决办法
628
查看次数