We have a dedicated Slack channel where you can ask questions, discuss new features, and provide feedback on the extension. Join us to stay updated and participate in the conversation!
We look forward to seeing you there and engaging with you!
Elevate your TYPO3 website with intelligent, content-driven recommendations
The Semantic Suggestion extension revolutionizes the way related content is presented on TYPO3 websites. Moving beyond traditional "more like this" functionalities based on categories and taxonomies, this extension employs advanced semantic analysis to create genuinely relevant content connections.
- ๐ฏ Highly Relevant Links: Automatically generate connections based on actual content similarity, not just predefined categories.
- โฑ๏ธ Increased User Engagement: Keep visitors on your site longer by offering truly related content.
- ๐ธ๏ธ Semantic Cocoon: Contribute to a high-quality semantic network within your website, enhancing SEO and user navigation.
- ๐ค Intelligent Automation: Reduce manual linking work while improving internal link quality.
While the Semantic Suggestion extension offers powerful capabilities, it's important to note:
- ๐ The similarity calculation process scales exponentially with the number of pages.
- โณ For sites with over 500 pages, the initial calculation may take up to 30 seconds, depending on server capacity.
- ๐ก We recommend using the backend module to assess the caching time for your specific setup.
- ๐ The cache is automatically reset when a page or content is modified, ensuring up-to-date similarity calculations.
๐ Pro Tip: Utilize the backend module to monitor performance and optimize settings for your specific use case.
By leveraging the power of semantic analysis, this extension provides a superior alternative to traditional related content plugins, offering more accurate and valuable content suggestions to your users.
The extension now includes stopwords functionality, significantly improving the accuracy of content analysis. Stopwords are common words (such as "the", "is", "at") that are filtered out before processing the content. This feature enhances the relevance of semantic suggestions by focusing on meaningful content.
A new debug mode has been introduced, which can be activated via TypoScript:
plugin.tx_semanticsuggestion_suggestions.settings.debugMode = 1
When enabled, this mode provides:
Detailed debug information in the backend interface
Comprehensive logs in public/typo3temp/logs/semantic_suggestion.log
This feature is invaluable for developers and administrators looking to fine-tune the extension's performance or troubleshoot issues.
### Backend Module Enhancements
The backend module has been significantly improved:
Optimized "Top 5 Most Similar Page Pairs" display, eliminating duplicate entries
Enhanced statistics and visualizations for better content insights
Improved performance for large-scale page analyses
### For Developers
New API methods are available to access stopwords statistics
The similarity calculation algorithm has been optimized, providing more accurate results
## ๐ Table of Contents
- [Introduction](#-introduction)
- [Features](#-features)
- [Requirements](#-requirements)
- [Installation](#-installation)
- [Configuration](#-configuration)
- [Usage](#-usage)
- [Backend Module](#-backend-module)
- [Similarity Logic](#-similarity-logic)
- [Display Customization](#-display-customization)
- [Multilingual Support](#-multilingual-support)
- [Debugging and Maintenance](#-debugging-and-maintenance)
- [Security](#-security)
- [Performance](#-performance)
- [File Structure](#-file-structure)
- [Unit Tests](#-unit-tests)
- [Contributing](#-contributing)
- [License](#-license)
- [Support](#-support)
### Frontend View
![Frontend view with the same theme](Documentation/Medias/frontend_on_the_same_theme_view.jpg)
## ๐ Features
- ๐ Analyzes subpages of a specified parent page
- ๐ Displays title, associated media, and enhanced text excerpt of suggested pages
- โ๏ธ Highly configurable via TypoScript
- ๐ Customizable parent page ID, proximity threshold, and search depth
- ๐พ Optimized performance with database caching of proximity scores
- ๐ Built-in multilingual support
- ๐งฉ Improved compatibility with various TYPO3 content structures, including Bootstrap Package
- ๐ซ Option to exclude specific pages from analysis and suggestions
## ๐ Requirements
- TYPO3 12.0.0-13.9.99
- PHP 8.0 or higher
## ๐ป Installation
<details>
<summary><strong>Composer Installation (recommended)</strong></summary>
1. Install the extension via composer:
```bash
composer require talan-hdf/semantic-suggestion
- Activate the extension in the TYPO3 Extension Manager
Manual Installation
- Download the extension from the TYPO3 Extension Repository (TER) or the GitHub repository.
- Upload the extension file to your TYPO3 installation's
typo3conf/ext/
directory. - In the TYPO3 backend, go to the Extension Manager and activate the "Semantic Suggestion" extension.
Edit your TypoScript setup to configure the extension:
plugin.tx_semanticsuggestion {
settings {
parentPageId = 1
proximityThreshold = 0.7
maxSuggestions = 3
excerptLength = 150
recursive = 1
excludePages = 8,9,3456
recencyWeight = 0.2
analyzedFields {
title = 1.5
description = 1.0
keywords = 2.0
abstract = 1.2
content = 1.0
}
}
}
The analyzedFields
section allows you to configure the importance of different content fields in the similarity calculation:
Weight | Importance |
---|---|
0.5 | Half as important as standard |
1.0 | Standard importance |
1.5 | 50% more important than standard |
2.0 | Twice as important as standard |
3.0+ | Significantly more important than standard |
Configuration Parameters Explained
parentPageId
: The ID of the parent page from which the analysis startsproximityThreshold
: The minimum similarity threshold for displaying a suggestion (0.0 to 1.0)maxSuggestions
: The maximum number of suggestions to displayexcerptLength
: The maximum length of the text excerpt for each suggestionrecursive
: The search depth in the page tree (0 = only direct children)excludePages
: Comma-separated list of page UIDs to exclude from analysis and suggestionsrecencyWeight
: Weight of recency in similarity calculation (0-1)
The recencyWeight
parameter determines the importance of publication or modification date in similarity calculations:
- 0: Recency has no impact
- 1: Recency has maximum impact
How Recency Weight Works
- Base similarity score is calculated from content
- Recency boost is calculated based on publication/modification dates
- Final similarity is a weighted combination of content similarity and recency boost
Formula:
finalSimilarity = (contentSimilarity * (1 - recencyWeight)) + (recencyBoost * recencyWeight)
Choosing the right value:
- Low (0.1-0.3): Slightly favor recent content
- Medium (0.4-0.6): Balance between content similarity and recency
- High (0.7-0.9): Strongly favor recent content
Consider your specific use case:
- News website: Higher recency weight
- Educational resource: Lower recency weight
- General blog: Medium recency weight
To add the plugin directly in your Fluid template, use:
<f:cObject typoscriptObjectPath='lib.semantic_suggestion' />
This method uses the TypoScript configuration and is suitable for simple integrations.
You can also integrate the Semantic Suggestions plugin using TypoScript. Add the following TypoScript setup to your configuration:
lib.semantic_suggestion = USER
lib.semantic_suggestion {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
extensionName = SemanticSuggestion
pluginName = Suggestions
vendorName = TalanHdf
controller = Suggestions
action = list
}
Then, you can use it in your TypoScript template like this:
page.10 = < lib.semantic_suggestion
Or in specific content elements:
tt_content.semantic_suggestion = COA
tt_content.semantic_suggestion {
10 = < lib.semantic_suggestion
}
Remember to include your TypoScript template in your site configuration or page setup.
The Semantic Suggestion extension includes a powerful backend module providing comprehensive insights into semantic relationships between your pages.
- ๐ Similarity Analysis: Visualize semantic similarity between pages
- ๐ Top Similar Pairs: Quickly identify most related page pairs
- ๐ Distribution of Similarity Scores: Overview of similarity across content
- โ๏ธ Configurable Analysis: Set custom parameters (parent page ID, depth, thresholds)
- ๐ Visual Representation: Intuitive charts and progress bars
- ๐ Detailed Statistics: In-depth page similarity and content relationship data
Access the module under the "Web" menu in the TYPO3 backend.
๐ก Tip: The effectiveness of semantic analysis depends on content quality and quantity. Ensure your pages have meaningful titles, descriptions, and content for best results.
The backend module provides crucial performance metrics to help optimize the extension's operation:
Execution Time (seconds)
- What: Total time for semantic analysis, including page retrieval, calculations, and caching
- Interpretation:
- Lower is better
- High values may indicate need for content structure optimization or increased caching
- 0.00 seconds typically means results were cached
Total Pages Analyzed
- What: Number of pages included in the semantic analysis
- Interpretation:
- Depends on page tree structure and configured analysis depth
- Higher numbers may increase accuracy but also execution time
Similarity Calculations
- What: Total number of page-to-page similarity comparisons
- Calculation: Typically
n * (n-1) / 2
, wheren
is the number of pages analyzed - Interpretation:
- Higher numbers indicate more comprehensive analysis
- May impact performance with large page sets
Results from Cache
- What: Indicates whether results were retrieved from cache (Yes/No)
- Interpretation:
- "Yes" means faster execution (cached results)
- "No" indicates a fresh analysis was performed
- Frequent "No" results might suggest too frequent cache clearing or rapidly changing content
- Caching: Adjust caching configuration to match your update frequency
- Analysis Depth: Balance comprehensiveness with performance
- Excluded Pages: Use
excludePages
setting to omit irrelevant pages - Content Structure: Organize content to minimize analyzed pages without compromising quality
Monitor these metrics to fine-tune the extension's configuration for your specific use case.
The extension employs a custom similarity calculation to determine related pages:
- Data Gathering: Collects title, description, keywords, and content for each subpage of the specified parent page.
- Similarity Calculation: Compares page pairs using a word intersection and union method. The similarity score is the ratio of common words to total unique words, weighted by field importance.
- Proximity Threshold: Only pages with similarity scores above the configured threshold are considered related and displayed.
- Caching Scores: Calculated scores are stored in
tx_semanticsuggestion_scores
table for performance optimization. These are updated periodically or when page content changes.
Customize the display of suggestions by overriding the Fluid template (List.html). Configure your own template paths in TypoScript:
plugin.tx_semanticsuggestion {
view {
templateRootPaths.10 = EXT:your_extension/Resources/Private/Templates/
}
}
The extension fully supports TYPO3's multilingual structure, analyzing and suggesting pages in the current site language.
The Semantic Suggestion extension utilizes TYPO3's logging system for comprehensive debugging and maintenance:
- ๐ Configure logging to get detailed information about the analysis and suggestion process
- ๐ Monitor extension behavior and performance
- ๐ Optimize based on logged data
Configuring Logging
Add the following to your typo3conf/AdditionalConfiguration.php
:
$GLOBALS['TYPO3_CONF_VARS']['LOG']['TalanHdf']['SemanticSuggestion']['writerConfiguration'] = [
\TYPO3\CMS\Core\Log\LogLevel::DEBUG => [
\TYPO3\CMS\Core\Log\Writer\FileWriter::class => [
'logFile' => 'typo3temp/logs/semantic_suggestion.log'
],
],
];
This configuration will log all debug-level and above messages to semantic_suggestion.log
.
The Semantic Suggestion extension implements several security measures:
- ๐ก๏ธ Protection against SQL injections through TYPO3's secure query mechanisms (QueryBuilder)
- ๐ XSS attack prevention via automatic output escaping in Fluid templates
- ๐ซ Access control restricted to users with appropriate permissions
Optimized for efficient operation, even with large numbers of pages:
- ๐พ Caching of similarity scores in the database
- ๐ Periodic score updates and refresh on content changes
- ๐ Optimized content retrieval process
- ๐ฏ Efficient handling of excluded pages
- โ๏ธ Batch processing of page analysis for server load management
semantic_suggestion/
โโโ Classes/
โ โโโ Controller/
โ โ โโโ SemanticBackendController.php
โ โ โโโ SuggestionsController.php
โ โโโ Service/
โ โโโ PageAnalysisService.php
โโโ Configuration/
โ โโโ Backend/
โ โ โโโ Modules.php
โ โ โโโ Routes.php
โ โโโ TCA/
โ โ โโโ Overrides/
โ โ โโโ sys_template.php
โ โ โโโ tt_content.php
โ โโโ TypoScript/
โ โ โโโ constants.typoscript
โ โ โโโ setup.typoscript
โ โโโ Services.yaml
โโโ Documentation/
โ โโโ Index.rst
โ โโโ Installation/
โ โ โโโ Index.rst
โ โโโ Introduction/
โ โ โโโ Index.rst
โ โโโ Medias/
โ โโโ backend_module.png
โ โโโ backend_module_performance_metrics.jpg
โ โโโ frontend_on_the_same_theme_view.jpg
โโโ Resources/
โ โโโ Private/
โ โ โโโ Language/
โ โ โ โโโ locallang.xlf
โ โ โ โโโ locallang_be.xlf
โ โ โ โโโ locallang_mod.xlf
โ โ โ โโโ locallang_semanticproximity.xlf
โ โ โโโ Layouts/
โ โ โ โโโ Default.html
โ โ โโโ Templates/
โ โ โโโ SemanticBackend/
โ โ โ โโโ Index.html
โ โ โ โโโ List.html
โ โ โโโ Suggestions/
โ โ โโโ List.html
โ โโโ Public/
โ โโโ Css/
โ โ โโโ SemanticSuggestion.css
โ โโโ Icons/
โ โโโ Extension.svg
โ โโโ module-semantic-suggestion.svg
โ โโโ user_mod_semanticproximity.svg
โโโ Tests/
โ โโโ Fixtures/
โ โ โโโ pages.xml
โ โโโ Integration/
โ โ โโโ Service/
โ โ โโโ PageAnalysisServiceIntegrationTest.php
โ โโโ Unit/
โ โโโ Service/
โ โโโ PageAnalysisServiceTest.php
โโโ .env
โโโ .gitignore
โโโ CHANGELOG.md
โโโ IMPROVEMENTS.MD
โโโ LICENSE
โโโ README.md
โโโ ROADMAP_TO_STABLE.md
โโโ composer.json
โโโ ext_conf_template.txt
โโโ ext_emconf.php
โโโ ext_localconf.php
โโโ ext_tables.php
โโโ phpunit.xml.dist
The Semantic Suggestion extension includes a comprehensive suite of unit tests to ensure reliability and correctness of core functionalities, with a focus on the similarity calculation algorithm.
- Weighted Word Calculation: Verifies the correct weighting of words based on field importance and word frequency.
- Similarity Calculation: Ensures accuracy of page similarity calculations using cosine similarity.
- Field-Specific Similarity: Tests the calculation of similarity scores for individual fields (title, content, keywords, etc.).
- Recency Boost Integration: Validates the integration of recency factors in the final similarity score.
- Page Data Preparation: Checks correct data preparation and preprocessing for similarity analysis.
- Common Keywords Detection: Tests functionality for finding shared keywords between pages.
- Relevance Determination: Validates logic for determining relevance based on calculated similarity scores.
- Edge Case Handling: Tests behavior with empty pages, single-word content, and extremely large content.
- Multilingual Content Handling: Verifies correct similarity calculation for content in different languages.
- Performance Testing: Evaluates the efficiency of similarity calculations with large datasets.
- Cache Handling: Ensures proper use of caching mechanisms for improved performance.
To run the unit tests:
- Ensure you have a development environment set up with DDEV.
- Open a terminal and navigate to your project root.
- Execute the following command:
ddev exec vendor/bin/phpunit -c packages/semantic_suggestion/phpunit.xml.dist --testdox --colors=always
For specific tests, add the --filter
option:
ddev exec vendor/bin/phpunit -c packages/semantic_suggestion/phpunit.xml.dist --filter testMethodName
Pour exรฉcuter tous les tests dans la classe PageAnalysisServiceTest :
ddev exec vendor/bin/phpunit -c packages/semantic_suggestion/phpunit.xml.dist --testdox --colors=always --filter PageAnalysisServiceTest
Pour tester une mรฉthode spรฉcifique, par exemple testGetWeightedWordsReturnsCorrectWeights
:
ddev exec vendor/bin/phpunit -c packages/semantic_suggestion/phpunit.xml.dist --testdox --colors=always --filter "PageAnalysisServiceTest::testGetWeightedWordsReturnsCorrectWeights"
Pour exรฉcuter tous les tests contenant "Similarity" dans leur nom :
ddev exec vendor/bin/phpunit -c packages/semantic_suggestion/phpunit.xml.dist --testdox --colors=always --filter "/::test.*Similarity/"
Pour exรฉcuter les tests avec un rapport de couverture de code :
ddev exec vendor/bin/phpunit -c packages/semantic_suggestion/phpunit.xml.dist --testdox --colors=always --filter PageAnalysisServiceTest --coverage-text
Pour obtenir plus de dรฉtails sur l'exรฉcution des tests :
ddev exec vendor/bin/phpunit -c packages/semantic_suggestion/phpunit.xml.dist --testdox --colors=always --filter PageAnalysisServiceTest -v
- โ Green checkmarks: Passed tests
- โ Red crosses: Failed tests
โ ๏ธ Yellow exclamation marks: Risky or incomplete tests
Detailed output helps quickly identify and address any issues.
๐ก Tip: Regular test execution is recommended, especially after code changes, to ensure continued functionality and catch regressions early.
We welcome contributions to the Semantic Suggestion extension! Here's how you can contribute:
- ๐ด Fork the repository
- ๐ฟ Create a new branch for your feature or bug fix
- ๐ ๏ธ Make your changes and commit them with clear messages
- ๐ Push your changes to your fork
- ๐ฌ Submit a pull request to the main repository
Please adhere to existing coding standards and include appropriate tests for your changes.
This project is licensed under the GNU General Public License v2.0 or later. See the LICENSE file for full details.
For support and further information:
๐ค Contact:
Wolfangel Cyril
Email: [email protected]
๐ Bug Reports and Feature Requests: Use the GitHub issue tracker
๐ Documentation and Updates: Visit our GitHub repository
๐ Full Documentation | ๐ Report Bug | ๐ก Request Feature