How to manually put Title and Description on phpbb?

User avatar
Delo Ramci
Posts: 16
Joined: Thu Jan 26, 2017 12:17 pm

How to manually put Title and Description on phpbb?

Tue Apr 11, 2017 7:53 pm

Dynamic Meta Descriptions.

Open /viewtopic.php and find:
// Parse the message and subject
$message = censor_text($row['post_text']);
After, add:

Code: Select all

 /*** 2017-03-03 BEGIN AmigoJack
        Dynamic meta description and meta keywords for topics, based on the first post ***/
    if( !$sMetaDescription ) {
        $sMetaDescription= preg_replace
                ( array
                        ( '#\\[([^/\\]=]+)[^\\]]*\\]#'  // Strip possible BBCode opening tags
                        , '#\\[/[^\\]]*\\]#'  // Closing tags
                        , '#<[^>]+>#'  // Strip possible HTML
                        , '#[\\n\\r\\t]#s'  // Strip linebreaks and tabs
                        , '# +#'  // Strip multiple spaces
                        , '#[a-z]+(:|\\&\\#58;)\\S+#i'  // Strip URIs
                        )
                , array
                        ( ''
                        , ''
                        , ''
                        , ' '
                        , ' '
                        , ' '
                        )
                , $message
                );

        // Keywords must be latin letters, ciphers and underscores only. Need to be more than 3 characters.
        $sKeyWord= ucwords( strtolower( preg_replace( '#[^a-zA-Z0-9_ ]+#', ' ', $sMetaDescription ) ) );
        $aKeyWord= explode( ' ', $sKeyWord );
        $aDistinct= array();
        foreach( $aKeyWord as $v1 ) if( !isset( $aDistinct[$v1] )&& utf8_strlen( $v1 )> 3 ) $aDistinct[$v1]= 0;
        $sKeyWord= implode( ', ', array_keys( $aDistinct ) );

        // Shorten description if it's longer than 150 characters
        if( ( utf8_strlen( $sMetaDescription )> 150 )&& ( $iSpace= utf8_strpos( $sMetaDescription, ' ', 150 ) )!== FALSE ) $sMetaDescription= substr( $sMetaDescription, 0, $iSpace );
    }
    /*** 2017-03-03 END ***/ 
    
Find:

Code: Select all

// Output the page
page_header($user->lang['VIEW_TOPIC'] . ' - ' . $topic_data['topic_title'], true, $forum_id); 
Before, add:

Code: Select all

    /*** 2011-03-03 BEGIN AmigoJack
        Assign possible meta data ***/
    $template-> assign_vars
    ( array
        ( 'S_META_DESCRIPTION'=> $sMetaDescription
        , 'S_META_KEYWORDS'=> $sKeyWord
        ) 
    );
    /*** 2017-03-03 END ***/ 
For every style you use open /styles/?/template/overall_header.html and find:
<meta name="keywords" content="" />
<meta name="description" content="" />
Replace with:

Code: Select all

<meta name="keywords" content="{S_META_KEYWORDS}" />
<meta name="description" content="{S_META_DESCRIPTION}" />
For every style you use delete /cache/tpl_?_overall_header.html.php.


Return to “phpBB 3.1.x to 3.2.0”

Links

In total there are 9 users online :: 0 registered, 0 hidden and 9 guests
Registered users: No registered users
Most users ever online was 156 on Sun Jun 17, 2018 7:42 am
Total posts 460
Total topics 339
Total members 69
Our newest member svetikvow
No birthdays today