Custom inbound pipe doesn't work
Hi, I am trying to delimit my search by their parent and child pages. This used to be in 3.7 but it's gone in the new versions. Currently i am on 6.1 , 6.2
for example this is my tree:
About-us(group page)
About
All News
Graduation
Research
Staff (Group Page)
Faculty
IT
Professors
Awards
I want to be somewhere in the About section, and if i want to search something inside the about section i want to show up. However if i want to search something outside of my group page i don't want any results.
I tried a few different methods of doing this based on other people's posts. However i have had no luck. If there something wrong with my Code?
public
class
Search_Delimiter_Test : PageInboundPipe
public
override
void
PushData(IList<Telerik.Sitefinity.Publishing.PublishingSystemEventInfo> items)
List<Telerik.Sitefinity.Publishing.PublishingSystemEventInfo> myItems =
new
List<Telerik.Sitefinity.Publishing.PublishingSystemEventInfo>();
foreach
(var item
in
items)
PageNode node =
null
;
if
(item.Item
is
WrapperObject && ((WrapperObject)item.Item).WrappedObject !=
null
)
node = (PageNode)((WrapperObject)item.Item).WrappedObject;
else
node = ((PageNode)item.Item);
if
(node.Page !=
null
&& node.Page.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live)
while
(
true
)
node = node.Parent;
if
(node.Title.Equals(
"about"
,StringComparison.InvariantCultureIgnoreCase))
//this will index only one page node with its children, don`t add items here for the pages that shouldn`t be indexed
myItems.Add(item);
break
;
if
(node.Parent ==
null
)
break
;
base
.PushData(myItems);
protected
void
Application_Start(
object
sender, EventArgs e)
Telerik.Sitefinity.Abstractions.Bootstrapper.Initialized -=
new
EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);
Telerik.Sitefinity.Abstractions.Bootstrapper.Initialized +=
new
EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);
void
Bootstrapper_Initialized(
object
sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
if
(e.CommandName ==
"Bootstrapped"
)
this
.RegisterProductPipes();
private
void
RegisterProductPipes()
//unregister default pipe
Telerik.Sitefinity.Publishing.PublishingSystemFactory.UnregisterPipe(Telerik.Sitefinity.Publishing.Pipes.PageInboundPipe.PipeName);
// unregister default pipe.
//register pipes
Telerik.Sitefinity.Publishing.PublishingSystemFactory.RegisterPipe(SitefinityWebApp.Search_Delimiter_Test.PipeName,
typeof
(SitefinityWebApp.Search_Delimiter_Test));
var pipeSettings1 = Telerik.Sitefinity.Publishing.PublishingSystemFactory.GetPipeSettings(SitefinityWebApp.Search_Delimiter_Test.PipeName);
Telerik.Sitefinity.Publishing.PublishingSystemFactory.RegisterTemplatePipe(
"SearchItemTemplate"
, pipeSettings1);
//create and register mapping
List<Telerik.Sitefinity.Publishing.Model.Mapping> mappingsList =
new
System.Collections.Generic.List<Telerik.Sitefinity.Publishing.Model.Mapping>();
var contentMapping =
new
Telerik.Sitefinity.Publishing.Model.Mapping() DestinationPropertyName =
"Content"
, IsRequired =
true
, SourcePropertyNames =
new
[]
"Title"
;
mappingsList.Add(contentMapping);
var linkMapping =
new
Telerik.Sitefinity.Publishing.Model.Mapping() DestinationPropertyName =
"Link"
, IsRequired =
true
, SourcePropertyNames =
new
[]
"Link"
;
linkMapping.Translations.Add(
new
Telerik.Sitefinity.Publishing.Model.PipeMappingTranslation() TranslatorName = Telerik.Sitefinity.Publishing.Translators.UrlShortenerTranslator.TranslatorName );
mappingsList.Add(linkMapping);
Telerik.Sitefinity.Publishing.PublishingSystemFactory.RegisterPipeMappings(SitefinityWebApp.Search_Delimiter_Test.PipeName,
true
, mappingsList);
// end registerProductPipes
Hello,
What exactly is the issue that you are experiencing?
I have tried your code and it seems to do exactly what you have described. All text from pages under About is found and text from under Staff cannot be found.
Regards,
Boyko Karadzhov
Telerik
really? When i test it it is finding everything from the whole site. Other than these 2 files is there something i am missing to make it function on my machine?
Hi Daniel,
I have created a new search index with scope "Static HTML from pages" and using it the search yielded the expected results using just the code you posted below.
It is possible your scope is set to browse all the content and by doing this it won't know that some content is not for the "About" section.
Regards,
Boyko Karadzhov
Telerik
It's still not working, I double checked every site is using the same search index, and yes, it is set to "static html". When i go into the about section i can search whatever, and it will throw results from all over the site.
is there a checkbox i could have had missed? or another program i failed to write or edit, or even a config file or something?
could it be my node? What am i supposed to put into node.Title would that be the page/grouppage name that is listed in the pages screen?
Hi,
Go to "~/App_Data/Sitefinity/Search" and delete all files in there. After that reindex the site.
If this doesn't help try to comment out everything inside PushData of your custom pipe and see if anything can be searched. If you can still search everywhere in the site then we know that the pipe is not used at all.
Regards,
Boyko Karadzhov
Telerik
so i deleted everything from the search folder, and then i reindexed, and the search still returned everything.
I commented out everything inside the pushdata method, so it's completely empty. I reindexed again. and did a search.
And again it returned everything.
Could is possibly be because of migration?
I am taking over for an employee who was working on migration assignment before, and she moved from 3.7 to 6.2 could my global asax file be different than what it is supposed to be on 6.2? This is my Global asax file in completion.
01.
<%@ Application Language=
"C#"
%>
02.
03.
<script runat=
"server"
>
04.
05.
public
class
Global : System.Web.HttpApplication
06.
07.
08.
public
override
string
GetVaryByCustomString(HttpContext context,
string
custom)
09.
10.
if
(custom.Equals(
"cms"
))
11.
12.
return
String.Concat(context.Request.Url.Host, context.Request.RawUrl, context.Request.Browser.Type).ToLower();
13.
14.
return
base
.GetVaryByCustomString(context, custom);
15.
16.
17.
protected
void
Application_Start(
object
sender, EventArgs e)
18.
19.
Telerik.Sitefinity.Abstractions.Bootstrapper.Initialized -=
new
EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);
20.
Telerik.Sitefinity.Abstractions.Bootstrapper.Initialized +=
new
EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);
21.
22.
23.
void
Bootstrapper_Initialized(
object
sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
24.
25.
if
(e.CommandName ==
"Bootstrapped"
)
26.
27.
this
.RegisterProductPipes();
28.
29.
30.
31.
32.
private
void
RegisterProductPipes()
33.
34.
//unregister default pipe
35.
Telerik.Sitefinity.Publishing.PublishingSystemFactory.UnregisterPipe(Telerik.Sitefinity.Publishing.Pipes.PageInboundPipe.PipeName);
36.
37.
//register pipes
38.
Telerik.Sitefinity.Publishing.PublishingSystemFactory.RegisterPipe(SitefinityWebApp.Search_Delimiter_Test.PipeName,
typeof
(SitefinityWebApp.Search_Delimiter_Test));
39.
var pipeSettings1 = Telerik.Sitefinity.Publishing.PublishingSystemFactory.GetPipeSettings(SitefinityWebApp.Search_Delimiter_Test.PipeName);
40.
Telerik.Sitefinity.Publishing.PublishingSystemFactory.RegisterTemplatePipe(
"SearchItemTemplate"
, pipeSettings1);
41.
42.
//create and register mapping
43.
List<Telerik.Sitefinity.Publishing.Model.Mapping> mappingsList =
new
System.Collections.Generic.List<Telerik.Sitefinity.Publishing.Model.Mapping>();
44.
var contentMapping =
new
Telerik.Sitefinity.Publishing.Model.Mapping() DestinationPropertyName =
"Content"
, IsRequired =
true
, SourcePropertyNames =
new
[]
"Title"
;
45.
mappingsList.Add(contentMapping);
46.
var linkMapping =
new
Telerik.Sitefinity.Publishing.Model.Mapping() DestinationPropertyName =
"Link"
, IsRequired =
true
, SourcePropertyNames =
new
[]
"Link"
;
47.
linkMapping.Translations.Add(
new
Telerik.Sitefinity.Publishing.Model.PipeMappingTranslation() TranslatorName = Telerik.Sitefinity.Publishing.Translators.UrlShortenerTranslator.TranslatorName );
48.
mappingsList.Add(linkMapping);
49.
Telerik.Sitefinity.Publishing.PublishingSystemFactory.RegisterPipeMappings(SitefinityWebApp.Search_Delimiter_Test.PipeName,
true
, mappingsList);
50.
51.
// end registerProductPipes
52.
53.
void
Application_End(
object
sender, EventArgs e)
54.
55.
// Code that runs on application shutdown
56.
57.
58.
59.
void
Application_Error(
object
sender, EventArgs e)
60.
61.
// DONE IN WEB.CONFIG
62.
//Exception ex = Server.GetLastError();
63.
//if (ex is HttpException)
64.
//
65.
// HttpException httpEx = ex as HttpException;
66.
// if (httpEx.ErrorCode == 403 || httpEx.Source.StartsWith("Telerik.Cms"))
67.
//
68.
// Response.Redirect("~/Sitefinity/nopermissions.aspx");
69.
// Server.ClearError();
70.
//
71.
//
72.
//else if (ex is Telerik.Security.SecurityApplicationException)
73.
//
74.
// Response.Redirect("~/Sitefinity/nopermissions.aspx");
75.
// Server.ClearError();
76.
//
77.
78.
79.
void
Session_Start(
object
sender, EventArgs e)
80.
81.
// Code that runs when a new session is started
82.
83.
84.
85.
void
Session_End(
object
sender, EventArgs e)
86.
87.
// Code that runs when a session ends.
88.
// Note: The Session_End event is raised only when the sessionstate mode
89.
// is set to InProc in the Web.config file. If session mode is set to StateServer
90.
// or SQLServer, the event is not raised.
91.
92.
93.
94.
</script>
Hello Daniel,
I don't see anything wrong in the Global.asax. Would you please open a support ticket with a link to this forum thread? It will be easier to debug this way.
Regards,
Boyko Karadzhov
Telerik
ok, I have submitted a support ticket. Awaiting a reply now
Hi,
I answered your question in the support ticket - lets continue the discussion there.
Regards,
Bonny
Telerik