Google search shows Cookie text because it's 1st on page (!?)
Permalink Browser Info Environment
Hi
when I use the script on a site and this site is being googled the description of the site is not shown! Instead the cookie text is.
I assume it's because the HTML is being inserted at the top of the code - directly after the <body> tag. Since formating is done using CSS anywys, I would like to place the code right before the </body> (=at the end) of the code.
a) is my assumption correct that the reason for this behaviour is the placement in the code?
b) how can I change the code position?
Olaf
when I use the script on a site and this site is being googled the description of the site is not shown! Instead the cookie text is.
I assume it's because the HTML is being inserted at the top of the code - directly after the <body> tag. Since formating is done using CSS anywys, I would like to place the code right before the </body> (=at the end) of the code.
a) is my assumption correct that the reason for this behaviour is the placement in the code?
b) how can I change the code position?
Olaf
Type: | Discussion |
---|---|
Status: | New |
Hi
thanks for the quick answer.
I found the regex (line 74) but I am not sure what to move where.
Could you please give me anothe rhint?
Thanks
PS: I PM'd you the sitename.
Olaf
thanks for the quick answer.
I found the regex (line 74) but I am not sure what to move where.
Could you please give me anothe rhint?
Thanks
PS: I PM'd you the sitename.
Olaf
Ok, yeah, I'm not quite sure because the site you PMd me seemed to have the meta description set on the front page...
The line you'll need to edit is this one:
And in particular, the regular expression pattern there:
www.www.regular-expressions.info...
You might also need to edit the parts inside that if-clause if the structure of the regular expression changes.
The line you'll need to edit is this one:
if (preg_match_all('/(.*)(<[ ]*body[^>]*>)(.*)/is', $output, $matches) > 0) {
And in particular, the regular expression pattern there:
'/(.*)(<[ ]*body[^>]*>)(.*)/is'
www.www.regular-expressions.info...
You might also need to edit the parts inside that if-clause if the structure of the regular expression changes.
Hi
thanks for the reply. I am using this regex (with this modified code now) - which makes the cookie code appear directly before the </body> (closing body)-tag:
'/(.*)(<[ ]*body[^>]*>)(.*)<\/body>(.*)/is'
Olaf
thanks for the reply. I am using this regex (with this modified code now) - which makes the cookie code appear directly before the </body> (closing body)-tag:
'/(.*)(<[ ]*body[^>]*>)(.*)<\/body>(.*)/is'
Olaf
It's hard to say without seeing the page source but, I would guess that the reason is what you assume. The easiest way to solve that would be to define a meta description for your pages and Google would use that instead.
You're also free to move the text to the bottom of the page source, that can be done by overriding this file in the package:
/libraries/disclosure_renderer.php
Towards the bottom of the file, you'll find a regular expression in the "on_render_complete" function that finds the starting body tag. You can move the text on bottom of the page just by modifying that regular expression.
Best,
Antti / Mainio