Skip to content

\Xmf\Metagen::generateDescription() and xlanguage #86

@GregMage

Description

@GregMage

This method does not work with xlanguage. With the first language, no problem but if we activate the second then Xoops crashes.

To avoid the problem I wrote this in my module:

$xoTheme->addMeta('meta', 'description', \Xmf\Metagen::generateDescription(preg_replace("/\[.*?\]/", '', $content->getVar('content_text')), 30));

I don't know if it's really good what I'm doing. We can add this code to the method "asPlainText()"

$text = preg_replace('/\[.*?\]/', ' ', $text);

The full code:

    protected static function asPlainText($rawText)
    {
        $text = $rawText;
        $text = static::html2text($text);
        $text = static::purifyText($text);

        $text = str_replace(array("\n", "\r"), ' ', $text);
        $text = preg_replace('/[ ]* [ ]*/', ' ', $text);
        $text = preg_replace('/\[.*?\]/', ' ', $text);

        return trim($text);
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions