Manage Metadata
Last updated
Last updated
The Xmf\Metagen class provides methods to extract and summarize content.
While metadata may be best when manually entered, some helpful suggestions through automation could make that process a little smoother.
Using a human meaningful phrase instead of raw id variables in a URL is a common SEO strategy. Most content has a title, and Xmf\Metagen
has an easy way to turn that title into a slug:
The output:
xmf-xoops-module-framework
Given a block of text, Metagen::generateKeywords()
can extract the most commonly used significant words. Here we feed it the lyrics of "," asking for a list of four words.
The output:
mary, lamb, school, play
Grabbing the lead sentences from a block of text for use as a description is easy. Call Xmf\Metagen::generateDescription()
with your text and the number of words you want:
The output:
Mary had a little lamb, Little lamb, little lamb, Mary had a little lamb, Its fleece was white as snow And everywhere that Mary went, Mary went, Mary went, Everywhere that Mary went The lamb was sure to go...
When displaying search results, it is convenient for the user to see a short bit of context that surrounds where the search terms were found in the content. Examining this context helps guide the user to the most relevant results.
Here, we request a summary of about 40 characters, centered around our chosen keyword(s), in this case 'school'. The text breaks on natural boundaries.
The output:
...He followed her to school one day...