Sitecore Lucene Search Exclude Item - web-config

in Sitecore Lucene Search, we can exclude a template from search with the following web.config tag :
<include hint="list:ExcludeTemplate">
<template>{8C18027D-CA51-4E5D-A7C1-510965555C}</template>
</include>
My question is :
How can we exclude a specific item from the search using web.config.
Is there a tag like :
<include hint="list:ExcludeItem">
I searched the web but could not find it. The solution and a related reference would be appreciated.
Thanx

Not sure if it's possible to do through the web.config, but you could have a checkbox on your templates which if it's checked it won't be added to the index?
That would mean a custom crawler though, which would do something like:
public class CustomCrawler : DatabaseCrawler
{
protected override bool IsMatch(Item item)
{
if (MainUtil.GetBool(item["include in search"], false))
{
return false;
}
return base.IsMatch(item);
}
}

You can extend the crawler to support this type of configuration. My company extended the Sitecore search contrib module of Alex Shyba to support the inclusion and exclusion of item paths with <include hint="list:IncludePath"> and <include hint="list:ExcludePath">
You can find the specific code in that class: https://github.com/unic/SitecoreSearchContrib/blob/master/scSearchContrib.Crawler/Crawlers/AdvancedDatabaseCrawler.cs
This is only a starter, but with that you can make a deep and clean integration into the crawler. The approach of Trayek would work too.

Related

How do I not include scripts and clientlibs in an experience fragment when exporting to Adobe Target?

I'm trying to build an experience fragment (XF) template in AEM 6.5. We have some custom clientlibs that I want to include when designers are authoring the experience fragment but I don't want to include when the experience fragment is injected via Adobe Target as the clientlibs will already be included on the base page template.
I want the clientlibs on the XF template so components render properly while designing. I've tried building a new page component based on /libs/cq/experience-fragments/components/xfpage and then checking the runmode for author or publish and using the result of that in a data-sly-test to conditionally include them. But I think because the Export to Target option happens on Author, it's including the scripts in the html output when it's exported to Target.
How do I conditionally include clientlibs during authoring of an XF, but not include them when the experience fragment is exported to target and added to a page from there?
There are couple of things you need to do in order to achieve this.
AEM offers the Link Rewriter Provider Interface. This is a ConsumerType interface that you can implement in your bundles, as a service.
It bypasses the modifications AEM performs on internal links of an HTML offer as rendered from an Experience Fragment. This interface allows you to customize the process of rewriting internal HTML links to align with your business needs.
To use the interface you first need to create a bundle containing a new service component that implements the Link Rewriter Provider interface.
This service will be used to plug into the Experience Fragment Export to Target rewriting in order to have access to the various links.
import com.adobe.cq.xf.ExperienceFragmentLinkRewriterProvider;
import com.adobe.cq.xf.ExperienceFragmentVariation;
import org.osgi.service.component.annotations.Service;
import org.osgi.service.component.annotations.Component;
#Component
#Service
public class GeneralLinkRewriter implements ExperienceFragmentLinkRewriterProvider {
#Override
public String rewriteLink(String link, String tag, String attribute) {
return null;
}
#Override
public boolean shouldRewrite(ExperienceFragmentVariation experienceFragment) {
return false;
}
#Override
public int getPriority() {
return 0;
}
}
shouldRewrite
You need to indicate to the system whether it needs to rewrite the links when a call is made for Export to Target on a certain Experience Fragment variation. You do this by implementing the method:
shouldRewrite(ExperienceFragmentVariation experienceFragment);
For example:
#Override
public boolean shouldRewrite(ExperienceFragmentVariation experienceFragment) {
return experienceFragment.getPath().equals("/content/experience-fragment/master");
}
This method receives, as a parameter, the Experience Fragment Variation that the Export to Target system is currently rewriting.
In the example above, we would like to rewrite:
links present in src
href attributes only
for a specific Experience Fragment:
/content/experience-fragment/
Any other Experience Fragments that pass through the Export to Target system are ignored and not affected by changes implemented in this Service.
rewriteLink
For the Experience Fragment variation impacted by the rewriting process, it will then proceed to let the service handle the link rewriting. Everytime a link is encountered in the internal HTML, the following method is invoked:
rewriteLink(String link, String tag, String attribute)
As input, the method receives the parameters:
link
The String representation of the link that is currently being processed. This is usually a relative URL pointing to the resource on the author instance.
tag
The name of the HTML element that is currently being processed.
attribute
The exact attribute name.
If, for example, the Export to Target system is currently processing this element, you can define CSSInclude as:
<link rel="stylesheet" href="/etc.clientlibs/foundation/clientlibs/main.css" type="text/css">
The call to the rewriteLink() method is done using these parameters:
rewriteLink(link="/etc.clientlibs/foundation/clientlibs/main.css", tag="link", attribute="href" )
When you create the service you can make decisions based on the given input, and then rewrite the link accordingly.

Do not allow multiple custom formats Tinymce

When playing around in the online editor at this url: https://www.tiny.cloud/docs/demo/format-custom/ it is quite possible to apply multiple custom formats.
I would claim multiple custom formats is the default behaviour, however we have a request to change this. Is it even possible to configure Tinymce to allow only one custom format at a time? Given the screenshot example, let's say it's not allowed to combine "red header" with "bold text"?
This isn't really Episerver-specific, but rather about TinyMCE.
There are examples of people creating a custom format button which only allows one (1) format to be selected: https://codepen.io/thibbiuf/pen/JKBkXy?editors=1000
You could create your own TinyMCE plugin and then add it to the editor in Episerver:
[ModuleDependency(typeof(TinyMceInitialization))]
public class ExtendedTinyMceInitialization : IConfigurableModule
{
public void Initialize(InitializationEngine context)
{
}
public void Uninitialize(InitializationEngine context)
{
}
public void ConfigureContainer(ServiceConfigurationContext context)
{
context.Services.Configure<TinyMceConfiguration>(config =>
{
config.Default()
.AddPlugin("custom_styleselect")
.AppendToolbar("custom_styleselect");
});
}
}
There are multiple ways to add a TinyMCE plugin, but one way is to load a custom script file when TinyMCE loads in Episerver by adding something like the following to module.config:
<?xml version="1.0" encoding="utf-8"?>
<module name="Your.Website" >
<clientResources>
<add name="epi-addon-tinymce.main" path="ClientResources/tinymce/custom_styleselect/Plugin.js" resourceType="Script" />
</clientResources>
</module>

GWT validation framework, how to specify location of internationalization bundle

This one is related to my previous post. Is it possible in GWT validation framework to specify location of ValidationMessages.properties files and their names? I already have messages translations in my application and I'd prefer them to be in one location.
You could create a custom UserValidationMessagesResolver:
public class CustomValidationMessagesResolver extends AbstractValidationMessageResolver implements UserValidationMessagesResolver {
protected CustomValidationMessagesResolver() {
super((ConstantsWithLookup) GWT.create(ValidationConstants.class));
}
}
In the above code, ValidationConstants is the class resulting from running I18NSync on my properties file.
Then in *.gwt.xml:
<replace-with class="yourpackage.client.validation.CustomValidationMessagesResolver">
<when-type-is class="com.google.gwt.validation.client.UserValidationMessagesResolver" />
</replace-with>
You can find a complete example here.

How do I create a simple joomla plugin?

I'm having a real problem unstanding somthing thats probably very easy about creating and using joomla plugins.
Here is what I've done so far.
I've created a sample joomla plugin using the following two files inside of a folder and named them all the same.
I listed their contents below.
The plugin installs correctly through the admin panel
Then I enable it through plugin manager
ok. all set to go.
How do I use the plugin on an article once I've enabled the plugin?
ZIP FOLDER: MakePlugIn
FOLDER: MakePlugIn
MakePlugIn.php -
<?php
// No direct access allowed to this file
defined( '_JEXEC' ) or die( 'Restricted access' );
// Import Joomla! Plugin library file
jimport('joomla.plugin.plugin');
//The Content plugin MakePlugIn
class plgContentMakePlugIn extends JPlugin
{
function plgContentMakePlugIn (&$subject)
{
parent::__construct ($subject);
}
function onPrepareContent (&$article, &$params, $page=0)
{
print "I am a happy plugin";
}
}
?>
MakePlugIn.xml -
<?xml version="1.0" encoding="utf-8"?>
<install version="1.5" type="plugin" group="content">
<name>Make-Plug-In</name>
<author>Make-Plug-In</author>
<creationDate>03/15/2011</creationDate>
<copyright>Copyright (C) 2011 Holder. All rights reserved.</copyright>
<license>GNU General Public License</license>
<authorEmail>authoremail#website.com</authorEmail>
<authorUrl>www.authorwebsite.com</authorUrl>
<version>1.0</version>
<description>Make-Plug-In test</description>
<files>
<filename plugin="MakePlugIn">MakePlugIn.php</filename>
</files>
</install>
You should not be echoing or printing information in the plug-in.
The method is receiving article reference as a parameter, modify it and you are good. You can use var_dump to quickly identify proper object type and properties.
Here is Joomla tutorial on creating Content Plug-in.
Updated on 3/17/2011
This is in response to first comment.
In order to modify the article modify the value of referenced object &$article.
See example below:
function onPrepareContent( &$article, &$params, $limitstart )
{
// Include you file with ajax code
JHTML::_('script', 'ajax-file.js', 'media/path/to/js/dir/');
// Create ajax div
$ajaxDiv = '<div id="ajax-div"></div>';
// Modify article text by adding the div for ajax at the top
$article->text = $ajaxDiv . PHP_EOL . $article->text;
return true;
}
Adding external JS to the head of the document.

Howto hide a preference page in an eclipse RCP

I have an eclipse rcp and want to hide the security and help prerence pages. How can I do that?
I was looking for the same thing and found the solution in this link:
http://sourceforge.net/apps/trac/fable/wiki/Preferences
Cheers.
Stefan
Disable help preferences ¶
Put the following code into your subclass of org.eclipse.ui.application.WorkbenchAdvisor, and it removes the "Help" group from RCP preference dialog:
public void postStartup() {
PreferenceManager pm = PlatformUI.getWorkbench().getPreferenceManager( );
pm.remove( "org.eclipse.help.ui.browsersPreferencePage" );
}
"org.eclipse.help.ui.browsersPreferencePage" is the ID for the preferences extension point.
Add Perspective preferences ¶
Remark : to find plugin id preferences, select Window-->show view--> PDE Runtime--> Plugin Registry ..... and try to find what you are looking for .....
For example, for "Workbench preferences", have a look in fable.eclipse.ui.ide and extension org.eclipse.ui.preferencePages: id="org.eclipse.ui.preferencePages.Workbench"
If you want to add only perspective (for example) preferences, add a preference extension in MANIFEST.XML :
id : org.eclipse.ui.preferencePages.Perspectives
name:perspective(fable)
class:org.eclipse.ui.internal.ide.dialogs.IDEPerspectivesPreferencePage
//Add : org.eclipse.ui.ide in your Dependencies
In ApplicationWorkBenchAdvisor :
public void postStartup() {
PreferenceManager pm = PlatformUI.getWorkbench().getPreferenceManager( );
pm.remove( ""org.eclipse.ui.preferencePages.Workbench"browsersPreferencePage" );
}
public String getInitialWindowPerspectiveId() {
IPreferenceStore pref = Activator.getDefault().getPreferenceStore();
String ret = pref.getDefaultString(IWorkbenchPreferenceConstants.DEFAULT_PERSPECTIVE_ID);
ret=(ret==null || ret.equals(""))?"yourDefaultPerspectiveID":ret;
return ret;
}//
According to this entry, you could use the "workbench activities" mechanism, and:
define separate activities corresponding to the different access levels
define your actions in regular action sets, grouped according to access level
associate each activity with the appropriate action sets via
activityPatternBinding elements
set the enabled activity ids after authentication, early in the workbench
lifecycle, e.g. from your WorkbenchAdvisor's preStartup() method.
(Note, the above was for a filtering based on user's permissions, but it could be generalize to other criteria.)
Regarding the preference pages for the storage and help, you should bind the id of those pages with an activity you know you can disable:
<activityPatternBinding
activityId="org.eclipse.javaDevelopment"
pattern="org\.eclipse\.help\..*/.*">
</activityPatternBinding>
would disable all menu/preferences/views related to help.
If you use org.eclipse.help.ui.PrefPageHelp\..*, it would only bind prefPageHelp and prefPageHelpContent.
If you add another activity binding extension with
org.eclipse.equinox.security.ui.sec_storage_preferences_context, that would also take care of the Secure Storage preference page.