WebsiteBaker Community Forum

General Community => Global WebsiteBaker 2.8.x discussion => Topic started by: scheltel on August 06, 2011, 12:08:14 AM

Title: Google Analytics in Settings
Post by: scheltel on August 06, 2011, 12:08:14 AM
I want to extend the settings form to enter the Google Analytics String.

I have modified the code, but when I'm trying to save the settings,  the script tags are not submitted to the database. It seems that there anti-cross site scripting measurements are taken. Is this true? And if so, how can I bypass this behavior?


[gelöscht durch Administrator]
Title: Re: Google Analytics in Settings
Post by: badknight on August 06, 2011, 09:46:32 AM
show us the changes from the save.php you made for this.. maybe ther is something wrong
Title: Re: Google Analytics in Settings
Post by: scheltel on August 06, 2011, 11:19:17 AM
I did not make any changes in save.php.

I have added the following 2 lines to /admin/settings/index.php

   $template->set_var(array(
                        [.... standard coding v2.8.2 ...]                        'HEADING_GOOGLE_ANAL YTICS_SETTINGS' => $HEADING['GOOGLE_ANALYTICS_SE TTINGS']                        
                        )
                  );

   // Insert language text and messages
   $template->set_var(array(
                        [.... standard coding v2.8.2 ...]
                        'TEXT_GOOGLE_ANALYTI CS_DESCRIPTION' => $TEXT['GOOGLE_ANALYTICS_DE SCRIPTION']
                        ));

Added to /templates/wb_theme/templates/settings.htt

<tr>
   <td colspan="3" style="padding-top: 10px;">
      <h2>{HEADING_GOOGLE_ANALYTICS_SETTINGS}</h2>
   </td>
</tr>
<tr>
   <td class="setting_name">{TEXT_GOOGLE_ANALYTICS_DESCRIPTION}</td>
   <td class="setting_value" colspan="2">
      <textarea name="google_analytics">{GOOGLE_ANALYTICS}</textarea>
   </td>
</tr>
<tr>
   <td>&nbsp;</td>
   <td>
      <input type="submit" name="submit" value="{TEXT_SAVE}" class="save" />
      <input type="reset" name="reset" value="{TEXT_RESET}" class="reset" />
   </td>
</tr>


Added to /install/save.php

   $settings_rows=   "INSERT INTO `".TABLE_PREFIX."settings` "
   ." (name, value) VALUES "
[.... standard coding v2.8.2 ...]
   ." ('google_analytics', '')";
   $database->query($settings_rows);


Added to /languages/[language].php
$TEXT['GOOGLE_ANALYTICS_DE SCRIPTION'] = 'Google Analytics String';
$HEADING['GOOGLE_ANALYTICS_SE TTINGS'] = 'Google Analytics Settings';


Added to /templates/[TEMPLATE_NAME]/index.php

if (function_exists('get_google_analytic s')) { get_google_analytic s(); }
?>
</body>


See attachment...
Title: Re: Google Analytics in Settings
Post by: DarkViper on August 06, 2011, 11:33:29 AM
go into /admin/settings/save.php and search for the Line:

Code: (/admin/settings/save.php) [Select]
<?php

139   $allow_tags_in_fields 
= array(&#39;website_header&#39;, &#39;website_footer&#39;);

?>

and add your new datafield to this array.

thats all


take care:
Google Analytics is a very hot iron. Especially in Germany and partly in other EU countries also, you can easily come in conflict with the privacy act and other law. Unawareness does not protect against punishment. That's why we do not include such 'features'.
Title: Re: Google Analytics in Settings
Post by: scheltel on August 06, 2011, 12:34:57 PM
DarkViper thanks!

So Google Analytics will not be built-in in future releases?
Title: Re: Google Analytics in Settings
Post by: DarkViper on August 06, 2011, 01:25:33 PM
Definitely not.
Website Baker is used by a big amount of people who do not know many/all of the legal regulations. It would be careless of us to offer them options that they can bring into conflict with the law.

If somebody like to use GA anyway, so it's very easy to implement it in the index.php of each template.