Saturday 29 October 2011

PHP: Exporting Data to Excel


After putting so much effort into importing your data into an SQL database and connecting it to your website, how do you get it back out and into Excel in order to keep your off-line and on-line systems synchronised?

The following article presents a simple method for downloading any data from PHP into an Excel spreadsheet - or at least something that looks like one.

1. Preparing the data

The following examples use the dataset created for Sorting Arrays of Arrays which is defined as follows:
<?PHP $data = array( array("firstname" => "Mary", "lastname" => "Johnson", "age" => 25), array("firstname" => "Amanda", "lastname" => "Miller", "age" => 18), array("firstname" => "James", "lastname" => "Brown", "age" => 31), array("firstname" => "Patricia", "lastname" => "Williams", "age" => 7), array("firstname" => "Michael", "lastname" => "Davis", "age" => 43), array("firstname" => "Sarah", "lastname" => "Miller", "age" => 24), array("firstname" => "Patrick", "lastname" => "Miller", "age" => 27) ); ?>
Note: Further down this page you can find an example on creating an export from an SQL query.
The first step is to output the data in a tab-delimited format (CSV can also be used but is slightly more complicated). To achieve this we use the following code:
<?PHP header ("Content-Type: text/plain"); $flag = false; foreach($data as $row) { if(!$flag) { # display field/column names as first row echo implode ("\t", array_keys ($row)) . "\r\n"; $flag = true; } echo implode("\t", array_values ($row)) . "\r\n"; } ?>
We set the content type to text/plain so that the output can more easily be viewed in the browser. Otherwise, because there is no HTML formatting, the output would appear as a single line of text.
The first line of output will be the column headings (in this case the field names are used). Values are separated with a tab \t and rows with a line break \n. The output should look something like the following:
firstname lastname age Mary Johnson 25 Amanda Miller 18 James Brown 31 Patricia Williams 7 Michael Davis 43 Sarah Miller 24 Patrick Miller 27
There's already a weakness in this code that may not be immediately obvious. What if one of the fields to be ouput already contains one or more tab characters, or worse, a newline? That's going to throw the whole process out as we rely on those characters to indicate column- and line-breaks.
The solution is to 'escape' the tab characters. In this case we're going to replace tabs with a literal \t and line breaks with a literal \n so they don't affect the formatting:
<?PHP function cleanData(&$str) { $str = preg_replace ("/\t/", "\\t", $str); $str = preg_replace("/\r?\n/", "\\n", $str); } header("Content-Type: text/plain"); $flag = false; foreach($data as $row) { if(!$flag) { # display field/column names as first row echo implode("\t", array_keys($row)) . "\r\n"; $flag = true; } array_walk ($row, 'cleanData'); echo implode("\t", array_values($row)) . "\r\n"; } ?>
Now, before each row is echoed any tab characters are replaced "\t" so that our columns aren't broken up. Also any line breaks within the data are replaced with "\n". Now, how to set this up as a download...

2. Triggering a download

What many programmers don't realise is that you don't have to create a file, even a temporary one, in order for one to be downloaded. It's sufficient to 'mimic' a download by passing the equivalent HTTP headers followed by the data.
If we create a PHP file with the following code then when it's called a file will be downloaded which can be opened directly using Excel.
<?PHP function cleanData(&$str) { $str = preg_replace("/\t/", "\\t", $str); $str = preg_replace("/\r?\n/", "\\n", $str); if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"'; } # filename for download $filename = "website_data_" . date('Ymd') . ".xls"; header("Content-Disposition: attachment; filename=\"$filename\""); header("Content-Type: application/vnd.ms-excel"); $flag = false; foreach($data as $row) { if(!$flag) { # display field/column names as first row echo implode("\t", array_keys($row)) . "\r\n"; $flag = true; } array_walk($row, 'cleanData'); echo implode("\t", array_values($row)) . "\r\n"; } exit; ?>
Note that we've added an extra line to the cleanData function to detect double-quotes and escape any value that contains them. Without this an uneven number of quotes in a string can confuse Excel.
This should result in a file being downloaded and saved to your computer. If all goes well then the filename will be named "website_data_20111029.xls" and will open in Excel looking something like this:
screenshot showing data in Excel colums
How does it work? Setting the headers tells the browser to expect a file with a given name and type. The data is then echoed, but instead of appearing on the page it becomes the downloaded file.
Because of the .xls extension and the ms-excel file type, most computers will associate it with Excel and double-clicking will cause that program to open. You could also modify the file name and mime type to indicate a different spreadsheet package or database application.
Before you ask, there is no way to specify data or cell formatting, column widths, etc, using this method. We are only passing a tab-delimited text file. To include formatting try generating HTML code or a script that actually builds an Excel file. Or a macro.
A similar technique can be used to allow users to download files that have been uploaded previously using PHP and stored with different names. More on that later...

3. Exporting from an SQL database

If your goal is to allow data to be exported from a query result then the changes are relatively simple:
<?PHP // Original PHP code by Chirp Internet: www.chirp.com.au // Please acknowledge use of this code by including this header. function cleanData(&$str) { $str = preg_replace("/\t/", "\\t", $str); $str = preg_replace("/\r?\n/", "\\n", $str); if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"'; } // file name for download $filename = "website_data_" . date('Ymd') . ".xls"; header("Content-Disposition: attachment; filename=\"$filename\""); header("Content-Type: application/vnd.ms-excel"); $flag = false; $result = pg_query ("SELECT * FROM table ORDER BY field") or die('Query failed!'); while(false !== ($row = pg_fetch_assoc ($result))) { if(!$flag) { // display field/column names as first row echo implode("\t", array_keys($row)) . "\r\n"; $flag = true; } array_walk($row, 'cleanData'); echo implode("\t", array_values($row)) . "\r\n"; } ?>
This would be the entire file required to query the database and trigger the file download. The database functions need to match the database you're using. MySQL users for example would use mysql_query  andmysql_fetch_assoc  in place of the PostgreSQL functions.
For other databases see under User Comments below or check the PHP documentation. If you are seeing duplicate columns (numbered as well as labeled) you need to change the fetch call to return only the associative (ASSOC) array.
If you're having trouble at this stage, remove the Content-Disposition header and change the Content-Type back to text/plain. This makes debugging a lot easier as you can see the output in your browser rather than having to download and open the generated file every time you edit the script.

4. Preventing Excel's ridiculous auto-format

When importing from a text file as we're essentially doing here, Excel has a nasty habit of mangling dates, timestamps, phone numbers and similar input values.
For our purposes, some simple additions to the cleanData function take care of most of the problems:
<?PHP // Original PHP code by Chirp Internet: www.chirp.com.au // Please acknowledge use of this code by including this header. function cleanData(&$str) { // escape tab characters $str = preg_replace("/\t/", "\\t", $str); // escape new lines $str = preg_replace("/\r?\n/", "\\n", $str); // convert 't' and 'f' to boolean values if($str == 't') $str = 'TRUE'; if($str == 'f') $str = 'FALSE'; // force certain number/date formats to be imported as strings if(preg_match("/^0/", $str) || preg_match("/^\+?\d{8,}$/", $str) || preg_match("/^\d{4}.\d{1,2}.\d{1,2}/", $str)) { $str = "'$str"; } // escape fields that include double quotes if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"'; } ?>
The section that prevents values being scrambled does so by inserting an apostrophe at the start of the cell. When you open the resuling file in Excel you may see the apostrophe, but editing the field will make it disappear while retaining the string format. Excel is strange that way.
The types of values being escape this way are: values starting with a zero; values starting with an optional+ and at least 8 consecutive digits (phone numbers); and values starting with numbers in YYYY-MM-DD format (timestamps). The relevant regular expressions have been highlighted in the code above.

5. Formatting - colours, numbers, dates

Again, this script generates and triggers the download of a tab-delimited text file with an .xls extension and Excel Mime-Type. We are not building an actual Excel document.
Defining styles, colours, column widths, etc, is not possible using this technique. You may be able to generate an HTML table with some formatted data that Excel will recognise, otherwise you need a much more complicated script.

6. Exporting to CSV format

The tab-delimited text options describe above may be a bit limiting if your data contains newlines or tab breaks that you want to preserve when opened in Excel or another spreadsheet application.
A better format then is comma-separated variables (CSV) which can be generated as follows:
<?PHP function cleanData(&$str) { if($str == 't') $str = 'TRUE'; if($str == 'f') $str = 'FALSE'; if(preg_match("/^0/", $str) || preg_match("/^\+?\d{8,}$/", $str) || preg_match("/^\d{4}.\d{1,2}.\d{1,2}/", $str)) { $str = "'$str"; } if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"'; } header("Content-Disposition: attachment; filename=\"$filename\""); header("Content-Type: application/vnd.ms-excel;"); $out = fopen ("php://output", 'w'); $flag = false; $result = pg_query("SELECT * FROM table ORDER BY field") or die('Query failed!'); while(false !== ($row = pg_fetch_assoc($result))) { if(!$flag) { // display field/column names as first row fputcsv ($out, array_keys($row), ',', '"'); $flag = true; } array_walk($row, 'cleanData'); fputcsv($out, array_values($row), ',', '"'); } fclose($out); ?>
Normally the fputcsv command is used to write data in CSV format to a separate file. In this script we're tricking it into writing directly to the page by telling it to write to php://output instead of a regular file.

7. Exporting to CSV with Unicode intact

If like us your data contains UTF-8 characters you will notice that Excel doesn't handle them very well. Other applications can open UTF-8 content without problems, but for some reason Microsoft wants to keep you in the dark ages.
Fortunately, there is a trick you can use. Below you can see how we modify the script to convert everything from UTF-8 to UTF-16 Lower Endian (UTF-16LE) format which Excel, at least on Windows, will recognise.
Please Note: When you open the file in Excel you might find all the data bunched into the first column. This should be fixable using the "Text to Columns..." command in the Data menu.
<?PHP function cleanData(&$str) { if($str == 't') $str = 'TRUE'; if($str == 'f') $str = 'FALSE'; if(preg_match("/^0/", $str) || preg_match("/^\+?\d{8,}$/", $str) || preg_match("/^\d{4}.\d{1,2}.\d{1,2}/", $str)) { $str = "'$str"; } if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"'; $str = mb_convert_encoding($str, 'UTF-16LE', 'UTF-8'); } header("Content-Disposition: attachment; filename=\"$filename\""); header("Content-Type: application/vnd.ms-excel; charset=UTF-16LE"); $out = fopen("php://output", 'w'); $flag = false; $result = pg_query("SELECT * FROM table ORDER BY field") or die('Query failed!'); while(false !== ($row = pg_fetch_assoc($result))) { if(!$flag) { // display field/column names as first row fputcsv($out, array_keys($row), ',', '"'); $flag = true; } array_walk($row, 'cleanData'); fputcsv($out, array_values($row), ',', '"'); } fclose($out); ?>
This script may not work for all versions of Excel. Please let us know using the Feedback form below if you encounter problems or come up with a better solution.

Thursday 27 October 2011

40 Modification tricks to Mystic the Popular WP theme

40+ Most Wanted Mystique Theme Modifications, Hacks

This tutorial was written for the Mystique WordPress theme up to 2.4.3 and since version 3.0 the themes code has change that much that these tutorials no longer work. For new modifications, hacks read this article, How to modify Mystique 3.0 WordPress Theme.
Mystique is a free WordPress theme that attempts to top commercial templates in terms of design and functionality. In our earlier articles, we showed a way for users to add social icons to Mystique Nav bar. In this article, we will share with you a way by which you can modify various fields in Mystique theme. Customize each and every part of Mystique WordPress theme using this guide.
If you don’t like to edit code, then download Modified Mystique Theme – MystiqueR2.

User CSS Code:

Note: Add following code to, Under Appearance -> Mystique settings -> User CSS.
1. Adjust the postion of Site_Title/Site_Logo:
/*** LOGO/Site_Title and Navbar***/
#site-title{padding:35px 0 10px 0;}
Where 35px is the space above site title and the 10px is the space below site title or site logo.
2. Adjust page width:
For some reason you want to change your default 960 (Grid System) page width to custom width then do following steps: First Under Appearance -> Mystique settings -> Design -> select Fluid (100%)/Custom option then add following code in User CSS.
/* Page Width */
body.fluid .page-content{
 max-width: 1060px;
}
Change value of 1060 accordingly and if you want to change sidebar size then Design -> Use column sizes option.

3. Set a custom featured post width and height:
If you adjust page width other than 960 (Grid System) then you have to adjust featured post width. You can also adjust featured post height.
/* Custom featured page width and height*/
#featured-content .slide-container, #featured-content ul.slides li.slide{ height:174px;
width:1060px;
}
Change value of 174, 1060 accordingly.
4. Hide tagline from homepage:
If you want to hide tagline from homepage but it should be display at browser page and so on.
/* Hide tag line from homepage */
#header .headline{ display: none; !important}
5. Change Site title colour:
/* Change Site title colour */
#site-title #logo a{
color:#FFFFFF;
}
Default colour is White. Change value of FFFFFF if you want another colour.
6. Change Site tag line colour:
/* Change Site tag line colour */
#site-title p.headline{
color:#C2DC15;
}
Default colour is Green. Change value of C2DC15 if you want another colour.
40+ Most Wanted Mystique Theme Modifications, Hacks
7. Change the hover colour of blog title:
/* The hover colour of blog title */
#site-title #logo a:hover{color:#ed1e24;}
Default colour is Red. Change value of edle24 if you want another colour.
8. Join navigation bar with main content:
40+ Most Wanted Mystique Theme Modifications, Hacks
/* Join navigation with main content */
.header-wrapper .shadow-right{padding-bottom:0;}
9. Black navigation style:
40+ Most Wanted Mystique Theme Modifications, Hacks
/* Black navigation */
ul.navigation{background-position:left -464px;background-color:#000;}
ul.navigation li{background-position:right bottom;}
ul.navigation li a{text-shadow:none;color:#b3b3b3;}

ul.navigation li.active a,
ul.navigation li.current_page_item a,ul.navigation li.current_page_parent a,ul.navigation li.current_page_ancestor a,
ul.navigation li.current-cat a,ul.navigation li.current-cat-parent a,ul.navigation li.current-cat-ancestor a{background-position:left -164px;color:#fff;}

ul.navigation li a:hover,ul.navigation li:hover a,ul.navigation li a.fadeThis span.hover{background-color:rgba(255,255,255,0.1);}
ul.navigation li:hover li a{background-color:transparent;}
ul.navigation li li a:hover,ul.navigation li li a.fadeThis span.hover{background-color:#ed1e24 !important;}

ul.navigation li.active a span.pointer,
ul.navigation li.current_page_item a span.pointer,ul.navigation li.current_page_parent a span.pointer,ul.navigation li.current_page_ancestor a

span.pointer,
ul.navigation li.current-cat a span.pointer,ul.navigation li.current-cat-parent a span.pointer,ul.navigation li.current-cat-ancestor a span.pointer
{background-position:center bottom;}

ul.navigation ul{background-color:rgba(0,0,0,0.66);border-color:#000;}

ul.navigation li.active ul,
ul.navigation li.current_page_item ul,ul.navigation li.current_page_parent ul,ul.navigation li.current_page_ancestor ul,
ul.navigation li.current-cat ul,ul.navigation li.current-cat-parent ul,ul.navigation li.current-cat-ancestor ul
{background-color:#656565;border-color:#656565;}

ul.navigation ul ul{border-top:1px solid rgba(255,255,255,0.5);}
Custom colors for the navigation bar:
40+ Most Wanted Mystique Theme Modifications, Hacks
/* Custom colors for the navigation bar */
ul.navigation li a:hover,ul.navigation li:hover a{background-color:#fc0;}
ul.navigation li.active a:hover, ul#navigation li.active:hover a{ background-color:#a6c61c;}

ul.navigation li.active a span.pointer, ul.navigation li.current_page_item a span.pointer, ul.navigation li.current_page_parent a span.pointer, ul.navigation li.current_page_ancestor a span.pointer{ display: none; }

ul.navigation li a.fadeThis span.hover{ background-color: #fc0; }

ul.navigation li.active a, ul.navigation li.current_page_item a, ul.navigation li.current_page_parent a, ul.navigation li.current_page_ancestor a{ background:#a6c61c; color:#fff; text-shadow:rgba(0,0,0,0.5) 1px 1px 1px; }

ul.navigation{ background:#c4db63 url(images/nav.png) repeat-x left top; }
ul.navigation li a{ text-shadow:rgba(0,0,0,0.5) 1px 1px 1px; color: #fff; }<strong></strong>
10. Decrease site title text size:
To decrease size of site title text use following code. Adjust value of 300 accordingly.
/* Decrease site title text size */
#site-title #logo{font-size:300%;}
11. Change size of header:
40+ Most Wanted Mystique Theme Modifications, Hacks
/* Change font size of header */
h1.title{font-weight: bold;font-size: 180%;margin:0 0 .2em 0;padding:.2em 0 0 0;text-shadow: #fff 1px 1px 1px;}
Adjust value of 180 accordingly.
12. Turn widget titles to lower case:
In Mystique theme all widget titles are in uppercase. To change this use following code.
/* turn widget titles to lower case */
.block h3.title{text-transform:none;}
40+ Most Wanted Mystique Theme Modifications, Hacks
13. Border for each post:
40+ Most Wanted Mystique Theme Modifications, Hacks
/*border for each post */
.post{
border:2px solid;
margin:0 0 40px;
padding:15px;
text-align:justify;
}
14. Change the default font size of text inside post’s:
/* Custom font size inside post */
div.post-content{ font-size: 120%; }
15. Change the black background:
In Mystique theme, default background is black you can change it to other. Here we gave blue as an example.
/* Change black background */
body{background-color:blue;}
16. Change background colour with upper and lower colour:
/* Change background colour with upper and lower colour */

body{
background-color: white;
}

#page{
 background: #000; /* for non-css3 browsers or Opera */
 filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#CCCCCC'); /* for IE 6 & 7 */
 -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#CCCCCC')"; /* for IE 8 */
 background: -webkit-gradient(linear, left top, left bottom, from(#000), to(rgba(0,0,0,0))); /* for webkit browsers */
 background: -moz-linear-gradient(top,&nbsp; #000, rgba(0,0,0,0));} /* For gecko FF3+ */
}
17. Permanent page controls:
To make the increase or decrease text size control button (Page Control Button) in the top right to permanently stay visible instead of having to mouse-over add following code. Some people want this great feature to be highly visible and not hidden like it is.
/*Permanent Page Controls */
#pageControls a{ display: block !important; }
40+ Most Wanted Mystique Theme Modifications, Hacks
18. Remove page controls permanently :
/* Remove page controls */
#pageControls{
height:100px;
position:absolute;
right:0;
top:0;
width:0;
z-index:4;
19.  Alternate header image:
To use following header image add given code below image.
40+ Most Wanted Mystique Theme Modifications, Hacks
/* Alternate header image */
#page{background-image:url(http://localhost/wp-content/themes/mystique/images/_alt/header2.jpg);}
Replace localhost by your site URL.
20. Move up the rss feed and twitter buttons:
By default I find Twitter and RSS buttons are hidden by the navigation bar and are hard to see and are not easily accessible to readers, so you move them up for user friendliness.
/* Move up Twitter and RSS buttons */
#header a.nav-extra{
height:64px;
}

#header p.nav-extra{
top:-60px;
}
40+ Most Wanted Mystique Theme Modifications, Hacks
21. Hide RSS button in navigation bar:
/* Hide RSS button */
#header a.rss{display:none;}
22. Hide Twitter button in navigation bar:
/* Hide Twitter button */
#header a.twitter{display:none;}
23. Hide post information bar:
In your homepage if you want to hide post information like Date, Posted by, Category, comment then use following code.
/* Hide post information bar */
.post-date, .post-info{display:none;}
24. Always show “REPLY | QUOTE | EDIT” in comments:
By default “REPLY | QUOTE | EDIT” will be shown when you hover mouse over them. To show them permanently use following code.
/* Always show “REPLY | QUOTE | EDIT” in comments */
#comments .controls{
 opacity : 1 !important;
 position: absolute;
 display: block !important;
 top: -3px !important;
}
40+ Most Wanted Mystique Theme Modifications, Hacks
25. Change footer background color to light gray:
40+ Most Wanted Mystique Theme Modifications, Hacks
/* Change footer background color to light gray */
#footer{background:#ddd;}
#footer-blocks .leftFade,#footer-blocks .rightFade{background-image:none;}
If you want other color then change value of #ddd, we are using #eeeeee value.
26. Change footer background color to dark gray:
/* Dark background footer */
#footer{background:#666;color:#ddd;}
#footer a{color:#fff;}
#footer-blocks .leftFade,#footer-blocks .rightFade{background-image:none;}
40+ Most Wanted Mystique Theme Modifications, Hacks
27. Get your uploaded background to repeat:
If you have uploaded custom background image and you want to repeat it then use following code.
body{background-repeat: repeat;}
(or repeat-x, repeat-y)

28. Adjust the space between line and paragraphs:
/* Adjust space between line and paragraphs */
.post-content p{
margin: 0 0 1.2em 0;
line-height: 150%;
}
First property:- Spacing between paragraphs (top/right/bottom/left).
Second property:- Spacing between lines. Adjust values accordingly.
29. Decrease the gap between widgets:
Some people don’t like the large gap between the the widgets. So here is the code to adjust the gap.
/* Decrease space between Widgets */
li.block{list-style-type:none;padding:0;margin:0;}
li.block, .arbitrary-block{margin:1em 0 1.2em;position:relative;}
Adjust the value of 1.2 accordingly.
40+ Most Wanted Mystique Theme Modifications, Hacks
30. Hide or remove the page title:
If you want to hide or remove post title on a single post page then add following code.
h1.title{font-size:0%;}
40+ Most Wanted Mystique Theme Modifications, Hacks

Other Tips and Tricks:

1. Place the description directly below the blog title, like this site:
Under Appearance -> Look in your style.css find
#site-title p.headline{float:left;border-left:1px solid  #999;margin:0 0 0 1em;padding:.2em 0 .2em  .8em;font-weight:normal;font-size:140%;line-height:64px;letter-spacing:0.4em;}
Delete:-   border-left:1px solid #999;
Add:-       clear:left;
Change:-  margin:0 0 0 0em;
Change:-  line-height:44px;
Change:-  padding:.2em 0 .2em .1em;
Adjust the numbers as you like.
2. Add favicon icon to your blog/site:
For those who don’t know what Favicon is ‘Favicon is a small icon (image) displayed at the beginning of the address bar of the browser. It is also called Favourite Icon, Page icon and url icon.’ Most of the people use 16*16 pixel favicon(you can also use 32*32 pixel favicon) with “.ico” format.But, you can also use gif,png (image formats) as well.
The main advantage of creating and using favicon is, it makes it easy to find your blog or site when someone favourites or bookmarked your site/blog among several other sites.
Under Appearance -> Look in your header.php, find
[/html]

and change it into

1
Don’t forget to replace, .ico and .gif file urls. Visit www.iconj.com for free 18000+ animated favicons, online icon generator, favicon hosting and more.
40+ Most Wanted Mystique Theme Modifications, Hacks
3. Get images in a post to open in lightbox, like this:
40+ Most Wanted Mystique Theme Modifications, Hacks
Lightbox is default feature provided in Mystique theme. The lightbox will open any link that ends in .jpg, .png or .gif (it will asume it’s a image) . So just make the images from the posts links. eg. thumbnails that link to the full size image.
4. To put a link  in the top navigation bar, add following code to, Under Appearance -> Mystique settings -> Advanced > User functions.
<!--?php function mymenu(){  echo '<li><a href="Link to Your Menu" rel="nofollow"><span>Menu Title</span>  <span></span></a></li>'; } add_action('mystique_navigation', 'mymenu'); ?-->
It is useful when you want to put a external link in navigation bar. Change “Link to your Menu” by your link and “Menu Title” by your title.
40+ Most Wanted Mystique Theme Modifications, Hacks
5. Make the background transparent:
Under Appearance -> Look in your style.css, find
/*** MAIN LAYOUT ***/
.shadow-left{background:url(images/shadow.png) no-repeat left bottom;}
 .shadow-right{background:url(images/shadow.png) no-repeat right bottom;padding-bottom:0px;position:relative;}
 #main{background:#fff url(images/main-right.jpg) no-repeat right top;}
 #main-inside{background:transparent url(images/main-left.jpg) no-repeat left top;min-height:380px;}
and change it into
/*** MAIN LAYOUT ***/
.shadow-left{background:url(images/shadow.png) no-repeat left bottom;}
 .shadow-right{background:url(images/shadow.png) no-repeat right bottom;padding-bottom:0px;position:relative;}
 #main{background:transparent;}
 #main-inside{background:transparent;min-height:380px;}
6. Remove the space between the top navigation bar and the actual content:
There is some space between the top navigation bar and the actual content. If you want to remove this space or you can join the content and the nav bar together. Under Appearance -> Look in your style.css, find
/*** MAIN LAYOUT ***/
.shadow-left{background:url(images/shadow.png) no-repeat left bottom;}
.shadow-right{background:url(images/shadow.png) no-repeat right bottom;padding-bottom:10px;position:relative;}
Change 10px to 0px if you want join the content and the nav bar together Or change it accordingly.
40+ Most Wanted Mystique Theme Modifications, Hacks
7. Another way to decrease the font size of posts title:
Under Appearance -> Look in your single.php, find
</pre>
<h1></h1>
<pre>
<!--?php endif; ?-->
Change h1 to every as you want. That is you can change it h2, h3 …
8. Another way to adjust the postion of Site_Title/Site_Logo :
In Appearence-> Editor -> Open Stylesheet (style.css), find:
/*** LOGO/Site_Title and Navbar***/
#site-title{padding:4em 0 3.7em 0;}
By adjusting value of 4em and 3.7em you can adjust header logo position. 4 em is space above site title and 3.7em is space between site title and Navigation bar.
9. Another way get more space between the lines:
In Appearence-> Editor -> Open Stylesheet (style.css), find:
p{margin:.6em 0 .3em;line-height:150%;}
By default value is 150%. You can change it to higher value as you need.
10. Include more text in feature content bar:
If you have increase the width of feature content bar then you want to include more text in feature content bar. To do this you require FTP client, then under wp-content -> themes -> mystique -> extensions -> featured-posts -> featured-posts.php, find
echo '</pre>
<div>'.mystique_strip_string(420, strip_tags(strip_shortcodes($featured_post['post_content']))).'</div>
<pre>
';
Change the 420 to however many characters you wish to have in your featured post.
We hoped that you enjoyed this long and resourceful article. If you like it please retweet and share it with your friends on Facebook. If you have some suggestion or problems about these tips and tricks, share it on our comment below.

Tuesday 25 October 2011

How to upgrade PHP version in XAMPP


Having been unable to find a definitive guide to upgrading the XAMPP PHP version to PHP 5.3.0rc2, I decided to improvise on a guide for installing the PHP 5.3 alpha.
My guide will describe how to upgrade the current XAMPP PHP version to the second release candidate of version 5.3. It is expected that this method will also work for the third release candidate when it is released later this month.

Step 1: Make backups
Before starting, make sure to backup any settings, custom modules and most importantly the htdocs directory, which contains your scripts and page resources. This directory is normally located atC:\xampp\htdocs\
Step 2: Preparation
  1. Download PHP 5.3.0rc2. I use the VC6 build in order to minimise any potential compatibility issues.
  2. It is also recommended that you download the latest Windows version of XAMPP. While this is an upgrade guide that shouldwork with previous versions of XAMPP, it is recommended that a fresh copy of the core files is used.
  3. Stop any instances of the Apache service that might be running.
Step 3: The upgrade
This guide will assume your XAMPP directory is C:\xampp\
  1. Extract the XAMPP archive to a directory of your choosing, I would recommend using the default C:\xampp\
  2. Extract the contents of the PHP archive to C:\xampp\php\, overwriting the contents of this directory with the new files.
  3. Open the file C:\xampp\apache\conf\extra\httpd-xampp.conf and ensure the following lines are present in this order:
    LoadFile "/xampp/php/php5ts.dll"
    LoadModule php5_module "/xampp/apache/bin/php5apache2_2.dll"
  4. Replace C:\xampp\php\php.ini with C:\xampp\php\php.ini-dist
    Uncomment the lines:
    ;extension=php_mbstring.dll
    ;extension=php_pdo_sqlite.dll
    Replace the line
    magic_quotes_gpc = On
    with
    magic_quotes_gpc = Off
  5. Copy all files in the C:\xampp\php\ to C:\xampp\apache\bin\ (do not copy the subdirectories or their contents).
After following the above steps, restart your Apache service (this can be done using C:\xampp\xampp-control.exe or manually through the control panel/command prompt). Your PHPinfo should indicate that the upgrade has been successful.
I will update this post if I discover any problems from using this method, or a cleaner (automated) means of performing the upgrade.