How To: Add Google search box.
This requires you to:
Step 1.
Edit: â/nextcloud/lib/public/AppFramework/Http/ContentSecurityPolicy.phpâ
You are going to allow array Domains which can be used as target for forms. This means you have to explicitly allow âGoogleâ. To do this you need to add âhttp://*.google.comâ below ââselfââ, ⊠as I have below.
/** @var array Domains which can be used as target for forms */
protected $allowedFormActionDomains = [
'\'self\'',
'http://*.google.com'
];
Step 2.
Create a file called: /nextcloud/core/templates/myGoogle.php
⊠and put this code in it âŠ
<span> </span>
<form action="http://www.google.com/search" method="get" target="_blank">
<input type="text" name="q" size="32" maxlength="256" value="">
<input type="submit" name="btnG" value="Google It">
</form>
Step 3.
Modify /nextcloud/core/templates/layout.user.php
⊠to include the file in step 2 ⊠but only for desktops (not mobile devices).
Put the code below at line 71 ⊠(below the â<?php endforeach; ?>â tag âŠ
<!-- Show the google box code-->
<li data-id="<?php p($entry['id']); ?>" class="hidden" tabindex="-1" style="padding: 6px 10px ! important;">
<!-- Show the google box code-->
<?php
function isMobile() {
return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
}
if(isMobile()){
// Do something for only mobile users
}
else {
include ("myGoogle.php"); // Do something for only desktop users
}
?>
</li>
<!-- Show the google box code-->