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

1 Attachment

Type: Discussion
Status: New
ong
View Replies:
Mainio replied on at Permalink Reply
Mainio
Hi,

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
ong replied on at Permalink Reply
ong
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
Mainio replied on at Permalink Reply
Mainio
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:
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.
ong replied on at Permalink Reply
ong
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'

//above the </body> tag
      if (preg_match_all('/(.*)(<[ ]*body[^>]*>)(.*)<\/body>(.*)/is', $output, $matches) > 0) {
         echo $matches[1][0] . $matches[2][0] . PHP_EOL;         
         echo $matches[3][0] . PHP_EOL;
         echo self::$_cookiesElement;
         echo "</body>";
         echo $matches[4][0];
      }


Olaf

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.