AEM - Search for both assets and sites - search

Is there a way to search for a particular metadata or free text search for both assets and pages in AEM (6.1)? or later?
So that the search result will have both images/ pdfs etc and also the actual pages in the sites console?

AEM 6.2 introduced omnisearch function (magnifier icon located at the top). Depending on your location, UI will add the location parameter in the Omnisearch. For instance, if you are in Assets, clicking on omnisearch icon will automatically add Location:Assets into the search box and restrict the search result. You may manually remove Location restriction to do site wide search against all content including sites, media assets, user and groups, etc.

predicatesMap.put("group.p.or", "true"); //combine this group with OR
predicatesMap.put("group.1_group.path", searchRootPagePath);
predicatesMap.put("group.1_group.type", NT_PAGE);
predicatesMap.put("group.2_group.path", PROP_SEARCH_ROOT_ASSETS);
predicatesMap.put("group.2_group.type", NT_DAM_ASSET);
PredicateGroup predicates = PredicateConverter.createPredicates(predicatesMap);
ResourceResolver resourceResolver = request.getResource().getResourceResolver();
Query query = this.queryBuilder.createQuery(predicates, resourceResolver.adaptTo(Session.class));
if (resultsSize != 0)
{
query.setHitsPerPage(resultsSize);
}
if (resultsOffset != 0)
{
query.setStart(resultsOffset);
}
SearchResult searchResult = query.getResult();
Just introduce groups and query both pages on some path (example:
"content/we-retail") and assets ("content/dam/we-retail")

Related

Editing Sharepoint Online HTML content using Client Object Model

We have a sharepoint online site with a good amount of pages that have href links to a shared in-house network server. Example: file://servername/sharedFolder This way when the user clicks the href - it directs them to the location in the file explorer if using IE or Edge.
Due to server maintenance - we needed to rename the server. So now "servername" is "servername1". This messes up all the links on the sharepoint site.
I need to iterate over all the pages on the sharepoint site, and fix the hrefs.
I apologize im very new to sharepoint so maybe im missing something very simple.
What i have right now is the following:
using (ClientContext ClientWebContext = new ClientContext("site"))
{
ClientWebContext.Credentials = new SharePointOnlineCredentials("username", ss);
Web web = ClientWebContext.Web;
Microsoft.SharePoint.Client.File file = ClientWebContext.Web.GetFileByServerRelativeUrl("page");
ClientWebContext.Load(web, w => w.Title, w => w.Description, w=> w.Lists);
ClientWebContext.Load(file, f => f.Length, f=> f.ServerRelativeUrl, f=> f.Name, f=>f.);
ClientResult<System.IO.Stream> str = file.OpenBinaryStream();
ClientWebContext.ExecuteQuery();
FileInformation fileInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(ClientWebContext, file.ServerRelativeUrl);using (FileStream filestream = new FileStream("C:" + "\\" + file.Name, FileMode.Create))
{
fileInfo.Stream.CopyTo(filestream);
}
}
The idea was to download the page - parse the html and update the hrefs, then write the page back out to the sharepoint server. But when i view the file that has been downloaded it doesnt contain any of the html that is actually on the page.
If i go to a page, select "edit", then select "Edit Source" I can view and edit all the html in raw format.
I guess the question is - how do i get this html and how do i pro grammatically update it.
EDIT:
A typical sharepoint page contains a table, cells & text inside of those cells. The text then contains links to the server I was talking about above. The sharepoint site is essentially being used as a wiki for new employees and a resource for existing employees to find information quickly. It doesnt contain many complex web parts and embedded code, mainly just a table, cells and text.
Thanks,
-John
Yeah, I don't think this approach will fly.
Again, different types of SharePoint pages have different web parts. Modern SharePoint site page, Wiki page, web part page. They all can have text web parts and/or page elements that can hold HTML, and in some, the WYSIWYG default presentation can be changed to a HTML editor. Then there are also list web parts, link web parts, and all kinds of stuff that can have an underlying link URL.
But these page elements are SharePoint artifacts. The page elements and their contents are stored in an internal SharePoint database. The page chrome and styling is also stored in different parts of the database. The SharePoint server processes the different parts that make up a page. On the SharePoint server side, these page elements then get translated and rendered into HTML that is served to the end user's browser.
You cannot take this rendered end result and expect to use it to change the underlying source of the HTML.
You need to get to the source. Again, what exactly that source is depends on the type of page used. Just because it is "in SharePoint" doesn't identify the page type.
Sorry, I know this is not what you want to hear, but if you want to manipulate SharePoint content, you need to acquire an understanding of what SharePoint is and what its moving parts are.

Multiple Single Html Pages Sails.js

I have a lot of landings in my application, where in index page I have to change some parameters in hrefs according to users GET query.
So, in views folder i have a lot different ./pattterns/pattern1/index.ejs for each single web page and in assets folder
I have ./patterns/pattern1/static-css-and-img-and-etc.
Now, the problem is I need to fix all links from pattern1/index.ejs to this static files, because by default static is searched in /assets/ and I can't figre out how to point in every other rending of view to specific /assets/patterns/pattern1/ folder to fetch static from.
Any suggestions would be appreciated)
You can overwrite the "layout"-setting in the render-call:
var templatetype = "patterns/pattern1/";
data = {
....
layout: templatetype + "index.ejs"
};
res.view(templatetype +"mysite",data);
In this example SailsJS is looking for "patterns/pattern1/index.ejs" and render this with "patterns/pattern1/mysite.ejs"

Display portlets on search page in plone?

How can I add portlets to a plone search or search results page?
Using ##manage-portlets doesn't work (www.mysite.com/search/##manage-portlets), I get an empty search result.
I'd like to display the portlets of the root folder also on that pages, in my case the search column uses the whole page width.
I'm using plone 4.0.1.
Search results template has left and right portlet columns disabled (hidden):
http://dev.plone.org/plone/browser/Plone/tags/4.0.1/Products/CMFPlone/skins/plone_forms/search.pt#L19
If you want to display portlets there you should customize or override your search.pt template by removing the corresopnding line:
disable_column_one python:request.set('disable_plone.leftcolumn',1);
disable_column_two python:request.set('disable_plone.rightcolumn',1);
Anyway this will not let you set specific portlets for search results, as it's just a template opened in the Plone site root context. So you'll see Plone site root portlets.
The only way I think you could achieve that is:
Create a new special folder for search results (i.e. search-results).
Set your desired portlets in the new folder.
Set search as default page for that folder.
Modify search viewlet to redirect not to /search but to /search-results.
Modify search_form template (adavnced search) to redirect not to /search but to /search-results.
I did it once in a Plone 3 site and it worked. Although it wasn't to display special portlets.

How can I modify the Joomla search component to use default search areas?

I'm using a Joomla 1.5 installation and the Joomla search component allows you to search in certain "search areas": Articles / News Feeds / Sections / Categories / Web Links ...
I don't want my users to have to worry about these things however and I also don't want them getting "sections" or "categories" as results - it's just a simple site with about 5 fixed pages and some simple news/event announcements that I use articles for.
I want to set some default "search areas" to use, and hide the search areas from the search results page. Hiding the search areas from the results page wasn't a problem - I just modified the default_form.php in the com_search component.
However, I have no idea how the "search areas" actually work and how I can change the functionality that the search function always only searches on "Articles" and nothing else...
There's two places where I can see it coming back:
In controller.php (in the com_search component) - you get the areas from the checkbox-list on the page:
$areas = JRequest::getVar('areas', null, 'post', 'array');
if ($areas) {
foreach($areas as $area)
{
$post['areas'][] = JFilterInput::clean($area, 'cmd');
}
}
In search.php (also in the com_search component) - you get the areas as specified and add them as "active areas" for your search query:
$areas = JRequest::getVar('areas');
$this->setAreas($areas);
Instead I wish to add my own $areas variable, but I have no idea what it contains and how I might change it to a default value of only 'Articles'.
The areas are driven by the search plugins in the backend. Have a look at the list of plugins and disable the ones you don't want.

Drupal - Hide a single page from search index

I've taken over an existing Drupal installation and have been asked to remove a single page from the site search results. I know about the lullabot tutorial through this question: Hide Drupal nodes from search, but that talks about excluding a class of content when I really just want to exclude a single page.
I've tried manually deleting the node from the search_index table, but that didn't seem to work either.
Any recommendations for excluding a single regular content page from the search index?
I've just had to work out something similar (hiding particular cck fields from the search index on a node by node basis) - took some tracking down, but this turned out to be the answer:
<?php
function mymodule_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
switch ($op) {
case 'view':
$nid = ---insert your node id here---;
if ($node->build_mode == NODE_BUILD_SEARCH_INDEX && $node->nid == $nid) {
unset($node);
}
break;
}
}
?>
The problem is that the search index follows 1) the access permissions. A module that hides single pages for users, is private module. A module that allows per-node access settings. Search will then follow the access settings and will hide the hidden page from search results.
1) technically not entirely correct
Module restrict_content is a perfect tool for what you need

Resources