phpBB SEO Template Variables

phpBB SEO Premod for phpBB3 support forum.
This premodded version of phpBB3 includes the three different type of URL rewriting for phpBB3 by phpBB SEO. It comes with several other Search Engine Optimization mods installed.

Moderator: Moderators

phpBB SEO Template Variables

Postby btrfishing » Mon Aug 18, 2014 4:43 pm

I was wondering if you have a list of phpBB SEO specific variables.

For example, a list that explain any added variables beyond phpBB's ( ex: https://wiki.phpbb.com/Global_Template_Variables )

_ _ _ _ _ _ _ _ _ _ _

Specifically what I'm trying to do is add just the meta keywords or just the meta description a second time under a different tag.

I want to repeat the description a second time under
Code: Select all
<meta property="og:description"


I didn't want to try to edit the PHP side of things to do this... but if that's the only way I would love some help.

Thanks in advance.
User avatar
btrfishing
 
Posts: 13
Joined: Wed Feb 13, 2013 11:08 pm

Advertisement

Re: phpBB SEO Template Variables

Postby dcz » Tue Aug 26, 2014 7:09 am

Problem is all meta are dumped in a single template variable. This makes is simpler to conditionally add each one of them.

You can though dump any meta variable you want easily in the meta mod file (phpbb_seo/phpbb_seo_meta.php in build_meta method.
Just bellow
Code: Select all
$template->assign_var('META_TAG', $meta_code);
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21394
Joined: Fri Apr 28, 2006 9:03 pm

Re: phpBB SEO Template Variables

Postby btrfishing » Wed Aug 27, 2014 11:05 pm

Is there a way i can make this line of code from phpbb_seo_meta.php spit out two lines of code?

Code: Select all
'description' => '<meta name="description" content="%s" />',


I want to make that variable 'description' spit out something like...

Code: Select all
'description' => '<meta name="description" content="%s" />' + '<meta name="og:description" content="%s" />',


The problem is I don't know PHP so I don't know how to make that variable spit out two lines there.

I've tried and just break everything lol.
User avatar
btrfishing
 
Posts: 13
Joined: Wed Feb 13, 2013 11:08 pm

Re: phpBB SEO Template Variables

Postby dcz » Mon Sep 01, 2014 5:35 am

just use :
Code: Select all
    'description' => '<meta name="description" content="%1$s" /><meta name="og:description" content="%1$s" />',


the %s bit will be replaced by the actual description at runtime (using sprintf()) and can be repeated as many times as you wish/need within this string.
In php, use a dot (.) to concatenate strings, I did not use one here since you can just add more string to the string.

You could use a new line between the two, but it's really only is cosmetic, not actually useful in any other way :
Code: Select all
    'description' => '<meta name="description" content="%1$s" />
<meta name="og:description" content="%1$s" />',

or in one line :
Code: Select all
     'description' => "<meta name=\"description\" content=\"%1\$s\" />\n<meta name=\"og:description\" content=\"%1\$s\" />",
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21394
Joined: Fri Apr 28, 2006 9:03 pm

Re: phpBB SEO Template Variables

Postby btrfishing » Thu Sep 04, 2014 2:12 pm

I get an error when trying this...

Code: Select all
Parse error: syntax error, unexpected '.', expecting ')' in /home/content/03/10286703/html/forum/phpbb_seo/phpbb_seo_meta.php on line 31
User avatar
btrfishing
 
Posts: 13
Joined: Wed Feb 13, 2013 11:08 pm

Re: phpBB SEO Template Variables

Postby dcz » Sat Sep 06, 2014 6:48 am

Are you trying the last one ? Cuz yes, you cannot use it since its in variable declaration wich only accept static content (constant or string) and no parsing.

the proper one liner in two lines :
Code: Select all
    'description' => "<meta name=\"description\" content=\"%s\" />\n<meta name=\"og:description\" content=\"%s\" />",


I also edited my previous post
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21394
Joined: Fri Apr 28, 2006 9:03 pm

Re: phpBB SEO Template Variables

Postby btrfishing » Mon Sep 08, 2014 6:14 pm

Thanks for working through this with me first of all... i know I'm being a pain here!

I got another error though:

Code: Select all
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb_seo/phpbb_seo_meta.php on line 175: sprintf() [function.sprintf]: Too few arguments
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4824: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3893)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4826: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3893)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4827: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3893)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4828: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3893)


I noticed that there were double quotes before the meta tag:

Code: Select all
'description' => "<meta name


Instead of single quotes like before:

Code: Select all
'description' => '<meta name


Although changing this didn't seem to help.
User avatar
btrfishing
 
Posts: 13
Joined: Wed Feb 13, 2013 11:08 pm

Re: phpBB SEO Template Variables

Postby dcz » Tue Sep 09, 2014 5:01 am

oh lol !

Code: Select all
'description' => "<meta name=\"description\" content=\"%1\$s\" />\n<meta name=\"og:description\" content=\"%1\$s\" />",


We needed to use variable slot for sprintf since we reuse instead of adding a different one ...

I tested this time :roll:
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21394
Joined: Fri Apr 28, 2006 9:03 pm

Re: phpBB SEO Template Variables

Postby btrfishing » Tue Sep 09, 2014 4:51 pm

YOU ARE THE MAN !!

Thanks again for taking the time and spelling this out for me! I really appreciate it.

:D :D :D :D :D

I think this is a great topic for anyone else trying to repeat their description or keywords under a different tag.

Well done, and thanks once again!
User avatar
btrfishing
 
Posts: 13
Joined: Wed Feb 13, 2013 11:08 pm

Re: phpBB SEO Template Variables

Postby dcz » Wed Sep 10, 2014 5:47 am

You could add an issue here https://github.com/phpBBSEO/meta to ask for an (optional?) addition of this additional meta tag.
Would be for 3.1, but backport are also possible.
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21394
Joined: Fri Apr 28, 2006 9:03 pm


Return to phpBB SEO Premod

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 8 guests