PHPackages                             dnadesign/silverstripe-elemental-textcontentforsearch - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. dnadesign/silverstripe-elemental-textcontentforsearch

ActiveSilverstripe-vendormodule[Search &amp; Filtering](/categories/search)

dnadesign/silverstripe-elemental-textcontentforsearch
=====================================================

A set of helper methods to facilitate indexing elemental pages text content

2.0.0(8mo ago)04.6k↑61.5%BSD-3-ClausePHP

Since Sep 20Pushed 8mo ago6 watchersCompare

[ Source](https://github.com/dnadesign/silverstripe-elemental-textcontentforsearch)[ Packagist](https://packagist.org/packages/dnadesign/silverstripe-elemental-textcontentforsearch)[ RSS](/packages/dnadesign-silverstripe-elemental-textcontentforsearch/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (2)Versions (6)Used By (0)

silverstripe-elemental-textcontentforsearch
===========================================

[](#silverstripe-elemental-textcontentforsearch)

A set of helper methods to facilitate searching elemental pages

Requirements
------------

[](#requirements)

- Silverstripe CMS ^6
- Silverstripe Elemental ^6

Installation
------------

[](#installation)

```
composer require dnadesign/silverstripe-elemental-textcontentforsearch

```

The following YAML config will enable elements on every `Page` object, replacing the standard `Content` rich text field and add access to the `getTextContentForSearch` method

**mysite/\_config/elements.yml**

```
Page:
  extensions:
    - DNADesign\Elemental\Extensions\ElementalPageExtension
    - DNADesign\Elemental\Extensions\ElementalPageTextSearchExtension
```

Usage
-----

[](#usage)

### SolrIndex

[](#solrindex)

We recommend you use the `TextContentForSearch` instead of the `ElementForSearch` method in your index. This avoids rendering the entire elemental area, which would include images and complex elements, which consumes a lot of resources during render and don't end up in the index anyway.

```
class ElementalSolrIndex extends SolrIndex
{
    public function init()
    {
        $this->addClass(Page::class);
        $this->addAllFulltextFields();
        /** @see ElementalPageTextContentSearchExtension::getTextContentForSearch */
        $this->addFulltextField('TextContentForSearch');
    }
}
```

Configuration
-------------

[](#configuration)

By default, the process will extract any `Varchar`, `Text` and `HTMLText` field from the elements. If you require any other type of fields to be considered for indexing, you ca update the config as follow:

```
Page:
  db_text_field_types:
    - CustomFieldType
```

You can exclude fields per element. By default, the `Style` and `ExtraClass` fields are excluded as they wouldn't bring any value to the search. To exclude a field, you can either set the config on the class or in the yaml:

```
DNADesign\Elemental\Models\ElementContent:
  exclude_fields_from_search:
    - Title
```

or

```
class MyCustomElement extends BaseElement
{
    private static $exclude_fields_from_search = [
        'Title'
    ];
}
```

In reverse, you can add a field in the same way.

```
DNADesign\Elemental\Models\ElementContent:
  include_fields_in_search:
    - AlternativeText
```

or

```
class MyCustomElement extends BaseElement
{
    private static $include_fields_in_search = [
        'AlternativeText'
    ];
}
```

In addition, you can implement a `updateTextFieldsForSearch` method on any element or extension to update the list of fields to include in search.

Some elements may have complex relationships that are not explored by the default process. You can implement `addTextContentForSearch` to concatenate extra content to the final string.

```
class MyCustomElement extends BaseElement
{
    private static $has_many = [
        'AccordionItems' => AccordionItem::class
    ];

    public function addTextContentForSearch()
    {
        $titles = [];
        foreach($this->AccordionItems() as $item) {
            $titles[] = $item->Title;
        }
        return implode(' ', $titles);
    }
}
```

Ultimately, you can manipulate the final string to be return by implementing `updateTextContentForSearch` method.

```
class MyCustomElement extends BaseElement
{
    public function updateTextContentForSearch($string)
    {
        // Remove any occurrence of forbiddenWord in the final string
        return = str_replace('forbiddenWord', '', $string);
    }
}
```

By default, every element is considered for indexing. If you wish to exclude an element from the search, you can use the config as follow:

```
DNADesign\Elemental\Models\ElementContent:
  exclude_content_from_search: true
```

or

```
class MyCustomElement extends BaseElement
{
    private static $exclude_content_from_search = true;
}
```

### Debugging

[](#debugging)

As it is difficult to see what is being included in the solr index, the module exposes a read only text field with the content generated by the `getTextContentForSearch` method. You can hide this field by amending the config:

```
DNADesign\Elemental\Extensions\ElementalPageTextSearchExtension:
  show_text_content_search_in_cms: false
```

Notes:
------

[](#notes)

- The introspective process will explore any `VirtualElement` and extract the parent element text fields

To do:
------

[](#to-do)

- Add an option to store the search string in the DB on save?

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance59

Moderate activity, may be stable

Popularity22

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~280 days

Total

5

Last Release

261d ago

Major Versions

1.x-dev → 2.0.02025-10-16

### Community

Maintainers

![](https://www.gravatar.com/avatar/efd88fa106982bcf2e3cd689e6a37d352c54308d14dedeac4ac477a47a432363?d=identicon)[DNADesign](/maintainers/DNADesign)

![](https://www.gravatar.com/avatar/e55a584eaac053bdbe811b1039dd00ac30da0c7978a5efbb6082504c610678d2?d=identicon)[alex-dna](/maintainers/alex-dna)

---

Top Contributors

[![alex-dna](https://avatars.githubusercontent.com/u/6982515?v=4)](https://github.com/alex-dna "alex-dna (7 commits)")[![Cambis](https://avatars.githubusercontent.com/u/12287346?v=4)](https://github.com/Cambis "Cambis (2 commits)")[![jules0x](https://avatars.githubusercontent.com/u/8979741?v=4)](https://github.com/jules0x "jules0x (2 commits)")[![djmattski](https://avatars.githubusercontent.com/u/3836638?v=4)](https://github.com/djmattski "djmattski (1 commits)")[![LABCAT](https://avatars.githubusercontent.com/u/9105153?v=4)](https://github.com/LABCAT "LABCAT (1 commits)")[![lukereative](https://avatars.githubusercontent.com/u/1415622?v=4)](https://github.com/lukereative "lukereative (1 commits)")

---

Tags

silverstripeelementalfulltextsearch

### Embed Badge

![Health badge](/badges/dnadesign-silverstripe-elemental-textcontentforsearch/health.svg)

```
[![Health](https://phpackages.com/badges/dnadesign-silverstripe-elemental-textcontentforsearch/health.svg)](https://phpackages.com/packages/dnadesign-silverstripe-elemental-textcontentforsearch)
```

###  Alternatives

[dnadesign/silverstripe-elemental

Elemental pagetype and collection of Elements

1141.1M309](/packages/dnadesign-silverstripe-elemental)[heyday/silverstripe-elastica

Provides Elastic Search integration for SilverStripe DataObjects using Elastica

1138.5k2](/packages/heyday-silverstripe-elastica)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
