tractorcow/silverstripe-opengraph

disable / enable per pagetype

Closed this issue · 4 comments

one question again:
is it possible to disable the opengraph tags for a specific pagetype?
make an "empty" extension, maybe?
And set it somewhere in the pagetype:
OpenGraph::$page_extension_class = 'BlockOGExtension';

thanx

Hi Ivo,

That's a good question. If you look at the code in OpenGraphPageExtension you can see that the MetaTags function is where the module "injects" the opengraph tags.

This function first calls the getTagBuilder function, which calls getOGType() on the object. Note that this gives you the chance to implement getOGType() in your code in order to override the extension implementation. If you do so, the getOGType() in the OpenGraphPageExtension class will not be called at all.

You can see from the code that if getOGType() returns null, nothing will happen. If you want your code for a particular page type to disable opengraph, you could simply use this code:

NonOGPage extends Page
{
    function getOGType() {
        return null;
    }
}

Sorry for the long winded explanation, but I just wanted to make sure you understand how the module works internally. There's nothing really fancy, but with a good explanation my hope is that it will be easy for you to use.

Hey Damian,
that solution works like a charm.
Thanks a lot for your efforts. Much appreciated!

i made a blogpost on your module, you might want to check :)
http://nerdpress.org/2012/06/14/opengraph-metatags-in-silverstripe/

Heh, that's a much prettier blog that mine. I really need to sharpen up my design skills.

Thanks for the props! Let me know any time you want to discuss code.