Misc
|
Tuesday, 24 June 2008 |
As you already know, Joomla has a built-in PDF generator. The problem with PDF's is that sometimes Google places the PDFs in search results instead of the original Joomla HTML content article. Somehow, the PDFs are more optimized than the HTML, probably because their keyword density is higher, and they don't include the navigation and modules usually found on a Joomla HTML page. When visitors search google and find the PDF instyead of the article, you may lose them, because they have no navigation menu, nosite search, and so on. They just get annoyed waiting for Adobe's reader browser plugin to load. The solution is simple, you need to alter your robots.txt (found in site root) and add these 2 lines to prevent PDF's from being crawled and included in Google's index User-agent: Googlebot
Disallow: /index2.php?option=com_content&do_pdf=1* Here are another 2 lines to block Yahoo Slurp crawler from indexing Joomla generated PDFs User-agent: Slurp
Disallow: /index2.php?option=com_content&do_pdf=1* Google/Yahoo allow wildcard matches in robots.txt, while other search engine robots may not. This technique will yeld its results when Google reindexes your site. Resources: Google Webmaster help center I don't want to list every file that I want to block. Can I use pattern matching? Yahoo robots.txt guide http://www.robotstxt.org/
Be first to comment this article |
Last Updated ( Wednesday, 25 June 2008 )
|
|
Misc
|
Monday, 23 June 2008 |
Here's my technique for rendering rounded corner boxes for Joomla. It's flexible, it can stretch both horizontally and vertically. I use one large background image cleverly positioned in each of module's nested divs. One image means one HTTP request, and this is as good as it gets for loading speed. The only limitation with this technnique is that a module cannot be infinitely large, it must be a bit smaller than the background image. The image i'm using is 775px wide x 1969px tall, so it should accomodate very large modules. It only weights 15.6KB There are no IE hacks, it just works in all browsers(tested in Firefox, Opera 9, IE6, IE7). So, let's get on to the CSS: /*TeachMeJoomla's flexible rounded corners module CSS*/
/*image setup */
div.module-green, div.module-green div{
background: url('images/rounded_green.jpg');
}
/*replaced with TeachMeJoomla's single image technique*/
div.module-green
{
padding: 0px 0px 0px 0px;
margin:0px 0px 0px 0px;
background-repeat:no-repeat;
background-position:bottom left;
height:1%;
width:auto;
}
div.module-green div
{
margin:0px 0px 0px 13px;
background-repeat:no-repeat;
background-position: bottom right;
padding: 0px 0px 13px 0px;
width:auto;
}
div.module-green div div
{
background-position: top right;
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
}
div.module-green div div div
{
margin:0px 13px 0px -13px;
background-position: top left;
padding: 13px 0px 0px 13px;
}
/*reset nested divs*/
div.module-green div div div div
{
padding:0px 0px 0px 0px;
margin:0px 0px 0px 0px;
background:none;
background-image: none;
background-position: top left;
background-repeat: repeat;
background-color: transparent;
width:100%;
} Here's the HTML, generated from your template by mosLoadPosition('module_position',-3) or (Joomla! 1.5) <jdoc:include type="modules" name="module_position"
style="rounded" headerLevel="3" />
<div class="module-green">
<div>
<div>
<div>
<p>
Look! I'm a flexible rounded corners box
with 1 single background image!
here's more HTML
</p>
<ul>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
</ul>
</div>
</div>
</div>
</div> And here's the final rendered box. Look! I'm a flexible rounded corners box with 1 single background image! Here's more HTML Comments (2) |
Last Updated ( Tuesday, 24 June 2008 )
|
|
Misc
|
Monday, 23 June 2008 |
Here's a simple way to render an animation when your users get a system message. The Javascript searches for an element with the ".message" class, it waits 2 and a half seconds, then it fades and shrinks the message away. To make sure the message is in sight, WinScroller scrolls to the element with the 'header' id. You need to modify this id to suit your templates's header or main column. The message is passed as a request variable, 'mosmsg'. This code snippet should be pasted into the head section of your template (between <head></head> tags) <script type="text/javascript" >
var tmjmosmsg,fx;
function pload(){
tmjmosmsg=$$('div.message');
if($type(tmjmosmsg[0])=='element'){
var el=tmjmosmsg[0];
el.setStyle('overflow','hidden');
var h=el.getSize().size.y;
fx = new Fx.Styles(el, {duration:900, wait:false});
//scrol to message
winScroller = new Fx.Scroll(window);
winScroller.toElement($('header'));
//delayed start, then remove the html element upon completion
(function(){
fx.start({
'margin-top':-1*h.toInt(),
opacity:0
}).chain(function(){el.remove();}); }).delay(2500);
}
};
window.addEvent('load',function(){
pload();
}
);
</script> Make sure you loaded mootools v.1.11 before this code. Joomla 1.5 loads it automatically for you, Joomla 1.0.15 needs to specifically load mootools trough a <script src="..."></script> tag. The file you need to alter is located at templates/your_current_template/index.php. The script is installled on this site, you'll notice it when posting comments. Comments (1) |
Last Updated ( Monday, 23 June 2008 )
|
|
Misc
|
Monday, 23 June 2008 |
As you already know, Google is automatically redirecting to your country's Google domain. But what if you're searching some code or english content and you're in Botswana? Google will favor Botswana results, and this is not always desirable. The quick solution is to specifically search Google international at this URL http://www.google.com/ncr Simple and effective. NCR=No Country Redirection. Be first to comment this article |
|
Misc
|
Wednesday, 28 May 2008 |
Here's a trick to redirect your ugly Joomap Google XML sitemap URL to a more "standard" URL. The benefit is a nicer URL, which can be succesfully submitted or even autodiscovered without submission by all search providers that support the Sitemaps protocol. This trick mimics a sitemap.xml file placed in site root, as the sitemaps protocol requires. The trick requires apache mod_rewrite and local .htaccess support. (Requirements are already met if you're succesfully using a 3rd party SEF extension for Joomla, such as Artio JoomSef, sh404SEF, sefAdvance, etc.) This was tested with Joomap 2.0.5. It also works with Artio JoomSef installed. All you have to do is paste the following 3 lines in your .htaccess file, just after the line that reads 'RewriteEngine On' # redirect joomap by TMJ
RewriteCond %{REQUEST_URI} ^(/sitemap.xml)$
RewriteRule (.*) index.php?option=com_joomap&view=google [L] On the 3rd line of code you'll notice the "destination" URL 'index.php?option=com_joomap&view=google' If you're also using a SEF extension that enforces non-sef urls redirects to sef URLs, please change this URL to the final URL for the sitemap, like 'option/com_joomap/view.html' Please note there is no leading slash. Be first to comment this article |
Last Updated ( Wednesday, 28 May 2008 )
|
|
Misc
|
Saturday, 23 February 2008 |
Here's a handy one-liner to help you replace strings globally throughout all the files in a specified folder. This procedure is also called mass find and replace, or global replace. You can even use it on windows if you're willing to spent a few minutes installing cygwin , a windows port of the gnu/linux most used utilities (including the bash shell and even X11) The code below will replace every occurence of 'ugly' with 'beautiful'. Linux example: find /home/bruno/old-friends -type f -exec sed -i 's/ugly/beautiful/g' {} ; Cygwin example (you have to use unix-style paths): find /cygdrive/c/xampp/joomla/ -type f -exec sed -i 's/ugly/beautiful/g' {} ; /cygdrive/c/ stands for the root of your C windows drive letter Also note that Cygwin requires you to use the forward slash delimiter instead of the windows backslash delimiter. The bash shell allows TAB completion for paths, just type the first few letters and hit TAB to auto-complete the path. If you want to filter, let's say, php files, you can add -name '*.php' to command-line arguments, just after the search path. find /cygdrive/c/xampp/joomla/ -type f -name '*.php' -exec sed -i 's/ugly/beautiful/g' {} ; Comments (2) |
Last Updated ( Monday, 26 May 2008 )
|
|
PHP
|
Monday, 13 August 2007 |
Here's a function to detect remote IP, even if client is behind a proxy function validip($ip) {
if (!empty($ip) && ip2long($ip)!=-1) {
$reserved_ips = array (
array('0.0.0.0','2.255.255.255'),
array('10.0.0.0','10.255.255.255'),
array('127.0.0.0','127.255.255.255'),
array('169.254.0.0','169.254.255.255'),
array('172.16.0.0','172.31.255.255'),
array('192.0.2.0','192.0.2.255'),
array('192.168.0.0','192.168.255.255'),
array('255.255.255.0','255.255.255.255')
);
foreach ($reserved_ips as $r) {
$min = ip2long($r[0]);
$max = ip2long($r[1]);
if ((ip2long($ip) >= $min) && (ip2long($ip) <= $max)) return false;
}
return true;
} else {
return false;
}
}
function getip() {
if (validip($_SERVER["HTTP_CLIENT_IP"])) {
return $_SERVER["HTTP_CLIENT_IP"];
}
foreach (explode(",",$_SERVER["HTTP_X_FORWARDED_FOR"]) as $ip) {
if (validip(trim($ip))) {
return $ip;
}
}
if (validip($_SERVER["HTTP_X_FORWARDED"])) {
return $_SERVER["HTTP_X_FORWARDED"];
} elseif (validip($_SERVER["HTTP_FORWARDED_FOR"])) {
return $_SERVER["HTTP_FORWARDED_FOR"];
} elseif (validip($_SERVER["HTTP_FORWARDED"])) {
return $_SERVER["HTTP_FORWARDED"];
} elseif (validip($_SERVER["HTTP_X_FORWARDED"])) {
return $_SERVER["HTTP_X_FORWARDED"];
} else {
return $_SERVER["REMOTE_ADDR"];
}
}
?> Credits go to http://algorytmy.pl/doc/php/function.getenv.php Comments (3) |
Last Updated ( Thursday, 19 June 2008 )
|
|
|