Logaholic.de

Avatar

web development

Premade admin panel layout – Complete Liquid Admin Control Panel

I found this nice premade admin panel layout on themeforest.net, a single licence is just 15$ (10-projects licence 45$, which I bought).

Complete Liquid Admin Control Panel

Author description:

Complex Liquid Admin template that contains a login page as well as a modular content page that includes all the elements you could possibly need in your admin. From these elements you should be able to generate any required page.

Please open the preview to check out all the elements.

Liquid as oposed to a fixed size means all the screen real-estate is used in the most efficient manner possible and also eliminates compatibility issues with non-standard, very low or very high screen resolutions.

Tableless CSS coding, cross-browser compatible and very stylish. Impress your customers today !

The template includes all page .psd files as well as slices and should be Easy to customise with medium knowledge of Photoshop and CSS .

Later edit : This template also contains rectangular notification boxes (ex. positive, negative, site message etc.) like our FlexiAdmin, however the shots don’t show this. So if you need these no worries, you will find them in the download package.

I’m impressed with the details and “amount of work” you get for that small price. I’m definitely going to use this in some projects – at least in my own ;)

Links:

Elegant OOP HTML scraping with DOMDocument

Over the years, I had to do html scraping sometimes. At my very first coding attempts some years ago, I found the explode() function to be pretty nice for this purpose. Not being satisfied with its (nonexistant) fault-tolerance, I learned regular expressions and used them. But regex only gets you so far in the DOM-tree. Finally, I arrived at the DOMDocument class, the builtin PHP answer to DOM parsing/manipulation. Looking into this is really worth it, because it a) solves the problem (99.99%) and has a nice OOP way to achieve it.

I will show you two very simple examples with all three methods – see for yourself why one should use DOMDocument ;)

Sample 1:

<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
    <head>
        <title>example</title>
    </head>
    <body>
        <div id="fetchme">
            foobar
        </div>
    </body>
</html>

Scraping:

// explode
$dataFirst = explode('<div id="fetchme">', $sample);
$dataSecond = explode('</div>', $dataFirst[1]);
$result = trim($dataSecond[0]);
echo $result;

// regex
preg_match('#<div id="fetchme">(.*)</div>#is', $sample, $matches);
$result = trim($matches[1]);
echo $result;

// domdocument
$doc = new DOMDocument();
$doc->loadHTML($sample);
$element = $doc->getElementById('fetchme');
$result = trim($element->nodeValue);
echo $result;

All three methods get this very simple example right ($result will be ‘foobar’).

Adding complexity, two of them fail badly, because they do not know which closing tag belongs to which opening tag.

Sample 2:

<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
    <head>
        <title>example</title>
    </head>
    <body>
        <div>
            <div id="fetchme">
                foo
                <div>
                    bar
                </div>
            </div>
        </div>
    </body>
</html>

Scraping:

The scraping methods are the same as for the first example, but with different output:
The explode method returns: ‘foo <div> bar’
The regex method returns: ‘foo <div> bar </div> </div>’ (the non-greedy regex would return the same as the explode version).
The DOMDocument method returns ‘foo bar’, because nodeValue strips htmltags. But the DOMElement $element holds just the content of the div #fetchme as we wanted it. It gets it right again.

Sidenotes:

You should know, some sites do not follow the (x)html standards correctly and therefore DOMDocument can fail. It also likes to throw exceptions then, but besides complaining you can still use > 90% of the document. If you want to disable the exceptions, you could either do it with @$doc->loadHTML() or $doc->strictErrorChecking = false.

Conclusion:

Besides DOMDocument solving the tag-matching issues, it also provides a much cleaner way to do HTML scraping jobs imho. It also is a lot more fault tolerant, one could use xpath-queries against the document, etc.

,