Check to see if meta tag has already been added to page

Permalink
Is there a way to check from a block's controller view method if a meta tag has already been added to the page ?

I have several blocks that add open graph and Twitter card meta tags to a page. I only want the 1st block on the page to add these tags, I do not want any duplicate tags.

I started going down the path of trying to keep track of what's been added in each block. This got very messy very fast. I have since abandoned this strategy.

It would sure be nice to get a hold of the current pages HTML or DOMDocument so I could simply search, but I am not sure what state it would be in when a particular block's view method gets called or how and when the actual html is rendered.

Can I store a value in the current page instance that each block could check from it's view method, such as $openGraphMetaTagsHaveBeenAdded = true ?

Any suggestions on how to do this ?

warish
 
warish replied on at Permalink Reply
warish
Any takers ?
jasteele12 replied on at Permalink Reply
jasteele12
Sounds exactly what Page Attributes are for. I'm not sure trying to do that with multiple blocks is the way to go, although you certainly could check if they are set, and if not add them.

Take a look at an older (but still viable) blog post by hereNT:
http://www.werstnet.com/blog/integrating-faceb/...

Hope that helps,

John
jasteele12 replied on at Permalink Reply
jasteele12
Oh, these would probably help taking a look at.

Open Graph Tags LIte (free) - Also see the Get Help discussions there:
http://www.concrete5.org/marketplace/addons/open-graph-tags-lite/...

https://www.concrete5.org/community/forums/customizing_c5/provide-co...
warish replied on at Permalink Reply
warish
Don't page attributes need to be set manually ? The open graph data is coming from a 3rd party content provider. I have no control over it. I get it and then set the meta tags via $this->addHeaderItem().

Is there a process where you get it, set the page attributes and then the page reads those attributes to create the meta tags ?

I have not had a chance to read that article yet.