Updates from May, 2009 Toggle Comment Threads | Keyboard Shortcuts

  • r4ccoon 2:34 am on May 20, 2009 Permalink | Reply
    Tags:   

    php function, another behaviour of count() and return value of it 

    $array = array();

    $value = false;

    count($value) will return 1

    count($array) will return 0 – zero –

    so i ve been using a variable that v’been returned from a DB class, and that class returning false if it doesnt found a record.

    if(count($rows)>0) {
    doSomething();
    }

    so that logic wouldnt work correctly because it always return value bigger than zero. and that logic always TRUE(because counting a false variable resulting as 1).

    so if you happens doing the same thing as i did, try to use

    if($rows){
    doSomething();
    }

    because PHP will return 0 as a FALSE..

    ok this is the other code snippet that you can use

    $arr = array();
     $var = false;
     if(count($var)>0){echo "ROFL";}
     if($var)echo "LOL";
     if($arr)echo "AFK";

    and the echoed value would be only “ROFL”

     
  • r4ccoon 4:43 am on May 19, 2009 Permalink | Reply
    Tags: firebug,   

    Using Firebug Tutorial 

    i found interesting tutorial about how to use firebug.

    this video is about modifying joomla template. you can see the results within changes you made in firebug.

    http://help.joomla.org/files/joomla_firebug_tutorial_part2.swf

     
  • r4ccoon 4:32 am on May 19, 2009 Permalink | Reply
    Tags: ,   

    How to override the output from the Joomla! core 

    http://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core

    There may be occasions where you would like to change the way a Joomla! Extension (such as a Component or Module, whether from the Joomla! core or produced by a third party) is displayed on your site. Of course, you could recode the Extension from scratch, but that may be a bit ambitious for you! Thankfully, there is another way.

    The standard output from any Joomla! Module or Component can be overridden by adding code to the html directory of your template. It is also possible to override two aspects of core functionality: Module chrome, and pagination.

    Getting a head-start with overrides

    If you are new to Joomla! development, then it is probably easiest to start with an existing view, and try modifying it to get what you want. To do this, you should make a copy of the existing view in the html directory of your template, and then modify the copy.

    The directory structure you need is:

    TEMPLATE_NAME/html/EXTENSION_NAME/VIEW_NAME/FILE_NAME.php

    For example, if you want to change the way that the ‘Article‘ view displays a com_content article, then you should copy the file at

    PATH_TO_JOOMLA/components/com_content/views/article/tmpl/default.php
    to
    TEMPLATE_NAME/html/com_content/article/default.php

    (note the slight difference in directory structure)

    Similarly, if you want to change how the mod_login Module is displayed, then you should copy

    PATH_TO_JOOMLA/modules/mod_login/tmpl/default.php
    to
    TEMPLATE_NAME/html/mod_login/default.php

    Joomla! comes pre-packaged with a frontend template called Beez. Beez utilizes template overrides to produce a table-less layout for faster, smoother, and semantically correct markup. To see how it’s done, locate your Joomla! installation’s template directory, and you’ll notice the Beez template. Inside the Beez template directory, you’ll find a directory named html

    the entire directory structure is as follows:

    /your_joomla/templates/Beez/html/

    If you want to try modifying the overrides used in Beez, you could simply copy and paste the Beez html directory into your own template’s main directory. However you choose to make your override files, you will need to ensure that they are correctly installed with your template. To do this, you should add the following code to your template’s templateDetails.xml file (in between the <files> and </files> tags):

    <folder>html</folder>

    The above code in essence lets the Joomla! package installer know that there are files to extract, and that they are part of the template as a whole.

    Further tips

    Template overrides are almost limitless. They allow you to add, edit, and remove the components of the Joomla! core output. Note: For the FireFox web browser, an extension is available called Firebug, which is useful for browsing a page’s HTML source and matching it up with the PHP code used in template overrides. A free video tutorial on using Firebug with Joomla is available here.

    More information is available from the following resources:

     
  • r4ccoon 6:02 am on May 16, 2009 Permalink | Reply  

    Crucial Concepts Behind Advanced Regular Expressions 

    Regular expressions (or regex) are a powerful way to traverse large strings in order to find information. They rely on underlying patterns in a string’s structure to work their magic. Unfortunately, simple regular expressions are unable to cope with complex patterns and symbols. To deal with this dilemma, you can use advanced regular expressions.

    Below, we present an introduction to advanced regular expressions, with eight commonly used concepts and examples. Each example outlines a simple way to match patterns in complex strings. If you do not yet have experience with basic regular expressions, have a look at this article to get started. The syntax used here matches PHP’s Perl-compatible regular expressions.

    http://www.smashingmagazine.com/2009/05/06/introduction-to-advanced-regular-expressions/

     
  • r4ccoon 1:47 pm on May 15, 2009 Permalink | Reply
    Tags:   

    Custom 404 error pages with CodeIgniter 

    http://maestric.com/en/doc/php/codeigniter_404

    Quick and simple way to use a standard controller method for 404 error pages.

    Create controller/method for 404 errors

    system/application/controllers/error.php

    <?php
    class Error extends Controller {
    
    	function error_404()
    	{
    		echo "404 - not found";
    	}
    } 

    (More …)

     
  • r4ccoon 8:02 am on May 2, 2009 Permalink | Reply
    Tags: ,   

    krumo in codeigniter 

    some days ago, I was looking for alternatives for print_r() & var_dump() for debugging my data, and I found this Krumo :
    http://krumo.kaloyan.info/

    I’m sure you’ll like it. so, to integrate it with CI, just do the next simple steps:
    1- Rename class.krumo.php to Krumo.php
    2- Edit Krumo.php and edit :
    a. replace “Class krumo {” with “Class Krumo extends Model {”
    b. add after this function :

    function Krumo() {
    parent
    ::Model();
    }

    3- Edit krumo.ini for ur needs ( CSS & Theme )
    4- FINALLy, Copy Krumo.php, krumo.js, krumo.ini, skins.

    now, you can load it easily:
    $this->Krumo(YOUR-DATA);

    Hope it helps !

     
  • r4ccoon 6:36 am on April 14, 2009 Permalink | Reply
    Tags: ,   

    regexp pattern to check only email address 

    ^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$

    on php


    if(preg_match('/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/',$email,$matchemail)){
    print_r($matchemail);
    }

     
  • r4ccoon 6:07 am on April 14, 2009 Permalink | Reply  

    regexp pattern that match only alphanumeric 

    ^([a-z0-9]+)$    or you can do this ^([a-zA-Z0-9]+)$

    php sample

    if(preg_match('/^([a-z0-9]+)$/',$username,$match)){
    print_r($match);
    }

     
  • r4ccoon 5:07 am on April 14, 2009 Permalink | Reply  

    javascript return confirm 

    <a href="delete.php" OnClick="return confirm('blah blah');"> Click here </a>
    
    or
    
    ECHO "<a href=\"delete.php\" OnClick=\"return confirm('blah blah');\"> Click here </a>";
     
  • r4ccoon 12:43 pm on April 5, 2009 Permalink | Reply  

    change tortoise svn password to connect with 

    Hello, somehow when I update the repository, another username/password is being use.  I think this happened because I recently configured another program to use svn.exe to use this username/password, but I don’t want all my regular work using this.  I didn’t see any obvious options to change this once I put this in, can someone help me change this?

    Tortoise SVN | Settings | Saved Data | Authentication Data | Clear

    That will clear the stored information, and you will be prompted for
    it the next time it’s needed.

    Jeff
    from http://www.nabble.com/Change-user-password-I-connect-with–td5854426.html

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel