drupal
clear cache function



function drupal_flush_all_caches() cleans out:
css cache
js cache
theme cache (also theme registry)
menu cache
node cache


To build a clear cache tool in drupal 6:
----------------------------
* create a new page
* option: input format: choose PHP code
* block body: add this code:
<?php
drupal_flush_all_caches();
?>

<a href="flushAllCaches">Clear All Cache Again</a>
* optionally you can call the page flushAllCaches or something easy instead of node/12345
* optional: create a stripped down theme:
  o in sites/all/themes/yourThemeOfChoice/ copy "page.tpl.php" page and call it "page-node-12345.tpl.php" (12345 being whatever node is for your clear cache page)
  o edit your page-node-12345.tpl.php
     . strip down the page as far as you can or as far as you like
  o now when you access your clear cache page, it should be a clean page
* create a new block, admin --> site building --> blocks --> click add block
* option: input format: Full HTML mode
* block body: create an iFrame
<a href="/youFolder/flushAllCaches" target="testiFrame">Flush All Caches</a>


<iframe src="/yourSite/yourFolder/anyBasicPage.html" scrolling="yes" frameborder="1" name="testiFrame"
width="160" height="150"
></iframe>
* input format: php code
* after filling title and all other items, click "save block"
* move your new block somewhere, for example: the side bar

You should see a new block with your given title, and a link "Flush All Caches". The link should put the clear cache php page into the newly created iFrame box

After the page finishes loading, all caches should be clear.
Test that everything works by making a structual change something like "page.tpl.php" in the themes. A small change to this php file normally won't show up until you've cleared the cache.
When you've tested that everything works, you can make a more friendly page that perhaps tells you that it's done.



Misc Notes:
------------

If you don't have the PHP input filter:
  * admin --> site building --> modules --> core optional --> check off PHP filter


Explanation of "page.tpl.php"
   This is a template or theme page that is applied to all pages.
   In "page-node-12345.tpl.php", node and 12345 is applies to page in yoursite.com/yourDrupalInstall/node/12345.


No way to set alias to page node/12345. You can rename pages by:
  * go to admin --> site building --> modules --> core optional --> check "Path"
  * now you can edit your pages. When you scroll down, you'll see "URL path settings"




copy or move drupal website to another server or another instance on same machine
--------------------

Original server:
  put drupal site on offline
  turn off clean urls
  clear cache (admin - settings - performancs)
  sqldump or phpMyAdmin
  copy all drupal files or just sites/* if upgrading (file copy or tar/gzip)

On destination server or another folder on same server:
  copy files or unarchive them if previously archived (above)
  create database in mysql
  restore database from previous mysqldump
  edit settings.php if database name is different
  go to yousite.com/yourDrupalInstall/?q=user
  check status and run cron
  bring online
  ** may also need to check permissions and ownership. i.e., /drupalInstall/sites/default/files/ and make files inside owner: apache:apache and recursive



-------------------------
If drupal installed in sub directory/sub folder
to get to base of drupal install instead of root of website

use:
 global $base_url

In PHP code:
 global $base_url;
 print $base_url;

Example:
creating links:
Cache



------------------
drupal 7 custom homepage or other single page
page--front.tpl.php
page--node--11.tpl.php



drupal 6 custom templates for single page
page-node-21.tpl.php


drupal 7 custom template for content type: node level:
node--myphones.tpl.php

----------------------------
add javascript to head tag




------------------------------------
drupal and php: server side includes

exec("/misc/some/path/myScript.pl");

include("/misc/some/path/myScript.pl");

system call:
system("/usr/bin/perl /var/www/html/my/absolute/path/misc/some/path/myScript.pl");
But does not handle as if it were a SSI. it runs the commands on the system level then returns the results.


system call will return any STDOUT to your browser and to a variable.
If my_bin.sh prints "hello".
$var = system("my_bin.sh");
echo $var;
This will print "hello" and "hello".

Instead, use shell_exec('my_bin.sh');