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
Related
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")
In laravel 4, it's really convenient to do pagination. When the page parameter is missing, the default page is the first page. In my project, it's better to be the last page as default value.
Currently I'm using following UGLY way to hack the pagination. Is there any better way to do this?
if(!Input::get('page') && $comments->getLastPage() > 1)
//Redirect with page=lastPage
And the question can be also asked as that can I set the current page of paginate() function manually? If no, what can I do if I don't want the page parameter to be named page.
If you can live with setting the pagination manually:
// check if a page is set
if(!Input::get('page'))
{
// work out the last page
$lastPage = ceil($totalItems/$perPage);
// set the page - maybe merge would be better than replace???
Input::replace(array('page' => $lastPage));
}
// manually create the paginator
$paginator = Paginator::make($items, $totalItems, $perPage);
I don't know what you're displaying, but would reversing the sorting not work?
Paginator docs
Hello please read the whole question, this isn't just solved by enabling the modules only for the search page:
I have a few modules that are exclusively shown on the search page in Joomla.
I created a hidden menu entry for the search as well in order to tell modules to only show on this page. This works alright, but when I click one of the results and get redirected to the actual result, then the modules, which should only show up on the search page are still shown in the result page.
Any clue how to fix this? Really annoying as I use 3rd party search enhancing modules, and they are showing on the results.
Using standard Joomla, there's no way to target modules to only the search results page and none of the pages that link off the results – but I know you knew that! The hidden menu item is a help, but does not change the menu item of some of the links off that page. It's all to do with the allocation and use of "Itemids" in Joomla.
To be able to target modules more specifically, you need to use a 3rd-party extension. I developed MetaMod (www.metamodpro.com) to cope with exactly this use case. MetaMod is a wrapper module that can then decide just which other module to include in itself (or not). So you assign the MetaMod to the page, then put a snippet of code inside the MetaMod which decides which other module to include.
In this case, I'd use the following in MetaMod:
if ($core_genius->check("pagetype = search, searchresults")) return XXX;
// replace XXX with the module id of the module to include
// ONLY on the search page, or the searchresults page, but
// no other type of page.
Hope that helps,
Stephen
Although MetaMod is great (I've used it myself & Stephen's support is great!) there is another way to do it without using 3rd party extensions.
You could create new module positions in your template above (or below) the module positions you wanted to use and wrap them in an if statement like so:
<?php if(!isset(JRequest::getString('searchword'))) : ?>
<jdoc:include type="modules" name="right-search" style="xhtml" />
<?php endif; ?>
I am working with typo3 4.7 and trying to redirect the search results of the indexed search plugin to a page in my site and managed to stumble upon the constants editor where I've managed to use it to guide me in setting up the object. Below is the current typoscript of the object in my root template (mapped into a TV template):
# --- SEARCHBOX OBJECT ----------------------------------
lib.searchbox < plugin.tx_indexedsearch
lib.searchbox{
#Disable the advanced search link
show.advancedSearchLink = 0
show.rules = 0
show.alwaysShowPageLinks = 1
#pid of root page is 1 and pid of the search result page is 9
search.rootPidList = 1
search.targetPid = 1
view.defaultPid = 9
result_link_target = 9
}
Thus far I have been unsuccessful in my attempts and all results are displayed in the page in where the search was performed. I would also like to know if it is possible to modify the displayed search box so that only the search field is displayed.
Thanks for your time.
Edit: I have installed and I'm trying out solr, if anyone has any experience with it pls feel free to help resolve this issue. My two problems with solr so far is that whilst search does re-direct to the right page, (1) the search box is way too big so I need to be able to modify the display of this box (to remove the button and reduce the size) (2) it spouts som e messages about search rules and returns nothing so far.
Edit 2: Seems solr is the way forward. I have managed to get everything I want done except the result output. I lost a few days (5) before realising that the tomcat container was bound to an ipv6 protocol interface. Resolving that (see here for those who may stumble upon the same problem for how to resolve this) has meant I can now remotely admin the solr server for more information. The pages are being indexed (Not regularly as specified in the scheduler) but I still get no results on the result page, and devlog only returns warning about there not being typo3 search markers despite my TV templates being peppered with them. I can only guess that maybe I'm to mark the results page with some type of marker to get the results to show at this point.
plugin.tx_indexedsearch {
search {
targetPid >
targetPid = 123
}
}
Reference: http://lists.typo3.org/pipermail/typo3-team-core/2010-March/036269.html
Experience: works even in TYPO3 version 6.x.
Default setting for plugin.tx_indexedsearch.search.targetPid is:
plugin.tx_indexedsearch {
search {
# TSFE:id is always the current page
targetPid.data = TSFE:id
}
}
I have never used the indexedsearch plugin as the searchbox on all of my pages.
Normally, I do this
Create a page with the indexed_search plugin as its content, this is
where all search requests are answered
Use macina_searchbox to
display a search box as part of the template
To elaborate:
Install macina_searchbox, and use this Typoscript to configure it
plugin.tx_macinasearchbox_pi1 {
pidSearchpage = {PID_OF_SEARCH_RESULT_PAGE}
templateFile = {PATH_TO_TEMPLATE_FILE_FOR_SEARCH_BOX}
}
Then, include macina_searchbox like so
lib.searchbox < plugin.tx_macinasearchbox_pi1
The search result page just needs the indexed_search plugin where you want the results to be displayed.
I would just create a search box, copy the HTML-Code, adjust action-url and HTML-Code and output it. IMHO there is no need, to render it via Plugin, if you just need an search-input field and an button. But do not forget the hidden fields!
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.