[pmwiki-users] Added meta tags and schema.org microdata injection into pages
Carlos AB
cabsec.pmwiki at gmail.com
Mon Oct 3 20:12:46 CDT 2011
On 10/3/11, kirpi at kirpi.it <kirpi at kirpi.it> wrote:
>> You'll have to write a markup rule and a function; The markup rule
>> calls the function and passes arguments for it ; Inside the function
>> you'll have to use the function called ParseArgs and then format the
>> arguments with the meta html markup you want; Last step is to assign
>> it to $HTMLHeaderFmt['facebookmeta'] - that has to be set as global
>> inside the function- and voilà! :-)
>
> Et voilà! ...you say :-)
> Ehhmm... well...
Well, that is the only word of french I understand, perhaps a couple
of expressions too, but that is not the point.
> Carlos, really thank you for your hints: I failed to understand both
> the technical jargon and to translate it into working code.
> I then tried to directly lift some code from /scripts/stdmarkup.php
> but there also I failed.
> It is all too advanced for me: I'm just at a copy-and-paste level,
> more or less :-)
> All those \/\'ie?($){*/'}... bleah!
> :-) Impossible to undertand.
Oh, It makes me sad that you gave up on trying to give a programatic
answer to your own needs.
For me it all started like this.
But not all is lost, I've made the recipe.
The idea is not deep/complete/"close to the core" as the idea proposed
by V. Krishn, but it works and it is simple, so you perhaps can give
programming one more try. :-)
But you'll have to write the page in the cookbook.
Do we have a deal?!
Anyway, here is the code:
---------8x---------
<?php
Markup('fbgpmeta',
'directives',
'/\\(:fbgpmeta\\s(.*?):\\)/ei',
"FbGpMeta(PSS('$1'))");
function FbGpMeta($a){
global $HTMLHeaderFmt;
$o = ParseArgs($a);
if($o['image']){
$o['image'] = PUE($o['image']);
$im = "\n<meta property=\"og:image\" content=\"".$o['image']."\"/>\n"
."<meta itemprop=\"image\" content=\"".$o['image']."\" />\n";
}
if($o['title']){
$tm = "\n<meta itemprop=\"name\" content=\"".$o['title']."\" />\n"
."<meta property=\"og:title\" content=\"".$o['title']."\"/>\n";
}
if($o['description']){
$dm = "\n<meta itemprop=\"description\"
content=\"".$o['description']."\" />\n"
."<meta property=\"og:description\"
content=\"".$o['description']."\"/>\n";
}
$HTMLHeaderFmt['fbgpmeta'] = $im.$tm.$dm;
}
---------8x---------
I did it really fast, but there is one thing I'm in doubt of ...
Do I have to PUE description and title?(if others can answer, TIA)
Regards,
CarlosAB
More information about the pmwiki-users
mailing list